	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ngfrm_allocate_CTX
_ngfrm_allocate_CTX:                    ## @ngfrm_allocate_CTX
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	$-1, %ebx
	cmpl	$1023, %esi                     ## imm = 0x3FF
	jg	LBB0_11
## %bb.1:
	movl	%esi, %r15d
	movq	%rdi, %r14
	movq	(%rdi), %rax
	movslq	%esi, %r12
	movl	(%rax,%r12,4), %ebx
	testl	%ebx, %ebx
	je	LBB0_5
## %bb.2:
	movq	_CTX_VALUE@GOTPCREL(%rip), %rcx
	andl	(%rcx), %ebx
	movq	_MAX_CT@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %ebx
	jge	LBB0_3
## %bb.4:
	cmpq	$0, 8(%r14)
	jne	LBB0_11
	jmp	LBB0_5
LBB0_3:
	movl	$0, (%rax,%r12,4)
LBB0_5:
	movq	_MAX_CT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	LBB0_10
## %bb.6:
	movq	8(%r14), %rdi
	movq	_CHAN_VALID@GOTPCREL(%rip), %r13
	movl	(%r13), %ecx
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	testl	%ecx, (%rdi)
	je	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	incq	%rbx
	addq	$8, %rdi
	cmpq	%rbx, %rax
	jne	LBB0_7
LBB0_10:
	movq	_LOG_ERR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r15d, %edx
	callq	_log
	movl	$-1, %ebx
	jmp	LBB0_11
LBB0_8:
	movl	$8, %esi
	callq	_bzero
	movq	(%r14), %rax
	movq	8(%r14), %rcx
	movq	_CTX_VALID@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	orl	%ebx, %edx
	movl	%edx, (%rax,%r12,4)
	movl	%r15d, 4(%rcx,%rbx,8)
	movl	(%r13), %eax
	movl	%eax, (%rcx,%rbx,8)
LBB0_11:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CTX_VALUE,4,2                  ## @CTX_VALUE
	.comm	_MAX_CT,4,2                     ## @MAX_CT
	.comm	_CHAN_VALID,4,2                 ## @CHAN_VALID
	.comm	_CTX_VALID,4,2                  ## @CTX_VALID
	.comm	_LOG_ERR,4,2                    ## @LOG_ERR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"No CTX available for dlci %d\n"

	.no_dead_strip	_ngfrm_allocate_CTX
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ngfrm_allocate_CTX
_ngfrm_allocate_CTX:                    ; @ngfrm_allocate_CTX
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	cmp	w1, #1023
	b.gt	LBB0_10
; %bb.1:
	mov	x19, x1
	mov	x20, x0
	ldr	x9, [x0]
	sxtw	x22, w19
	ldr	w10, [x9, w1, sxtw #2]
Lloh0:
	adrp	x8, _MAX_CT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MAX_CT@GOTPAGEOFF]
	cbz	w10, LBB0_5
; %bb.2:
Lloh2:
	adrp	x11, _CTX_VALUE@GOTPAGE
Lloh3:
	ldr	x11, [x11, _CTX_VALUE@GOTPAGEOFF]
Lloh4:
	ldr	w11, [x11]
	and	w21, w11, w10
	ldr	w10, [x8]
	cmp	w21, w10
	b.ge	LBB0_4
; %bb.3:
	ldr	x9, [x20, #8]
	cbnz	x9, LBB0_11
	b	LBB0_5
LBB0_4:
	str	wzr, [x9, x22, lsl #2]
LBB0_5:
	ldr	w10, [x8]
	cmp	w10, #1
	b.lt	LBB0_9
; %bb.6:
	mov	w21, #0
	mov	x23, #0
	ldr	x8, [x20, #8]
Lloh5:
	adrp	x24, _CHAN_VALID@GOTPAGE
Lloh6:
	ldr	x24, [x24, _CHAN_VALID@GOTPAGEOFF]
	ldr	w9, [x24]
	lsl	x10, x10, #3
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w11, [x8, x23]
	tst	w9, w11
	b.eq	LBB0_12
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	add	x23, x23, #8
	add	w21, w21, #1
	cmp	x10, x23
	b.ne	LBB0_7
LBB0_9:
Lloh7:
	adrp	x8, _LOG_ERR@GOTPAGE
Lloh8:
	ldr	x8, [x8, _LOG_ERR@GOTPAGEOFF]
Lloh9:
	ldr	w0, [x8]
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x19
	bl	_log
LBB0_10:
	mov	w21, #-1
LBB0_11:
	mov	x0, x21
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_12:
	add	x0, x8, x23
	mov	w1, #8
	bl	_bzero
Lloh12:
	adrp	x8, _CTX_VALID@GOTPAGE
Lloh13:
	ldr	x8, [x8, _CTX_VALID@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	orr	w8, w8, w21
	ldp	x10, x9, [x20]
	str	w8, [x10, x22, lsl #2]
	add	x8, x9, x23
	str	w19, [x8, #4]
	ldr	w9, [x24]
	str	w9, [x8]
	b	LBB0_11
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_CTX_VALUE,4,2                  ; @CTX_VALUE
	.comm	_MAX_CT,4,2                     ; @MAX_CT
	.comm	_CHAN_VALID,4,2                 ; @CHAN_VALID
	.comm	_CTX_VALID,4,2                  ; @CTX_VALID
	.comm	_LOG_ERR,4,2                    ; @LOG_ERR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"No CTX available for dlci %d\n"

	.no_dead_strip	_ngfrm_allocate_CTX
.subsections_via_symbols
