	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function surface3_button_device_create
_surface3_button_device_create:         ## @surface3_button_device_create
	.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
	movl	%edx, %r12d
	movq	%rsi, %rbx
	movq	_MAX_NBUTTONS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	shll	$5, %esi
	orl	$16, %esi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_devm_kzalloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	cmpq	$0, 8(%rbx)
	je	LBB0_9
## %bb.3:
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	addq	$16, %r14
	xorl	%r15d, %r15d
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_4 Depth=1
	cmpq	$0, 40(%rbx)
	leaq	32(%rbx), %rbx
	je	LBB0_8
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	%r12d, (%rbx)
	jne	LBB0_7
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	28(%rbx), %esi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_surface3_button_lookup_gpio
	movl	%eax, %r13d
	movl	%eax, %edi
	callq	_gpio_is_valid
	testl	%eax, %eax
	je	LBB0_7
## %bb.6:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	24(%rbx), %eax
	movslq	%r15d, %r15
	movq	%r15, %rcx
	shlq	$5, %rcx
	movl	%eax, 24(%r14,%rcx)
	movl	20(%rbx), %eax
	movl	%eax, 20(%r14,%rcx)
	movl	%r13d, (%r14,%rcx)
	movl	16(%rbx), %eax
	movl	%eax, 16(%r14,%rcx)
	movq	8(%rbx), %rax
	movq	%rax, 8(%r14,%rcx)
	movl	4(%rbx), %eax
	movl	%eax, 4(%r14,%rcx)
	incl	%r15d
	jmp	LBB0_7
LBB0_8:
	testl	%r15d, %r15d
	je	LBB0_9
## %bb.10:
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movq	%r14, 8(%rax)
	movq	%rax, %r14
	movl	%r15d, (%rax)
	movl	%r12d, 4(%rax)
	movq	_PLATFORM_DEVID_AUTO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str(%rip), %rdi
	callq	_platform_device_alloc
	testq	%rax, %rax
	je	LBB0_11
## %bb.12:
	movq	%rax, %r12
	movq	%rax, %rdi
	movq	%r14, %rsi
	movl	$16, %edx
	callq	_platform_device_add_data
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.13:
	movq	%r12, %rdi
	callq	_platform_device_add
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_17
LBB0_14:
	movq	%r12, %rdi
	callq	_platform_device_put
	jmp	LBB0_15
LBB0_9:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	-48(%rbp), %r14                 ## 8-byte Reload
LBB0_15:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	%r14, %rsi
	callq	_devm_kfree
	jmp	LBB0_16
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_16:
	movl	%ebx, %edi
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_ERR_PTR                        ## TAILCALL
LBB0_11:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_15
LBB0_17:
	movq	%r12, %rax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MAX_NBUTTONS,4,2               ## @MAX_NBUTTONS
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_ENODEV,4,2                     ## @ENODEV
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"gpio-keys"

	.comm	_PLATFORM_DEVID_AUTO,4,2        ## @PLATFORM_DEVID_AUTO
	.no_dead_strip	_surface3_button_device_create
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function surface3_button_device_create
_surface3_button_device_create:         ; @surface3_button_device_create
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x21, x2
	mov	x22, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _MAX_NBUTTONS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MAX_NBUTTONS@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	mov	w1, #16
	bfi	w1, w8, #5, #27
Lloh3:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
	bl	_devm_kzalloc
	cbz	x0, LBB0_15
; %bb.1:
	mov	x20, x0
	ldr	x8, [x22, #8]
	cbz	x8, LBB0_12
; %bb.2:
	mov	w23, #0
	add	x24, x20, #16
	add	x25, x22, #24
	b	LBB0_4
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x25, #16]
	add	x25, x25, #32
	cbz	x8, LBB0_7
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldur	w8, [x25, #-24]
	cmp	w8, w21
	b.ne	LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w1, [x25, #4]
	mov	x0, x19
	bl	_surface3_button_lookup_gpio
	mov	x22, x0
	bl	_gpio_is_valid
	cbz	w0, LBB0_3
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [x25]
	sxtw	x9, w23
	add	x9, x24, x9, lsl #5
	str	w8, [x9, #24]
	str	w22, [x9]
	ldur	d0, [x25, #-8]
	str	d0, [x9, #16]
	ldur	x8, [x25, #-16]
	str	x8, [x9, #8]
	ldur	w8, [x25, #-20]
	str	w8, [x9, #4]
	add	w23, w23, #1
	b	LBB0_3
LBB0_7:
	cbz	w23, LBB0_12
; %bb.8:
	str	x24, [x20, #8]
	stp	w23, w21, [x20]
Lloh6:
	adrp	x8, _PLATFORM_DEVID_AUTO@GOTPAGE
Lloh7:
	ldr	x8, [x8, _PLATFORM_DEVID_AUTO@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
Lloh9:
	adrp	x0, l_.str@PAGE
Lloh10:
	add	x0, x0, l_.str@PAGEOFF
	bl	_platform_device_alloc
	cbz	x0, LBB0_17
; %bb.9:
	mov	x22, x0
	mov	x1, x20
	mov	w2, #16
	bl	_platform_device_add_data
	mov	x21, x0
	cbnz	w0, LBB0_11
; %bb.10:
	mov	x0, x22
	bl	_platform_device_add
	mov	x21, x0
	cbz	w0, LBB0_18
LBB0_11:
	mov	x0, x22
	bl	_platform_device_put
	b	LBB0_14
LBB0_12:
Lloh11:
	adrp	x8, _ENODEV@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_13:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_14:
	mov	x0, x19
	mov	x1, x20
	bl	_devm_kfree
	b	LBB0_16
LBB0_15:
Lloh13:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh14:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_16:
	mov	x0, x21
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	b	_ERR_PTR
LBB0_17:
Lloh16:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh17:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_13
LBB0_18:
	mov	x0, x22
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_MAX_NBUTTONS,4,2               ; @MAX_NBUTTONS
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_ENODEV,4,2                     ; @ENODEV
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"gpio-keys"

	.comm	_PLATFORM_DEVID_AUTO,4,2        ; @PLATFORM_DEVID_AUTO
	.no_dead_strip	_surface3_button_device_create
.subsections_via_symbols
