	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mgsl_add_device
_mgsl_add_device:                       ## @mgsl_add_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	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %rbx
	movq	$0, 56(%rdi)
	movq	_mgsl_device_count@GOTPCREL(%rip), %r14
	movl	(%r14), %edx
	movl	%edx, (%rdi)
	movl	36(%rdi), %edi
	leaq	L_.str(%rip), %rsi
	callq	_sprintf
	movslq	(%rbx), %rax
	movq	_MAX_TOTAL_DEVICES@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jge	LBB0_10
## %bb.1:
	movq	_maxframe@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	LBB0_3
## %bb.2:
	movl	%ecx, 4(%rbx)
LBB0_3:
	movq	_txdmabufs@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx,%rax,4), %ecx
	testl	%ecx, %ecx
	je	LBB0_5
## %bb.4:
	cmpl	$2, %ecx
	movl	$1, %edx
	cmovgel	%ecx, %edx
	movl	%edx, 8(%rbx)
LBB0_5:
	movq	_txholdbufs@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx,%rax,4), %eax
	testl	%eax, %eax
	je	LBB0_10
## %bb.6:
	movl	%eax, 12(%rbx)
	jle	LBB0_7
## %bb.8:
	movq	_MAX_TX_HOLDING_BUFFERS@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	cmpl	%ecx, %eax
	jg	LBB0_9
	jmp	LBB0_10
LBB0_7:
	movl	$1, %ecx
LBB0_9:
	movl	%ecx, 12(%rbx)
LBB0_10:
	incl	(%r14)
	movq	_mgsl_device_list@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	testq	%rcx, %rcx
	je	LBB0_13
	.p2align	4, 0x90
LBB0_11:                                ## =>This Inner Loop Header: Depth=1
	movq	%rcx, %rax
	movq	56(%rcx), %rcx
	testq	%rcx, %rcx
	jne	LBB0_11
## %bb.12:
	addq	$56, %rax
LBB0_13:
	movq	%rbx, (%rax)
	movl	4(%rbx), %r10d
	movl	$4096, %eax                     ## imm = 0x1000
	cmpl	$4096, %r10d                    ## imm = 0x1000
	jl	LBB0_15
## %bb.14:
	movl	$65535, %eax                    ## imm = 0xFFFF
	cmpl	$65536, %r10d                   ## imm = 0x10000
	jb	LBB0_16
LBB0_15:
	movl	%eax, 4(%rbx)
	movl	%eax, %r10d
LBB0_16:
	movq	16(%rbx), %rax
	movq	_MGSL_BUS_TYPE_PCI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_18
## %bb.17:
	movl	48(%rbx), %esi
	incl	%esi
	movl	36(%rbx), %edx
	movl	28(%rbx), %r8d
	movl	32(%rbx), %ecx
	movl	44(%rbx), %r9d
	movl	40(%rbx), %ebx
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r10
	pushq	%rbx
	callq	_printk
	addq	$16, %rsp
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_18:
	movl	36(%rbx), %esi
	movl	32(%rbx), %edx
	movl	24(%rbx), %r8d
	movl	28(%rbx), %ecx
	leaq	L_.str.2(%rip), %rdi
	movl	%r10d, %r9d
	xorl	%eax, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_printk                         ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_mgsl_device_count,4,2          ## @mgsl_device_count
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ttySL%d"

	.comm	_MAX_TOTAL_DEVICES,4,2          ## @MAX_TOTAL_DEVICES
	.comm	_maxframe,8,3                   ## @maxframe
	.comm	_txdmabufs,8,3                  ## @txdmabufs
	.comm	_txholdbufs,8,3                 ## @txholdbufs
	.comm	_MAX_TX_HOLDING_BUFFERS,4,2     ## @MAX_TX_HOLDING_BUFFERS
	.comm	_mgsl_device_list,8,3           ## @mgsl_device_list
	.comm	_MGSL_BUS_TYPE_PCI,8,3          ## @MGSL_BUS_TYPE_PCI
L_.str.1:                               ## @.str.1
	.asciz	"SyncLink PCI v%d %s: IO=%04X IRQ=%d Mem=%08X,%08X MaxFrameSize=%u\n"

L_.str.2:                               ## @.str.2
	.asciz	"SyncLink ISA %s: IO=%04X IRQ=%d DMA=%d MaxFrameSize=%u\n"

	.no_dead_strip	_mgsl_add_device
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mgsl_add_device
_mgsl_add_device:                       ; @mgsl_add_device
	.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	x19, x0
	str	xzr, [x0, #56]
Lloh0:
	adrp	x20, _mgsl_device_count@GOTPAGE
Lloh1:
	ldr	x20, [x20, _mgsl_device_count@GOTPAGEOFF]
	ldr	w2, [x20]
	str	w2, [x0]
	ldr	w0, [x0, #36]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	bl	_sprintf
	ldrsw	x8, [x19]
Lloh4:
	adrp	x9, _MAX_TOTAL_DEVICES@GOTPAGE
Lloh5:
	ldr	x9, [x9, _MAX_TOTAL_DEVICES@GOTPAGEOFF]
Lloh6:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ge	LBB0_10
; %bb.1:
Lloh7:
	adrp	x9, _maxframe@GOTPAGE
Lloh8:
	ldr	x9, [x9, _maxframe@GOTPAGEOFF]
Lloh9:
	ldr	x9, [x9]
	ldr	w9, [x9, x8, lsl #2]
	cbz	w9, LBB0_3
; %bb.2:
	str	w9, [x19, #4]
LBB0_3:
Lloh10:
	adrp	x9, _txdmabufs@GOTPAGE
Lloh11:
	ldr	x9, [x9, _txdmabufs@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
	ldr	w9, [x9, x8, lsl #2]
	cbz	w9, LBB0_5
; %bb.4:
	cmp	w9, #1
	csinc	w9, w9, wzr, gt
	str	w9, [x19, #8]
LBB0_5:
Lloh13:
	adrp	x9, _txholdbufs@GOTPAGE
Lloh14:
	ldr	x9, [x9, _txholdbufs@GOTPAGEOFF]
Lloh15:
	ldr	x9, [x9]
	ldr	w8, [x9, x8, lsl #2]
	cbz	w8, LBB0_10
; %bb.6:
	str	w8, [x19, #12]
	cmp	w8, #1
	b.lt	LBB0_8
; %bb.7:
Lloh16:
	adrp	x9, _MAX_TX_HOLDING_BUFFERS@GOTPAGE
Lloh17:
	ldr	x9, [x9, _MAX_TX_HOLDING_BUFFERS@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x9]
	cmp	w8, w9
	b.gt	LBB0_9
	b	LBB0_10
LBB0_8:
	mov	w9, #1
LBB0_9:
	str	w9, [x19, #12]
LBB0_10:
	ldr	w8, [x20]
	add	w8, w8, #1
	str	w8, [x20]
Lloh19:
	adrp	x8, _mgsl_device_list@GOTPAGE
Lloh20:
	ldr	x8, [x8, _mgsl_device_list@GOTPAGEOFF]
	ldr	x9, [x8]
	cbz	x9, LBB0_13
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	mov	x8, x9
	ldr	x9, [x9, #56]
	cbnz	x9, LBB0_11
; %bb.12:
	add	x8, x8, #56
LBB0_13:
	str	x19, [x8]
	ldr	w5, [x19, #4]
	cmp	w5, #1, lsl #12                 ; =4096
	b.ge	LBB0_15
; %bb.14:
	mov	w5, #4096
	b	LBB0_17
LBB0_15:
	cmp	w5, #16, lsl #12                ; =65536
	b.lo	LBB0_18
; %bb.16:
	mov	w5, #65535
LBB0_17:
	str	w5, [x19, #4]
LBB0_18:
	ldr	x8, [x19, #16]
Lloh21:
	adrp	x9, _MGSL_BUS_TYPE_PCI@GOTPAGE
Lloh22:
	ldr	x9, [x9, _MGSL_BUS_TYPE_PCI@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_20
; %bb.19:
	ldp	w8, w9, [x19, #44]
	add	w1, w9, #1
	ldp	w4, w3, [x19, #28]
	ldp	w2, w9, [x19, #36]
	stp	x9, x5, [sp]
Lloh24:
	adrp	x0, l_.str.1@PAGE
Lloh25:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x5, x8
	bl	_printk
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
LBB0_20:
	ldp	w2, w1, [x19, #32]
	ldp	w4, w3, [x19, #24]
Lloh26:
	adrp	x0, l_.str.2@PAGE
Lloh27:
	add	x0, x0, l_.str.2@PAGEOFF
                                        ; kill: def $w5 killed $w5 killed $x5
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	b	_printk
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_mgsl_device_count,4,2          ; @mgsl_device_count
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ttySL%d"

	.comm	_MAX_TOTAL_DEVICES,4,2          ; @MAX_TOTAL_DEVICES
	.comm	_maxframe,8,3                   ; @maxframe
	.comm	_txdmabufs,8,3                  ; @txdmabufs
	.comm	_txholdbufs,8,3                 ; @txholdbufs
	.comm	_MAX_TX_HOLDING_BUFFERS,4,2     ; @MAX_TX_HOLDING_BUFFERS
	.comm	_mgsl_device_list,8,3           ; @mgsl_device_list
	.comm	_MGSL_BUS_TYPE_PCI,8,3          ; @MGSL_BUS_TYPE_PCI
l_.str.1:                               ; @.str.1
	.asciz	"SyncLink PCI v%d %s: IO=%04X IRQ=%d Mem=%08X,%08X MaxFrameSize=%u\n"

l_.str.2:                               ; @.str.2
	.asciz	"SyncLink ISA %s: IO=%04X IRQ=%d DMA=%d MaxFrameSize=%u\n"

	.no_dead_strip	_mgsl_add_device
.subsections_via_symbols
