	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function d3d9_read_viewport
_d3d9_read_viewport:                    ## @d3d9_read_viewport
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	$0, -56(%rbp)
	movq	$0, -48(%rbp)
	movl	16(%rdi), %r12d
	leaq	-64(%rbp), %rdi
	leaq	-60(%rbp), %rsi
	callq	_video_driver_get_size
	xorl	%r15d, %r15d
	leaq	-56(%rbp), %rdx
	movl	%r12d, %edi
	xorl	%esi, %esi
	callq	_d3d9_device_get_render_target
	testl	%eax, %eax
	je	LBB0_15
## %bb.1:
	movl	-64(%rbp), %r13d
	movl	-60(%rbp), %r15d
	xorl	%eax, %eax
	callq	_d3d9_get_xrgb8888_format
	movq	_D3DPOOL_SYSTEMMEM@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r8d
	movq	$0, (%rsp)
	leaq	-48(%rbp), %r9
	movl	%r12d, %edi
	movl	%r13d, %esi
	movl	%r15d, %edx
	movl	%eax, %ecx
	callq	_d3d9_device_create_offscreen_plain_surface
	testl	%eax, %eax
	je	LBB0_13
## %bb.2:
	movq	-56(%rbp), %rsi
	movq	-48(%rbp), %rdx
	movl	%r12d, %edi
	callq	_d3d9_device_get_render_target_data
	testl	%eax, %eax
	je	LBB0_13
## %bb.3:
	movq	-48(%rbp), %rdi
	leaq	-80(%rbp), %rsi
	callq	_d3d9_surface_lock_rect
	testq	%rax, %rax
	movl	$0, %r15d
	je	LBB0_15
## %bb.4:
	movl	(%r14), %edx
	testl	%edx, %edx
	je	LBB0_14
## %bb.5:
	movslq	12(%r14), %rcx
	shlq	$2, %rcx
	addq	-72(%rbp), %rcx
	movl	-80(%rbp), %esi
	leal	3(%rsi), %eax
	testl	%esi, %esi
	cmovnsl	%esi, %eax
	leal	-1(%rdx), %esi
	sarl	$2, %eax
	imull	%eax, %esi
	leaq	(%rcx,%rsi,4), %rcx
	movl	4(%r14), %esi
	imull	%eax, %esi
	shlq	$2, %rsi
	subq	%rsi, %rcx
	movl	8(%r14), %edi
	shlq	$2, %rax
	negq	%rax
	xorl	%esi, %esi
	jmp	LBB0_8
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_8 Depth=1
	xorl	%edi, %edi
LBB0_7:                                 ##   in Loop: Header=BB0_8 Depth=1
	incl	%esi
	addq	%rax, %rcx
	cmpl	%edx, %esi
	jae	LBB0_14
LBB0_8:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_10 Depth 2
	testl	%edi, %edi
	je	LBB0_6
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	xorl	%edx, %edx
	.p2align	4, 0x90
LBB0_10:                                ##   Parent Loop BB0_8 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movzbl	(%rcx,%rdx,4), %edi
	movl	%edi, (%rbx)
	movzbl	1(%rcx,%rdx,4), %edi
	movl	%edi, 4(%rbx)
	movzbl	2(%rcx,%rdx,4), %edi
	movl	%edi, 8(%rbx)
	addq	$12, %rbx
	incq	%rdx
	movl	8(%r14), %edi
	cmpq	%rdi, %rdx
	jb	LBB0_10
## %bb.11:                              ##   in Loop: Header=BB0_8 Depth=1
	movl	(%r14), %edx
	jmp	LBB0_7
LBB0_13:
	xorl	%r15d, %r15d
	jmp	LBB0_15
LBB0_14:
	movq	-48(%rbp), %rdi
	callq	_d3d9_surface_unlock_rect
	movl	$1, %r15d
LBB0_15:
	movq	-56(%rbp), %rdi
	testq	%rdi, %rdi
	je	LBB0_17
## %bb.16:
	callq	_d3d9_surface_free
LBB0_17:
	movq	-48(%rbp), %rdi
	testq	%rdi, %rdi
	je	LBB0_19
## %bb.18:
	callq	_d3d9_surface_free
LBB0_19:
	movl	%r15d, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_D3DPOOL_SYSTEMMEM,4,2          ## @D3DPOOL_SYSTEMMEM
	.no_dead_strip	_d3d9_read_viewport
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function d3d9_read_viewport
_d3d9_read_viewport:                    ; @d3d9_read_viewport
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	mov	x20, x1
	mov	x19, x0
	stp	xzr, xzr, [sp, #8]
	ldr	w21, [x0, #16]
	add	x0, sp, #44
	add	x1, sp, #40
	bl	_video_driver_get_size
	add	x2, sp, #16
	mov	x0, x21
	mov	w1, #0
	bl	_d3d9_device_get_render_target
	cbz	w0, LBB0_11
; %bb.1:
	ldp	w23, w22, [sp, #40]
	bl	_d3d9_get_xrgb8888_format
	mov	x3, x0
Lloh0:
	adrp	x8, _D3DPOOL_SYSTEMMEM@GOTPAGE
Lloh1:
	ldr	x8, [x8, _D3DPOOL_SYSTEMMEM@GOTPAGEOFF]
Lloh2:
	ldr	w4, [x8]
	add	x5, sp, #8
	mov	x0, x21
	mov	x1, x22
	mov	x2, x23
	mov	x6, #0
	bl	_d3d9_device_create_offscreen_plain_surface
	cbz	w0, LBB0_11
; %bb.2:
	ldp	x2, x1, [sp, #8]
	mov	x0, x21
	bl	_d3d9_device_get_render_target_data
	cbz	w0, LBB0_11
; %bb.3:
	ldr	x0, [sp, #8]
	add	x1, sp, #24
	bl	_d3d9_surface_lock_rect
	cbz	x0, LBB0_11
; %bb.4:
	ldr	w11, [x19]
	cbz	w11, LBB0_16
; %bb.5:
	mov	x10, #0
	mov	w8, #0
	ldr	x9, [sp, #32]
	ldrsw	x12, [x19, #12]
	add	x9, x9, x12, lsl #2
	sub	w12, w11, #1
	ldr	w13, [sp, #24]
	add	w14, w13, #3
	cmp	w13, #0
	csel	w13, w14, w13, lt
	asr	w13, w13, #2
	mul	w12, w12, w13
	add	x9, x9, w12, uxtw #2
	ldp	w14, w12, [x19, #4]
	mul	w14, w14, w13
	sub	x9, x9, w14, uxtw #2
	sub	x10, x10, w13, uxtw #2
	b	LBB0_7
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=1
	add	w8, w8, #1
	add	x9, x9, x10
	cmp	w8, w11
	b.hs	LBB0_16
LBB0_7:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_9 Depth 2
	cbz	w12, LBB0_6
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	x11, #0
LBB0_9:                                 ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	add	x12, x9, x11, lsl #2
	ldrb	w13, [x12]
	str	w13, [x20]
	ldrb	w13, [x12, #1]
	str	w13, [x20, #4]
	ldrb	w12, [x12, #2]
	add	x13, x20, #12
	str	w12, [x20, #8]
	add	x11, x11, #1
	ldr	w12, [x19, #8]
	mov	x20, x13
	cmp	x11, x12
	b.lo	LBB0_9
; %bb.10:                               ;   in Loop: Header=BB0_7 Depth=1
	ldr	w11, [x19]
	mov	x20, x13
	b	LBB0_6
LBB0_11:
	mov	w19, #0
	ldr	x0, [sp, #16]
	cbz	x0, LBB0_13
LBB0_12:
	bl	_d3d9_surface_free
LBB0_13:
	ldr	x0, [sp, #8]
	cbz	x0, LBB0_15
; %bb.14:
	bl	_d3d9_surface_free
LBB0_15:
	mov	x0, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_16:
	ldr	x0, [sp, #8]
	bl	_d3d9_surface_unlock_rect
	mov	w19, #1
	ldr	x0, [sp, #16]
	cbnz	x0, LBB0_12
	b	LBB0_13
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_D3DPOOL_SYSTEMMEM,4,2          ; @D3DPOOL_SYSTEMMEM
	.no_dead_strip	_d3d9_read_viewport
.subsections_via_symbols
