	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function kempld_detect_device
_kempld_detect_device:                  ## @kempld_detect_device
	.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
	leaq	20(%rdi), %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movl	24(%r15), %edi
	callq	_ioread8
	movl	%eax, %ebx
	cmpl	$255, %eax
	jne	LBB0_3
## %bb.1:
	movl	28(%r15), %edi
	callq	_ioread8
	cmpl	$255, %eax
	jne	LBB0_3
## %bb.2:
	movq	%r14, %rdi
	callq	_mutex_unlock
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_10
LBB0_3:
	movq	_KEMPLD_MUTEX_KEY@GOTPCREL(%rip), %r12
	movl	(%r12), %edi
	testl	%ebx, %edi
	jne	LBB0_5
## %bb.4:
	movl	24(%r15), %esi
	callq	_iowrite8
	movl	(%r12), %edi
	movl	24(%r15), %esi
	callq	_iowrite8
LBB0_5:
	movq	%r14, %rdi
	callq	_mutex_unlock
	movq	%r15, %rdi
	callq	_kempld_get_info
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_10
## %bb.6:
	movq	(%r15), %rbx
	movl	16(%r15), %r14d
	movq	%r15, %rdi
	callq	_kempld_get_type_string
	movl	8(%r15), %r9d
	movl	12(%r15), %r8d
	leaq	L_.str(%rip), %rsi
	movq	%rbx, %rdi
	movl	%r14d, %edx
	movl	%eax, %ecx
	callq	_dev_info
	movq	(%r15), %rdi
	movq	_pld_attr_group@GOTPCREL(%rip), %rsi
	callq	_sysfs_create_group
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_10
## %bb.7:
	movq	%r15, %rdi
	callq	_kempld_register_cells
	testl	%eax, %eax
	je	LBB0_8
## %bb.9:
	movl	%eax, %ebx
	movq	(%r15), %rdi
	movq	_pld_attr_group@GOTPCREL(%rip), %rsi
	callq	_sysfs_remove_group
	jmp	LBB0_10
LBB0_8:
	xorl	%ebx, %ebx
LBB0_10:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_KEMPLD_MUTEX_KEY,4,2           ## @KEMPLD_MUTEX_KEY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Found Kontron PLD - %s (%s), spec %d.%d\n"

	.comm	_pld_attr_group,4,2             ## @pld_attr_group
	.no_dead_strip	_kempld_detect_device
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function kempld_detect_device
_kempld_detect_device:                  ; @kempld_detect_device
	.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	x19, x0
	add	x20, x0, #20
	mov	x0, x20
	bl	_mutex_lock
	ldr	w0, [x19, #24]
	bl	_ioread8
	mov	x21, x0
	cmp	w0, #255
	b.ne	LBB0_3
; %bb.1:
	ldr	w0, [x19, #28]
	bl	_ioread8
	cmp	w0, #255
	b.ne	LBB0_3
; %bb.2:
	mov	x0, x20
	bl	_mutex_unlock
Lloh0:
	adrp	x8, _ENODEV@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_9
LBB0_3:
Lloh3:
	adrp	x22, _KEMPLD_MUTEX_KEY@GOTPAGE
Lloh4:
	ldr	x22, [x22, _KEMPLD_MUTEX_KEY@GOTPAGEOFF]
	ldr	w0, [x22]
	tst	w0, w21
	b.ne	LBB0_5
; %bb.4:
	ldr	w1, [x19, #24]
	bl	_iowrite8
	ldr	w0, [x22]
	ldr	w1, [x19, #24]
	bl	_iowrite8
LBB0_5:
	mov	x0, x20
	bl	_mutex_unlock
	mov	x0, x19
	bl	_kempld_get_info
	mov	x20, x0
	cbnz	w0, LBB0_9
; %bb.6:
	ldr	x20, [x19]
	ldr	w21, [x19, #16]
	mov	x0, x19
	bl	_kempld_get_type_string
	mov	x3, x0
	ldp	w5, w4, [x19, #8]
Lloh5:
	adrp	x1, l_.str@PAGE
Lloh6:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	mov	x2, x21
	bl	_dev_info
	ldr	x0, [x19]
Lloh7:
	adrp	x1, _pld_attr_group@GOTPAGE
Lloh8:
	ldr	x1, [x1, _pld_attr_group@GOTPAGEOFF]
	bl	_sysfs_create_group
	mov	x20, x0
	cbnz	w0, LBB0_9
; %bb.7:
	mov	x0, x19
	bl	_kempld_register_cells
	mov	x20, x0
	cbz	w0, LBB0_9
; %bb.8:
	ldr	x0, [x19]
Lloh9:
	adrp	x1, _pld_attr_group@GOTPAGE
Lloh10:
	ldr	x1, [x1, _pld_attr_group@GOTPAGEOFF]
	bl	_sysfs_remove_group
LBB0_9:
	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 AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_KEMPLD_MUTEX_KEY,4,2           ; @KEMPLD_MUTEX_KEY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Found Kontron PLD - %s (%s), spec %d.%d\n"

	.comm	_pld_attr_group,4,2             ; @pld_attr_group
	.no_dead_strip	_kempld_detect_device
.subsections_via_symbols
