	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ov5640_set_mode_exposure_calc
_ov5640_set_mode_exposure_calc:         ## @ov5640_set_mode_exposure_calc
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$0, 8(%rsi)
	je	LBB0_34
## %bb.1:
	movq	%rsi, %rbx
	movq	%rdi, %r15
	callq	_ov5640_get_exposure
	movl	%eax, %r14d
	testl	%eax, %eax
	js	LBB0_22
## %bb.2:
	movq	%r15, %rdi
	callq	_ov5640_get_binning
	testl	%eax, %eax
	js	LBB0_42
## %bb.3:
	je	LBB0_5
## %bb.4:
	movq	(%rbx), %rax
	movq	_OV5640_MODE_720P_1280_720@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	setne	%dl
	movq	_OV5640_MODE_1080P_1920_1080@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	setne	%cl
	andb	%dl, %cl
	shll	%cl, %r14d
LBB0_5:
	movq	%r15, %rdi
	callq	_ov5640_get_gain
	movl	%eax, %r13d
	testl	%eax, %eax
	js	LBB0_23
## %bb.6:
	movq	_OV5640_REG_AVG_READOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-48(%rbp), %rdx
	movq	%r15, %rdi
	callq	_ov5640_read_reg
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_43
## %bb.7:
	movq	%r15, %rdi
	callq	_ov5640_set_night_mode
	testl	%eax, %eax
	js	LBB0_42
## %bb.8:
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_ov5640_load_regs
	testl	%eax, %eax
	js	LBB0_42
## %bb.9:
	movq	%r15, %rdi
	callq	_ov5640_get_vts
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_24
## %bb.10:
	movq	%r15, %rdi
	callq	_ov5640_get_hts
	movl	%eax, %r12d
	testl	%eax, %eax
	js	LBB0_43
## %bb.11:
	je	LBB0_34
## %bb.12:
	movq	%r15, %rdi
	callq	_ov5640_get_sysclk
	testl	%eax, %eax
	js	LBB0_42
## %bb.13:
	je	LBB0_34
## %bb.14:
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	%r15, %rdi
	callq	_ov5640_get_light_freq
	movl	%eax, %ecx
	testl	%eax, %eax
	js	LBB0_25
## %bb.15:
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	imull	$100, %esi, %eax
	cltd
	idivl	%r12d
	movl	%eax, %edi
	cmpl	$60, %ecx
	jne	LBB0_17
## %bb.16:
	imull	$100, %edi, %eax
	movslq	%eax, %rdi
	imulq	$-2004318071, %rdi, %rax        ## imm = 0x88888889
	shrq	$32, %rax
	addl	%eax, %edi
	movl	%edi, %eax
	shrl	$31, %eax
	sarl	$6, %edi
	addl	%eax, %edi
LBB0_17:
	movl	(%r15), %ecx
	testl	%ecx, %ecx
	je	LBB0_26
## %bb.18:
	testl	%edi, %edi
	je	LBB0_34
LBB0_19:
	movl	-48(%rbp), %r8d
	cmpl	4(%r15), %r8d
	jle	LBB0_29
## %bb.20:
	cmpl	8(%r15), %r8d
	jge	LBB0_29
## %bb.21:
	imull	%r14d, %r13d
	imull	%esi, %r13d
	movl	%r13d, %eax
	cltd
	idivl	%ecx
	imull	12(%r15), %eax
	cltd
	idivl	%r12d
	leaq	16(%r15), %rcx
	movl	%r8d, %r12d
	jmp	LBB0_30
LBB0_22:
	movl	%r14d, %r12d
	jmp	LBB0_43
LBB0_23:
	movl	%r13d, %r12d
	jmp	LBB0_43
LBB0_24:
	movl	%ebx, %r12d
	jmp	LBB0_43
LBB0_26:
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdi
	callq	_ov5640_get_sysclk
	movl	%eax, %ecx
	testl	%eax, %eax
	js	LBB0_25
## %bb.27:
	je	LBB0_34
## %bb.28:
	movl	%ecx, (%r15)
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	testl	%edi, %edi
	jne	LBB0_19
	jmp	LBB0_34
LBB0_25:
	movl	%ecx, %r12d
	jmp	LBB0_43
LBB0_29:
	imull	%r14d, %r13d
	imull	%esi, %r13d
	movl	%r13d, %eax
	cltd
	idivl	%ecx
	leaq	12(%r15), %rcx
LBB0_30:
	addl	$-4, %ebx
	imull	(%rcx), %eax
	cltd
	idivl	%r12d
	movl	%eax, %ecx
	movl	%edi, %eax
	shll	$4, %eax
	cmpl	%eax, %ecx
	jge	LBB0_32
## %bb.31:
	leal	15(%rcx), %eax
	testl	%ecx, %ecx
	cmovnsl	%ecx, %eax
	sarl	$4, %eax
	cmpl	$2, %eax
	movl	$1, %r14d
	cmovgel	%eax, %r14d
	movl	%ecx, %eax
	cltd
	idivl	%r14d
	cmpl	$17, %eax
	movl	$16, %esi
	cmovgel	%eax, %esi
	jmp	LBB0_38
LBB0_32:
	movl	%ebx, %eax
	cltd
	idivl	%edi
	movl	%ebx, %r14d
	subl	%edx, %r14d
	movl	%r14d, %eax
	shll	$4, %eax
	cmpl	%eax, %ecx
	jle	LBB0_36
## %bb.33:
	testl	%r14d, %r14d
	jne	LBB0_37
LBB0_34:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
	jmp	LBB0_43
LBB0_36:
	leal	15(%rcx), %r14d
	testl	%ecx, %ecx
	cmovnsl	%ecx, %r14d
	sarl	$4, %r14d
	movl	%r14d, %eax
	cltd
	idivl	%edi
	subl	%edx, %r14d
	je	LBB0_34
LBB0_37:
	movl	%ecx, %eax
	cltd
	idivl	%r14d
	movl	%eax, %esi
LBB0_38:
	movq	%r15, %rdi
	callq	_ov5640_set_gain
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_43
## %bb.39:
	cmpl	%ebx, %r14d
	jle	LBB0_41
## %bb.40:
	leal	4(%r14), %esi
	movq	%r15, %rdi
	callq	_ov5640_set_vts
	testl	%eax, %eax
	js	LBB0_42
LBB0_41:
	movq	%r15, %rdi
	movl	%r14d, %esi
	callq	_ov5640_set_exposure
LBB0_42:
	movl	%eax, %r12d
LBB0_43:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_OV5640_MODE_720P_1280_720,8,3  ## @OV5640_MODE_720P_1280_720
	.comm	_OV5640_MODE_1080P_1920_1080,8,3 ## @OV5640_MODE_1080P_1920_1080
	.comm	_OV5640_REG_AVG_READOUT,4,2     ## @OV5640_REG_AVG_READOUT
	.no_dead_strip	_ov5640_set_mode_exposure_calc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ov5640_set_mode_exposure_calc
_ov5640_set_mode_exposure_calc:         ; @ov5640_set_mode_exposure_calc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	ldr	w8, [x1, #8]
	cbz	w8, LBB0_34
; %bb.1:
	mov	x23, x1
	mov	x19, x0
	bl	_ov5640_get_exposure
	mov	x21, x0
	tbnz	w0, #31, LBB0_22
; %bb.2:
	mov	x0, x19
	bl	_ov5640_get_binning
	mov	x20, x0
	tbnz	w0, #31, LBB0_35
; %bb.3:
	cbz	w20, LBB0_5
; %bb.4:
	ldr	x8, [x23]
Lloh0:
	adrp	x9, _OV5640_MODE_720P_1280_720@GOTPAGE
Lloh1:
	ldr	x9, [x9, _OV5640_MODE_720P_1280_720@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
Lloh3:
	adrp	x9, _OV5640_MODE_1080P_1920_1080@GOTPAGE
Lloh4:
	ldr	x9, [x9, _OV5640_MODE_1080P_1920_1080@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	ccmp	x8, x9, #4, ne
	cset	w8, ne
	lsl	w21, w21, w8
LBB0_5:
	mov	x0, x19
	bl	_ov5640_get_gain
	mov	x22, x0
	tbnz	w0, #31, LBB0_23
; %bb.6:
Lloh6:
	adrp	x8, _OV5640_REG_AVG_READOUT@GOTPAGE
Lloh7:
	ldr	x8, [x8, _OV5640_REG_AVG_READOUT@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_ov5640_read_reg
	mov	x20, x0
	cbnz	w0, LBB0_35
; %bb.7:
	mov	x0, x19
	bl	_ov5640_set_night_mode
	tbnz	w0, #31, LBB0_42
; %bb.8:
	mov	x0, x19
	mov	x1, x23
	bl	_ov5640_load_regs
	tbnz	w0, #31, LBB0_42
; %bb.9:
	mov	x0, x19
	bl	_ov5640_get_vts
	mov	x23, x0
	tbnz	w0, #31, LBB0_24
; %bb.10:
	mov	x0, x19
	bl	_ov5640_get_hts
	mov	x20, x0
	tbnz	w0, #31, LBB0_35
; %bb.11:
	cbz	w20, LBB0_34
; %bb.12:
	mov	x0, x19
	bl	_ov5640_get_sysclk
	mov	x24, x0
	tbnz	w0, #31, LBB0_25
; %bb.13:
	cbz	w24, LBB0_34
; %bb.14:
	mov	x0, x19
	bl	_ov5640_get_light_freq
	tbnz	w0, #31, LBB0_42
; %bb.15:
	mov	w8, #100
	mul	w9, w24, w8
	sdiv	w25, w9, w20
	cmp	w0, #60
	b.ne	LBB0_17
; %bb.16:
	mul	w8, w25, w8
	mov	w9, #34953
	movk	w9, #34952, lsl #16
	smull	x9, w8, w9
	lsr	x9, x9, #32
	add	w8, w9, w8
	asr	w9, w8, #6
	add	w25, w9, w8, lsr #31
LBB0_17:
	ldr	w0, [x19]
	cbz	w0, LBB0_26
; %bb.18:
	cbz	w25, LBB0_34
LBB0_19:
	ldr	w8, [sp, #12]
	ldr	w9, [x19, #4]
	cmp	w8, w9
	b.le	LBB0_29
; %bb.20:
	ldr	w9, [x19, #8]
	cmp	w8, w9
	b.ge	LBB0_29
; %bb.21:
	mul	w9, w22, w21
	mul	w9, w9, w24
	sdiv	w9, w9, w0
	ldr	w10, [x19, #12]
	mul	w9, w10, w9
	sdiv	w9, w9, w20
	add	x10, x19, #16
	mov	x20, x8
	b	LBB0_30
LBB0_22:
	mov	x20, x21
	b	LBB0_35
LBB0_23:
	mov	x20, x22
	b	LBB0_35
LBB0_24:
	mov	x20, x23
	b	LBB0_35
LBB0_25:
	mov	x20, x24
	b	LBB0_35
LBB0_26:
	mov	x0, x19
	bl	_ov5640_get_sysclk
	tbnz	w0, #31, LBB0_42
; %bb.27:
	cbz	w0, LBB0_34
; %bb.28:
	str	w0, [x19]
	cbnz	w25, LBB0_19
	b	LBB0_34
LBB0_29:
	mul	w8, w22, w21
	mul	w8, w8, w24
	add	x10, x19, #12
	sdiv	w9, w8, w0
LBB0_30:
	sub	w22, w23, #4
	ldr	w8, [x10]
	mul	w8, w8, w9
	sdiv	w8, w8, w20
	cmp	w8, w25, lsl #4
	b.ge	LBB0_32
; %bb.31:
	add	w9, w8, #15
	cmp	w8, #0
	csel	w9, w9, w8, lt
	asr	w9, w9, #4
	cmp	w9, #1
	csinc	w21, w9, wzr, gt
	sdiv	w8, w8, w21
	mov	w9, #16
	cmp	w8, #16
	csel	w1, w8, w9, gt
	b	LBB0_38
LBB0_32:
	sdiv	w9, w22, w25
	mul	w21, w9, w25
	cmp	w8, w21, lsl #4
	b.le	LBB0_36
; %bb.33:
	cbnz	w21, LBB0_37
LBB0_34:
Lloh9:
	adrp	x8, _EINVAL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_35:
	mov	x0, x20
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
LBB0_36:
	add	w9, w8, #15
	cmp	w8, #0
	csel	w9, w9, w8, lt
	asr	w9, w9, #4
	sdiv	w9, w9, w25
	mul	w21, w9, w25
	cbz	w21, LBB0_34
LBB0_37:
	sdiv	w1, w8, w21
LBB0_38:
	mov	x0, x19
	bl	_ov5640_set_gain
	mov	x20, x0
	cbnz	w0, LBB0_35
; %bb.39:
	cmp	w21, w22
	b.le	LBB0_41
; %bb.40:
	add	w1, w21, #4
	mov	x0, x19
	bl	_ov5640_set_vts
	tbnz	w0, #31, LBB0_42
LBB0_41:
	mov	x0, x19
	mov	x1, x21
	bl	_ov5640_set_exposure
LBB0_42:
	mov	x20, x0
	b	LBB0_35
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_OV5640_MODE_720P_1280_720,8,3  ; @OV5640_MODE_720P_1280_720
	.comm	_OV5640_MODE_1080P_1920_1080,8,3 ; @OV5640_MODE_1080P_1920_1080
	.comm	_OV5640_REG_AVG_READOUT,4,2     ; @OV5640_REG_AVG_READOUT
	.no_dead_strip	_ov5640_set_mode_exposure_calc
.subsections_via_symbols
