	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mt9m111_set_gain
_mt9m111_set_gain:                      ## @mt9m111_set_gain
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movl	%esi, %ebx
	movq	%rdi, %r14
	movq	$0, -24(%rbp)
	movq	_MT9M111_PAGE_MAP@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-24(%rbp), %rdx
	movl	$2, %ecx
	callq	_m5602_write_sensor
	testl	%eax, %eax
	js	LBB0_14
## %bb.1:
	movq	_INITIAL_MAX_GAIN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	leal	(,%rax,8), %ecx
	cmpl	%ebx, %ecx
	jle	LBB0_2
## %bb.3:
	leal	(,%rax,4), %edx
	cmpl	%ebx, %edx
	jle	LBB0_4
## %bb.10:
	leal	(%rax,%rax), %ecx
	cmpl	%ebx, %ecx
	jg	LBB0_6
## %bb.11:
	leal	3(%rbx), %eax
	testl	%ebx, %ebx
	cmovnsl	%ebx, %eax
	sarl	$2, %eax
	orl	$768, %eax                      ## imm = 0x300
	jmp	LBB0_12
LBB0_2:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_14
LBB0_4:
	addl	$-8, %ecx
	cmpl	%ebx, %ecx
	jle	LBB0_5
## %bb.9:
	movl	%ebx, %eax
	shll	$9, %eax
	movl	%ebx, %ecx
	shll	$8, %ecx
	leal	7(%rbx), %edx
	testl	%ebx, %ebx
	cmovnsl	%ebx, %edx
	sarl	$3, %edx
	orl	%eax, %ecx
	orl	%edx, %ecx
	orl	$1024, %ecx                     ## imm = 0x400
	movl	%ecx, %ebx
	jmp	LBB0_13
LBB0_5:
	leal	(%rax,%rax), %ecx
LBB0_6:
	cmpl	%ebx, %eax
	jg	LBB0_13
## %bb.7:
	cmpl	%ebx, %ecx
	jle	LBB0_13
## %bb.8:
	movl	%ebx, %eax
	shrl	$31, %eax
	addl	%ebx, %eax
	sarl	%eax
	orl	$256, %eax                      ## imm = 0x100
LBB0_12:
	movl	%eax, %ebx
LBB0_13:
	movzbl	%bl, %r8d
	movl	%r8d, -20(%rbp)
	movzbl	%bh, %eax
	movl	%eax, -24(%rbp)
	movq	_D_CONF@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	leaq	L_.str(%rip), %rdx
	movq	%r14, %rdi
	movl	%ebx, %ecx
	movl	%eax, %r9d
	callq	_gspca_dbg
	movq	_MT9M111_SC_GLOBAL_GAIN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-24(%rbp), %rdx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	_m5602_write_sensor
LBB0_14:
	addq	$16, %rsp
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MT9M111_PAGE_MAP,4,2           ## @MT9M111_PAGE_MAP
	.comm	_INITIAL_MAX_GAIN,4,2           ## @INITIAL_MAX_GAIN
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_D_CONF,4,2                     ## @D_CONF
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"tmp=%d, data[1]=%d, data[0]=%d\n"

	.comm	_MT9M111_SC_GLOBAL_GAIN,4,2     ## @MT9M111_SC_GLOBAL_GAIN
	.no_dead_strip	_mt9m111_set_gain
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mt9m111_set_gain
_mt9m111_set_gain:                      ; @mt9m111_set_gain
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x20, x1
	mov	x19, x0
	str	xzr, [sp, #8]
Lloh0:
	adrp	x8, _MT9M111_PAGE_MAP@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MT9M111_PAGE_MAP@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	add	x2, sp, #8
	mov	w3, #2
	bl	_m5602_write_sensor
	tbnz	w0, #31, LBB0_11
; %bb.1:
Lloh3:
	adrp	x8, _INITIAL_MAX_GAIN@GOTPAGE
Lloh4:
	ldr	x8, [x8, _INITIAL_MAX_GAIN@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	lsl	w9, w8, #3
	cmp	w9, w20
	b.le	LBB0_5
; %bb.2:
	cmp	w20, w8, lsl #2
	b.ge	LBB0_6
; %bb.3:
	lsl	w9, w8, #1
	cmp	w9, w20
	b.gt	LBB0_9
; %bb.4:
	add	w8, w20, #3
	cmp	w20, #0
	csel	w8, w8, w20, lt
	asr	w8, w8, #2
	orr	w3, w8, #0x300
	b	LBB0_10
LBB0_5:
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_11
LBB0_6:
	sub	w9, w9, #8
	cmp	w9, w20
	b.le	LBB0_8
; %bb.7:
	lsl	w8, w20, #8
	add	w9, w20, #7
	cmp	w20, #0
	csel	w9, w9, w20, lt
	orr	w8, w8, w20, lsl #9
	orr	w8, w8, w9, asr #3
	orr	w3, w8, #0x400
	b	LBB0_10
LBB0_8:
	lsl	w9, w8, #1
LBB0_9:
	cmp	w20, #0
	cinc	w10, w20, lt
	asr	w10, w10, #1
	orr	w10, w10, #0x100
	cmp	w8, w20
	ccmp	w9, w20, #4, le
	csel	w3, w20, w10, le
LBB0_10:
	and	w4, w3, #0xff
	ubfx	w5, w3, #8, #8
	stp	w5, w4, [sp, #8]
Lloh9:
	adrp	x8, _D_CONF@GOTPAGE
Lloh10:
	ldr	x8, [x8, _D_CONF@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
Lloh12:
	adrp	x2, l_.str@PAGE
Lloh13:
	add	x2, x2, l_.str@PAGEOFF
	mov	x0, x19
	bl	_gspca_dbg
Lloh14:
	adrp	x8, _MT9M111_SC_GLOBAL_GAIN@GOTPAGE
Lloh15:
	ldr	x8, [x8, _MT9M111_SC_GLOBAL_GAIN@GOTPAGEOFF]
Lloh16:
	ldr	w1, [x8]
	add	x2, sp, #8
	mov	x0, x19
	mov	w3, #2
	bl	_m5602_write_sensor
LBB0_11:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_MT9M111_PAGE_MAP,4,2           ; @MT9M111_PAGE_MAP
	.comm	_INITIAL_MAX_GAIN,4,2           ; @INITIAL_MAX_GAIN
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_D_CONF,4,2                     ; @D_CONF
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"tmp=%d, data[1]=%d, data[0]=%d\n"

	.comm	_MT9M111_SC_GLOBAL_GAIN,4,2     ; @MT9M111_SC_GLOBAL_GAIN
	.no_dead_strip	_mt9m111_set_gain
.subsections_via_symbols
