	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bh1770_detect
_bh1770_detect:                         ## @bh1770_detect
	.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
	movq	%rdi, %r15
	movq	24(%rdi), %r14
	movq	_BH1770_MANUFACT_ID@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_i2c_smbus_read_byte_data
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_1
## %bb.2:
	movq	_BH1770_PART_ID@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_i2c_smbus_read_byte_data
	movl	%eax, %r12d
	testl	%eax, %eax
	js	LBB0_10
## %bb.3:
	movl	%ebx, %eax
	movq	_BH1770_REV_MASK@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	andl	%r12d, %edx
	movq	_BH1770_REV_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shrq	%cl, %rdx
	movl	%r12d, %ecx
	movq	%rdx, 16(%r15)
	movq	_BH1770_COEF_SCALER@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	movl	%edx, (%r15)
	movl	$0, 4(%r15)
	movq	_BH1770_NEUTRAL_CF@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	movl	%edx, 12(%r15)
	movq	_BH1770_MANUFACT_ROHM@GOTPCREL(%rip), %rdx
	cmpq	%rax, (%rdx)
	jne	LBB0_6
## %bb.4:
	movq	_BH1770_PART_MASK@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	andl	%ecx, %edx
	movq	_BH1770_PART@GOTPCREL(%rip), %rsi
	cmpq	(%rsi), %rdx
	jne	LBB0_6
## %bb.5:
	movl	8(%r15), %edi
	leaq	L_.str(%rip), %rdx
	movl	$4, %esi
	callq	_snprintf
	xorl	%r12d, %r12d
	jmp	LBB0_11
LBB0_1:
	movl	%ebx, %r12d
	jmp	LBB0_10
LBB0_6:
	movq	_BH1770_MANUFACT_OSRAM@GOTPCREL(%rip), %rdx
	cmpq	%rax, (%rdx)
	jne	LBB0_9
## %bb.7:
	movq	_BH1770_PART_MASK@GOTPCREL(%rip), %rax
	andl	(%rax), %ecx
	movq	_BH1770_PART@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rcx
	jne	LBB0_9
## %bb.8:
	movl	8(%r15), %edi
	leaq	L_.str.1(%rip), %rdx
	movl	$4, %esi
	callq	_snprintf
	movabsq	$171798692659, %rax             ## imm = 0x2800000333
	movq	%rax, (%r15)
	xorl	%r12d, %r12d
	jmp	LBB0_11
LBB0_9:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
LBB0_10:
	leaq	L_.str.2(%rip), %rsi
	movq	%r14, %rdi
	callq	_dev_dbg
LBB0_11:
	movl	%r12d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_BH1770_MANUFACT_ID,4,2         ## @BH1770_MANUFACT_ID
	.comm	_BH1770_PART_ID,4,2             ## @BH1770_PART_ID
	.comm	_BH1770_REV_MASK,8,3            ## @BH1770_REV_MASK
	.comm	_BH1770_REV_SHIFT,8,3           ## @BH1770_REV_SHIFT
	.comm	_BH1770_COEF_SCALER,4,2         ## @BH1770_COEF_SCALER
	.comm	_BH1770_NEUTRAL_CF,4,2          ## @BH1770_NEUTRAL_CF
	.comm	_BH1770_MANUFACT_ROHM,8,3       ## @BH1770_MANUFACT_ROHM
	.comm	_BH1770_PART_MASK,8,3           ## @BH1770_PART_MASK
	.comm	_BH1770_PART,8,3                ## @BH1770_PART
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"BH1770GLC"

	.comm	_BH1770_MANUFACT_OSRAM,8,3      ## @BH1770_MANUFACT_OSRAM
L_.str.1:                               ## @.str.1
	.asciz	"SFH7770"

	.comm	_ENODEV,4,2                     ## @ENODEV
L_.str.2:                               ## @.str.2
	.asciz	"BH1770 or SFH7770 not found\n"

	.no_dead_strip	_bh1770_detect
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ; -- Begin function bh1770_detect
lCPI0_0:
	.long	819                             ; 0x333
	.long	40                              ; 0x28
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	2
_bh1770_detect:                         ; @bh1770_detect
	.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
	mov	x20, x0
	ldr	x19, [x0, #24]
Lloh0:
	adrp	x8, _BH1770_MANUFACT_ID@GOTPAGE
Lloh1:
	ldr	x8, [x8, _BH1770_MANUFACT_ID@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_i2c_smbus_read_byte_data
	mov	x21, x0
	tbnz	w0, #31, LBB0_10
; %bb.1:
Lloh3:
	adrp	x8, _BH1770_PART_ID@GOTPAGE
Lloh4:
	ldr	x8, [x8, _BH1770_PART_ID@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_i2c_smbus_read_byte_data
	tbnz	w0, #31, LBB0_8
; %bb.2:
	mov	w9, w21
	mov	w8, w0
Lloh6:
	adrp	x10, _BH1770_REV_MASK@GOTPAGE
Lloh7:
	ldr	x10, [x10, _BH1770_REV_MASK@GOTPAGEOFF]
Lloh8:
	ldr	x10, [x10]
	and	x10, x10, x8
Lloh9:
	adrp	x11, _BH1770_REV_SHIFT@GOTPAGE
Lloh10:
	ldr	x11, [x11, _BH1770_REV_SHIFT@GOTPAGEOFF]
Lloh11:
	ldr	x11, [x11]
	lsr	x10, x10, x11
Lloh12:
	adrp	x11, _BH1770_COEF_SCALER@GOTPAGE
Lloh13:
	ldr	x11, [x11, _BH1770_COEF_SCALER@GOTPAGEOFF]
	str	x10, [x20, #16]
Lloh14:
	ldr	w10, [x11]
	stp	w10, wzr, [x20]
Lloh15:
	adrp	x10, _BH1770_NEUTRAL_CF@GOTPAGE
Lloh16:
	ldr	x10, [x10, _BH1770_NEUTRAL_CF@GOTPAGEOFF]
Lloh17:
	ldr	w10, [x10]
	str	w10, [x20, #12]
Lloh18:
	adrp	x10, _BH1770_MANUFACT_ROHM@GOTPAGE
Lloh19:
	ldr	x10, [x10, _BH1770_MANUFACT_ROHM@GOTPAGEOFF]
Lloh20:
	ldr	x10, [x10]
	cmp	x10, x9
	b.ne	LBB0_5
; %bb.3:
Lloh21:
	adrp	x10, _BH1770_PART_MASK@GOTPAGE
Lloh22:
	ldr	x10, [x10, _BH1770_PART_MASK@GOTPAGEOFF]
Lloh23:
	ldr	x10, [x10]
	and	x10, x10, x8
Lloh24:
	adrp	x11, _BH1770_PART@GOTPAGE
Lloh25:
	ldr	x11, [x11, _BH1770_PART@GOTPAGEOFF]
Lloh26:
	ldr	x11, [x11]
	cmp	x10, x11
	b.ne	LBB0_5
; %bb.4:
	ldr	w0, [x20, #8]
Lloh27:
	adrp	x2, l_.str@PAGE
Lloh28:
	add	x2, x2, l_.str@PAGEOFF
	mov	w1, #4
	bl	_snprintf
	mov	w21, #0
	b	LBB0_11
LBB0_5:
Lloh29:
	adrp	x10, _BH1770_MANUFACT_OSRAM@GOTPAGE
Lloh30:
	ldr	x10, [x10, _BH1770_MANUFACT_OSRAM@GOTPAGEOFF]
Lloh31:
	ldr	x10, [x10]
	cmp	x10, x9
	b.ne	LBB0_9
; %bb.6:
Lloh32:
	adrp	x9, _BH1770_PART_MASK@GOTPAGE
Lloh33:
	ldr	x9, [x9, _BH1770_PART_MASK@GOTPAGEOFF]
Lloh34:
	ldr	x9, [x9]
	and	x8, x9, x8
Lloh35:
	adrp	x9, _BH1770_PART@GOTPAGE
Lloh36:
	ldr	x9, [x9, _BH1770_PART@GOTPAGEOFF]
Lloh37:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_9
; %bb.7:
	ldr	w0, [x20, #8]
Lloh38:
	adrp	x2, l_.str.1@PAGE
Lloh39:
	add	x2, x2, l_.str.1@PAGEOFF
	mov	w1, #4
	bl	_snprintf
	mov	w21, #0
Lloh40:
	adrp	x8, lCPI0_0@PAGE
Lloh41:
	ldr	d0, [x8, lCPI0_0@PAGEOFF]
	str	d0, [x20]
	b	LBB0_11
LBB0_8:
	mov	x21, x0
	b	LBB0_10
LBB0_9:
Lloh42:
	adrp	x8, _ENODEV@GOTPAGE
Lloh43:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh44:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_10:
Lloh45:
	adrp	x1, l_.str.2@PAGE
Lloh46:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x19
	bl	_dev_dbg
LBB0_11:
	mov	x0, x21
	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 AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdr	Lloh40, Lloh41
	.loh AdrpAdd	Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh42, Lloh43, Lloh44
	.loh AdrpAdd	Lloh45, Lloh46
	.cfi_endproc
                                        ; -- End function
	.comm	_BH1770_MANUFACT_ID,4,2         ; @BH1770_MANUFACT_ID
	.comm	_BH1770_PART_ID,4,2             ; @BH1770_PART_ID
	.comm	_BH1770_REV_MASK,8,3            ; @BH1770_REV_MASK
	.comm	_BH1770_REV_SHIFT,8,3           ; @BH1770_REV_SHIFT
	.comm	_BH1770_COEF_SCALER,4,2         ; @BH1770_COEF_SCALER
	.comm	_BH1770_NEUTRAL_CF,4,2          ; @BH1770_NEUTRAL_CF
	.comm	_BH1770_MANUFACT_ROHM,8,3       ; @BH1770_MANUFACT_ROHM
	.comm	_BH1770_PART_MASK,8,3           ; @BH1770_PART_MASK
	.comm	_BH1770_PART,8,3                ; @BH1770_PART
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"BH1770GLC"

	.comm	_BH1770_MANUFACT_OSRAM,8,3      ; @BH1770_MANUFACT_OSRAM
l_.str.1:                               ; @.str.1
	.asciz	"SFH7770"

	.comm	_ENODEV,4,2                     ; @ENODEV
l_.str.2:                               ; @.str.2
	.asciz	"BH1770 or SFH7770 not found\n"

	.no_dead_strip	_bh1770_detect
.subsections_via_symbols
