	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function aspeed_video_check_and_set_polarity
_aspeed_video_check_and_set_polarity:   ## @aspeed_video_check_and_set_polarity
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_NUM_POLARITY_CHECKS@GOTPCREL(%rip), %r15
	cmpl	$0, (%r15)
	jle	LBB0_12
## %bb.1:
	movq	%rdi, %r14
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	_VE_MODE_DETECT_STATUS@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movq	%r14, %rdi
	callq	_aspeed_video_read
	movq	_VE_MODE_DETECT_STATUS_VSYNC@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	andl	%eax, %ecx
	negl	%ecx
	movl	$0, %ecx
	sbbl	%ecx, %ecx
	orl	$1, %ecx
	addl	%ecx, %r12d
	movq	_VE_MODE_DETECT_STATUS_HSYNC@GOTPCREL(%rip), %rcx
	andl	(%rcx), %eax
	negl	%eax
	movl	$0, %eax
	sbbl	%eax, %eax
	orl	$1, %eax
	addl	%eax, %r13d
	incl	%ebx
	cmpl	(%r15), %ebx
	jl	LBB0_2
## %bb.3:
	testl	%r13d, %r13d
	js	LBB0_5
## %bb.4:
	testl	%r12d, %r12d
	jns	LBB0_12
LBB0_5:
	testl	%r13d, %r13d
	js	LBB0_6
## %bb.7:
	movq	_V4L2_DV_HSYNC_POS_POL@GOTPCREL(%rip), %rcx
	movl	(%r14), %eax
	orl	(%rcx), %eax
	xorl	%ecx, %ecx
	jmp	LBB0_8
LBB0_6:
	movq	_V4L2_DV_HSYNC_POS_POL@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	(%r14), %eax
	movq	_VE_CTRL_HSYNC_POL@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
LBB0_8:
	movl	%eax, (%r14)
	testl	%r12d, %r12d
	js	LBB0_9
## %bb.10:
	movq	_V4L2_DV_VSYNC_POS_POL@GOTPCREL(%rip), %rdx
	orl	(%rdx), %eax
	movl	%eax, (%r14)
	testl	%ecx, %ecx
	je	LBB0_12
LBB0_13:
	movq	_VE_CTRL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	xorl	%edx, %edx
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_aspeed_video_update            ## TAILCALL
LBB0_9:
	movq	_VE_CTRL_VSYNC_POL@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	_V4L2_DV_VSYNC_POS_POL@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	notl	%edx
	andl	%eax, %edx
	movl	%edx, (%r14)
	testl	%ecx, %ecx
	jne	LBB0_13
LBB0_12:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NUM_POLARITY_CHECKS,4,2        ## @NUM_POLARITY_CHECKS
	.comm	_VE_MODE_DETECT_STATUS,4,2      ## @VE_MODE_DETECT_STATUS
	.comm	_VE_MODE_DETECT_STATUS_VSYNC,4,2 ## @VE_MODE_DETECT_STATUS_VSYNC
	.comm	_VE_MODE_DETECT_STATUS_HSYNC,4,2 ## @VE_MODE_DETECT_STATUS_HSYNC
	.comm	_VE_CTRL_HSYNC_POL,4,2          ## @VE_CTRL_HSYNC_POL
	.comm	_V4L2_DV_HSYNC_POS_POL,4,2      ## @V4L2_DV_HSYNC_POS_POL
	.comm	_VE_CTRL_VSYNC_POL,4,2          ## @VE_CTRL_VSYNC_POL
	.comm	_V4L2_DV_VSYNC_POS_POL,4,2      ## @V4L2_DV_VSYNC_POS_POL
	.comm	_VE_CTRL,4,2                    ## @VE_CTRL
	.no_dead_strip	_aspeed_video_check_and_set_polarity
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function aspeed_video_check_and_set_polarity
_aspeed_video_check_and_set_polarity:   ; @aspeed_video_check_and_set_polarity
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
Lloh0:
	adrp	x22, _NUM_POLARITY_CHECKS@GOTPAGE
Lloh1:
	ldr	x22, [x22, _NUM_POLARITY_CHECKS@GOTPAGEOFF]
	ldr	w8, [x22]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.1:
	mov	x19, x0
	mov	w23, #0
	mov	w20, #0
	mov	w21, #0
Lloh2:
	adrp	x24, _VE_MODE_DETECT_STATUS@GOTPAGE
Lloh3:
	ldr	x24, [x24, _VE_MODE_DETECT_STATUS@GOTPAGEOFF]
Lloh4:
	adrp	x25, _VE_MODE_DETECT_STATUS_VSYNC@GOTPAGE
Lloh5:
	ldr	x25, [x25, _VE_MODE_DETECT_STATUS_VSYNC@GOTPAGEOFF]
Lloh6:
	adrp	x26, _VE_MODE_DETECT_STATUS_HSYNC@GOTPAGE
Lloh7:
	ldr	x26, [x26, _VE_MODE_DETECT_STATUS_HSYNC@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x24]
	mov	x0, x19
	bl	_aspeed_video_read
	ldr	w8, [x25]
	sub	w9, w20, #1
	tst	w8, w0
	csinc	w20, w9, w20, ne
	ldr	w8, [x26]
	sub	w9, w21, #1
	tst	w8, w0
	csinc	w21, w9, w21, ne
	add	w23, w23, #1
	ldr	w8, [x22]
	cmp	w23, w8
	b.lt	LBB0_2
; %bb.3:
	tbnz	w21, #31, LBB0_5
; %bb.4:
	tbz	w20, #31, LBB0_12
LBB0_5:
	tbnz	w21, #31, LBB0_8
; %bb.6:
Lloh8:
	adrp	x8, _V4L2_DV_HSYNC_POS_POL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _V4L2_DV_HSYNC_POS_POL@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	ldr	w9, [x19]
	orr	w8, w9, w8
	str	w8, [x19]
	tbnz	w20, #31, LBB0_11
; %bb.7:
	mov	w3, #0
	b	LBB0_9
LBB0_8:
Lloh11:
	adrp	x8, _VE_CTRL_HSYNC_POL@GOTPAGE
Lloh12:
	ldr	x8, [x8, _VE_CTRL_HSYNC_POL@GOTPAGEOFF]
Lloh13:
	ldr	w3, [x8]
Lloh14:
	adrp	x8, _V4L2_DV_HSYNC_POS_POL@GOTPAGE
Lloh15:
	ldr	x8, [x8, _V4L2_DV_HSYNC_POS_POL@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	ldr	w9, [x19]
	bic	w8, w9, w8
	str	w8, [x19]
	tbnz	w20, #31, LBB0_11
LBB0_9:
Lloh17:
	adrp	x9, _V4L2_DV_VSYNC_POS_POL@GOTPAGE
Lloh18:
	ldr	x9, [x9, _V4L2_DV_VSYNC_POS_POL@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	orr	w8, w8, w9
	str	w8, [x19]
	cbz	w3, LBB0_12
LBB0_10:
Lloh20:
	adrp	x8, _VE_CTRL@GOTPAGE
Lloh21:
	ldr	x8, [x8, _VE_CTRL@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #0
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	b	_aspeed_video_update
LBB0_11:
Lloh23:
	adrp	x9, _VE_CTRL_VSYNC_POL@GOTPAGE
Lloh24:
	ldr	x9, [x9, _VE_CTRL_VSYNC_POL@GOTPAGEOFF]
Lloh25:
	ldr	w3, [x9]
Lloh26:
	adrp	x9, _V4L2_DV_VSYNC_POS_POL@GOTPAGE
Lloh27:
	ldr	x9, [x9, _V4L2_DV_VSYNC_POS_POL@GOTPAGEOFF]
Lloh28:
	ldr	w9, [x9]
	bic	w8, w8, w9
	str	w8, [x19]
	cbnz	w3, LBB0_10
LBB0_12:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_NUM_POLARITY_CHECKS,4,2        ; @NUM_POLARITY_CHECKS
	.comm	_VE_MODE_DETECT_STATUS,4,2      ; @VE_MODE_DETECT_STATUS
	.comm	_VE_MODE_DETECT_STATUS_VSYNC,4,2 ; @VE_MODE_DETECT_STATUS_VSYNC
	.comm	_VE_MODE_DETECT_STATUS_HSYNC,4,2 ; @VE_MODE_DETECT_STATUS_HSYNC
	.comm	_VE_CTRL_HSYNC_POL,4,2          ; @VE_CTRL_HSYNC_POL
	.comm	_V4L2_DV_HSYNC_POS_POL,4,2      ; @V4L2_DV_HSYNC_POS_POL
	.comm	_VE_CTRL_VSYNC_POL,4,2          ; @VE_CTRL_VSYNC_POL
	.comm	_V4L2_DV_VSYNC_POS_POL,4,2      ; @V4L2_DV_VSYNC_POS_POL
	.comm	_VE_CTRL,4,2                    ; @VE_CTRL
	.no_dead_strip	_aspeed_video_check_and_set_polarity
.subsections_via_symbols
