	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vl6180_set_als_gain
_vl6180_set_als_gain:                   ## @vl6180_set_als_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	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
                                        ## kill: def $edx killed $edx def $rdx
                                        ## kill: def $esi killed $esi def $rsi
	leal	-41(%rsi), %eax
	cmpl	$-41, %eax
	jbe	LBB0_1
## %bb.2:
	imull	$1000000, %esi, %eax            ## imm = 0xF4240
	leal	(%rax,%rdx), %ecx
	addl	$-40001000, %ecx                ## imm = 0xFD9DA218
	cmpl	$-40000001, %ecx                ## imm = 0xFD9DA5FF
	ja	LBB0_3
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_8
LBB0_3:
	movq	%rdi, %r14
	addl	%edx, %eax
	movl	%eax, %eax
	imulq	$274877907, %rax, %rbx          ## imm = 0x10624DD3
	shrq	$38, %rbx
	movq	_vl6180_als_gain_tab@GOTPCREL(%rip), %r12
	movq	(%r12), %r15
	movq	%r15, %rdi
	callq	_ARRAY_SIZE
	movl	%ebx, %edi
	movq	%r15, %rsi
	movl	%eax, %edx
	callq	_find_closest
	movl	%eax, %r15d
	movq	%r14, %rdi
	callq	_mutex_lock
	movq	%r14, %rdi
	movl	$1, %esi
	callq	_vl6180_hold
	testl	%eax, %eax
	js	LBB0_4
## %bb.5:
	movl	8(%r14), %edi
	movq	_VL6180_ALS_GAIN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_vl6180_als_gain_tab_bits@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movslq	%r15d, %r15
	movl	(%rax,%r15,4), %edx
	callq	_vl6180_write_byte
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_7
## %bb.6:
	movq	(%r12), %rax
	movl	(%rax,%r15,4), %eax
	movl	%eax, 4(%r14)
	jmp	LBB0_7
LBB0_4:
	movl	%eax, %ebx
LBB0_7:
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_vl6180_hold
	movq	%r14, %rdi
	callq	_mutex_unlock
LBB0_8:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_vl6180_als_gain_tab,8,3        ## @vl6180_als_gain_tab
	.comm	_VL6180_ALS_GAIN,4,2            ## @VL6180_ALS_GAIN
	.comm	_vl6180_als_gain_tab_bits,8,3   ## @vl6180_als_gain_tab_bits
	.no_dead_strip	_vl6180_set_als_gain
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vl6180_set_als_gain
_vl6180_set_als_gain:                   ; @vl6180_set_als_gain
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	sub	w8, w1, #41
	cmn	w8, #41
	b.ls	LBB0_2
; %bb.1:
	mov	w8, #16960
	movk	w8, #15, lsl #16
	madd	w8, w1, w8, w2
	mov	w9, #41496
	movk	w9, #64925, lsl #16
	add	w10, w9, #1000
	add	w9, w8, w9
	cmp	w9, w10
	b.hs	LBB0_3
LBB0_2:
Lloh0:
	adrp	x8, _EINVAL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_8
LBB0_3:
	mov	x19, x0
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	umull	x8, w8, w9
	lsr	x20, x8, #38
Lloh3:
	adrp	x22, _vl6180_als_gain_tab@GOTPAGE
Lloh4:
	ldr	x22, [x22, _vl6180_als_gain_tab@GOTPAGEOFF]
	ldr	x21, [x22]
	mov	x0, x21
	bl	_ARRAY_SIZE
	mov	x2, x0
	mov	x0, x20
	mov	x1, x21
	bl	_find_closest
	mov	x21, x0
	mov	x0, x19
	bl	_mutex_lock
	mov	x0, x19
	mov	w1, #1
	bl	_vl6180_hold
	tbnz	w0, #31, LBB0_6
; %bb.4:
	ldr	w0, [x19, #8]
Lloh5:
	adrp	x8, _VL6180_ALS_GAIN@GOTPAGE
Lloh6:
	ldr	x8, [x8, _VL6180_ALS_GAIN@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
Lloh8:
	adrp	x8, _vl6180_als_gain_tab_bits@GOTPAGE
Lloh9:
	ldr	x8, [x8, _vl6180_als_gain_tab_bits@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
	ldr	w2, [x8, w21, sxtw #2]
	bl	_vl6180_write_byte
	mov	x20, x0
	tbnz	w0, #31, LBB0_7
; %bb.5:
	sxtw	x8, w21
	ldr	x9, [x22]
	ldr	w8, [x9, x8, lsl #2]
	str	w8, [x19, #4]
	b	LBB0_7
LBB0_6:
	mov	x20, x0
LBB0_7:
	mov	x0, x19
	mov	w1, #0
	bl	_vl6180_hold
	mov	x0, x19
	bl	_mutex_unlock
LBB0_8:
	mov	x0, x20
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_vl6180_als_gain_tab,8,3        ; @vl6180_als_gain_tab
	.comm	_VL6180_ALS_GAIN,4,2            ; @VL6180_ALS_GAIN
	.comm	_vl6180_als_gain_tab_bits,8,3   ; @vl6180_als_gain_tab_bits
	.no_dead_strip	_vl6180_set_als_gain
.subsections_via_symbols
