	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ReadMemory                     ## -- Begin function ReadMemory
	.p2align	4, 0x90
_ReadMemory:                            ## @ReadMemory
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, %r12
	movl	%edx, -44(%rbp)                 ## 4-byte Spill
	testq	%rsi, %rsi
	je	LBB0_8
## %bb.1:
	testq	%r12, %r12
	je	LBB0_8
## %bb.2:
	movq	%rsi, %rbx
	cmpq	$0, (%rsi)
	jle	LBB0_8
## %bb.3:
	movq	%r8, %r15
	movl	16(%rbp), %eax
	movq	%rcx, -104(%rbp)
	movq	%r8, -96(%rbp)
	movl	%eax, -88(%rbp)
	leal	1(%rax), %edi
	movl	$1, %esi
	callq	_calloc
	movq	%rax, -80(%rbp)
	testq	%rax, %rax
	je	LBB0_12
## %bb.4:
	movl	(%rbx), %edi
	leaq	-104(%rbp), %rdx
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	callq	_ioctl
	testl	%eax, %eax
	je	LBB0_14
## %bb.5:
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	xorl	%eax, %eax
	callq	_getpagesize
	movl	%eax, %r13d
	leal	(%r15,%r13), %esi
	movl	%esi, %eax
	cltd
	idivl	%r13d
	subl	%edx, %esi
	movl	%esi, %ecx
	movq	%r15, -128(%rbp)                ## 8-byte Spill
	subl	%r15d, %ecx
	movl	16(%rbp), %ebx
	movl	%ebx, %r15d
	subl	%ecx, %r15d
	jle	LBB0_26
## %bb.6:
	movl	%edx, %r14d
	movl	%esi, -112(%rbp)                ## 4-byte Spill
	movl	%ecx, -88(%rbp)
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	movl	%ecx, -56(%rbp)                 ## 4-byte Spill
	leaq	-104(%rbp), %rdx
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	callq	_ioctl
	testl	%eax, %eax
	je	LBB0_15
## %bb.7:
	movq	%r12, %rdi
	movl	$255, %esi
	movl	-56(%rbp), %edx                 ## 4-byte Reload
	callq	_memset
	xorl	%eax, %eax
	jmp	LBB0_16
LBB0_8:
	movq	(%rdi), %rax
	testq	%r12, %r12
	je	LBB0_10
## %bb.9:
	leaq	L_.str.1(%rip), %rdi
	jmp	LBB0_11
LBB0_10:
	leaq	L_.str(%rip), %rdi
LBB0_11:
	callq	*%rax
LBB0_12:
	movl	$-1, %ebx
LBB0_13:
	movl	%ebx, %eax
	addq	$88, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_14:
	movq	-80(%rbp), %rsi
	movq	%r12, %rdi
	movl	16(%rbp), %ebx
	movl	%ebx, %edx
	jmp	LBB0_28
LBB0_15:
	movq	-80(%rbp), %rsi
	movq	%r12, %rdi
	movl	-56(%rbp), %edx                 ## 4-byte Reload
	callq	_memcpy
	movl	$1, %eax
LBB0_16:
	cmpl	%r13d, %r15d
	movl	-112(%rbp), %edx                ## 4-byte Reload
	movl	%eax, -60(%rbp)                 ## 4-byte Spill
	jge	LBB0_18
## %bb.17:
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	movl	-56(%rbp), %r14d                ## 4-byte Reload
	jmp	LBB0_24
LBB0_18:
	movslq	-56(%rbp), %rax                 ## 4-byte Folded Reload
	movslq	%r13d, %rcx
	movslq	%edx, %rbx
	subl	%r13d, %r14d
	movq	%r12, -120(%rbp)                ## 8-byte Spill
	leaq	(%r12,%rax,4), %r12
	movq	%rcx, -56(%rbp)                 ## 8-byte Spill
	leaq	(,%rcx,4), %rax
	movq	%rax, -112(%rbp)                ## 8-byte Spill
	jmp	LBB0_21
	.p2align	4, 0x90
LBB0_19:                                ##   in Loop: Header=BB0_21 Depth=1
	movq	%r12, %rdi
	movl	$255, %esi
	movl	%r13d, %edx
	callq	_memset
LBB0_20:                                ##   in Loop: Header=BB0_21 Depth=1
	addq	-56(%rbp), %rbx                 ## 8-byte Folded Reload
	subl	%r13d, %r14d
	addq	-112(%rbp), %r12                ## 8-byte Folded Reload
	movl	16(%rbp), %eax
	leal	(%rax,%r14), %r15d
	cmpl	%r13d, %r15d
	jl	LBB0_23
LBB0_21:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, -96(%rbp)
	movl	%r13d, -88(%rbp)
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	leaq	-104(%rbp), %rdx
	callq	_ioctl
	testl	%eax, %eax
	jne	LBB0_19
## %bb.22:                              ##   in Loop: Header=BB0_21 Depth=1
	movq	-80(%rbp), %rsi
	movq	%r12, %rdi
	movl	%r13d, %edx
	callq	_memcpy
	movl	$1, -60(%rbp)                   ## 4-byte Folded Spill
	jmp	LBB0_20
LBB0_23:
	movq	-128(%rbp), %rax                ## 8-byte Reload
	subl	%r14d, %eax
	negl	%r14d
	movl	%eax, %edx
                                        ## kill: def $r14d killed $r14d killed $r14
	movl	16(%rbp), %ebx
	movq	-120(%rbp), %r12                ## 8-byte Reload
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
LBB0_24:
	movslq	%edx, %rax
	movq	%rax, -96(%rbp)
	movl	%r15d, -88(%rbp)
	movl	(%rcx), %edi
	leaq	-104(%rbp), %rdx
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	callq	_ioctl
	movslq	%r14d, %rcx
	leaq	(%r12,%rcx,4), %rdi
	testl	%eax, %eax
	je	LBB0_27
## %bb.25:
	movl	$255, %esi
	movl	%r15d, %edx
	callq	_memset
	cmpl	$0, -60(%rbp)                   ## 4-byte Folded Reload
	jne	LBB0_29
LBB0_26:
	movl	$-1, %ebx
	jmp	LBB0_29
LBB0_27:
	movq	-80(%rbp), %rsi
	movl	%r15d, %edx
LBB0_28:
	callq	_memcpy
LBB0_29:
	movq	-80(%rbp), %rdi
	callq	_free
	jmp	LBB0_13
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid input buffer.\n"

L_.str.1:                               ## @.str.1
	.asciz	"IOCTL device not initialized.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ReadMemory                     ; -- Begin function ReadMemory
	.p2align	2
_ReadMemory:                            ; @ReadMemory
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x23, x5
	cbz	x1, LBB0_8
; %bb.1:
	cbz	x23, LBB0_8
; %bb.2:
	mov	x22, x1
	ldr	x8, [x1]
	cmp	x8, #1
	b.lt	LBB0_8
; %bb.3:
	mov	x19, x6
	mov	x27, x4
	mov	x21, x2
	stp	x3, x4, [sp, #32]
	add	w0, w6, #1
	str	w6, [sp, #48]
	mov	w1, #1
	bl	_calloc
	str	x0, [sp, #56]
	cbz	x0, LBB0_12
; %bb.4:
	ldr	w0, [x22]
	add	x2, sp, #32
	mov	x1, x21
	bl	_ioctl
	cbz	w0, LBB0_14
; %bb.5:
	bl	_getpagesize
	add	w20, w0, w27
	sdiv	w8, w20, w0
	mul	w8, w8, w0
	sub	w26, w8, w27
	sub	w25, w19, w26
	cmp	w25, #1
	b.lt	LBB0_25
; %bb.6:
	mov	x24, x0
	str	x8, [sp, #16]                   ; 8-byte Folded Spill
	str	w26, [sp, #48]
	ldr	w0, [x22]
	add	x2, sp, #32
	mov	x1, x21
	bl	_ioctl
	cbz	w0, LBB0_15
; %bb.7:
	mov	x0, x23
	mov	w1, #255
	mov	x2, x26
	bl	_memset
	mov	w28, #0
	b	LBB0_16
LBB0_8:
	ldr	x8, [x0]
	cbz	x23, LBB0_10
; %bb.9:
Lloh0:
	adrp	x0, l_.str.1@PAGE
Lloh1:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_11
LBB0_10:
Lloh2:
	adrp	x0, l_.str@PAGE
Lloh3:
	add	x0, x0, l_.str@PAGEOFF
LBB0_11:
	blr	x8
LBB0_12:
	mov	w19, #-1
LBB0_13:
	mov	x0, x19
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
LBB0_14:
	ldr	x1, [sp, #56]
	mov	x0, x23
	mov	x2, x19
	b	LBB0_27
LBB0_15:
	ldr	x1, [sp, #56]
	mov	x0, x23
	mov	x2, x26
	bl	_memcpy
	mov	w28, #1
LBB0_16:
	cmp	w25, w24
	ldr	x10, [sp, #16]                  ; 8-byte Folded Reload
	b.lt	LBB0_23
; %bb.17:
	str	w28, [sp, #28]                  ; 4-byte Folded Spill
	str	x27, [sp, #8]                   ; 8-byte Folded Spill
	sxtw	x28, w24
	mov	x8, x10
	mov	x9, x23
	sxtw	x23, w8
	sub	w8, w20, w10
	sub	w27, w8, w24
	sbfiz	x20, x24, #2, #32
	str	x9, [sp, #16]                   ; 8-byte Folded Spill
	add	x26, x9, w26, sxtw #2
	b	LBB0_20
LBB0_18:                                ;   in Loop: Header=BB0_20 Depth=1
	mov	x0, x26
	mov	w1, #255
	mov	x2, x24
	bl	_memset
LBB0_19:                                ;   in Loop: Header=BB0_20 Depth=1
	add	x23, x23, x28
	add	x26, x26, x20
	sub	w27, w27, w24
	add	w25, w19, w27
	cmp	w25, w24
	b.lt	LBB0_22
LBB0_20:                                ; =>This Inner Loop Header: Depth=1
	str	x23, [sp, #40]
	str	w24, [sp, #48]
	ldr	w0, [x22]
	add	x2, sp, #32
	mov	x1, x21
	bl	_ioctl
	cbnz	w0, LBB0_18
; %bb.21:                               ;   in Loop: Header=BB0_20 Depth=1
	ldr	x1, [sp, #56]
	mov	x0, x26
	mov	x2, x24
	bl	_memcpy
	mov	w8, #1
	str	w8, [sp, #28]                   ; 4-byte Folded Spill
	b	LBB0_19
LBB0_22:
	ldp	x8, x23, [sp, #8]               ; 16-byte Folded Reload
	sub	w10, w8, w27
	neg	w26, w27
	ldr	w28, [sp, #28]                  ; 4-byte Folded Reload
LBB0_23:
	sxtw	x8, w10
	str	x8, [sp, #40]
	str	w25, [sp, #48]
	ldr	w0, [x22]
	add	x2, sp, #32
	mov	x1, x21
	bl	_ioctl
	mov	x8, x0
	add	x0, x23, w26, sxtw #2
	cbz	w8, LBB0_26
; %bb.24:
	mov	w1, #255
	mov	x2, x25
	bl	_memset
	cbnz	w28, LBB0_28
LBB0_25:
	mov	w19, #-1
	b	LBB0_28
LBB0_26:
	ldr	x1, [sp, #56]
	mov	x2, x25
LBB0_27:
	bl	_memcpy
LBB0_28:
	ldr	x0, [sp, #56]
	bl	_free
	b	LBB0_13
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid input buffer.\n"

l_.str.1:                               ; @.str.1
	.asciz	"IOCTL device not initialized.\n"

.subsections_via_symbols
