	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mthca_free_db                  ## -- Begin function mthca_free_db
	.p2align	4, 0x90
_mthca_free_db:                         ## @mthca_free_db
	.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	%edx, %eax
	movq	%rdi, %r15
	movq	_MTHCA_DB_REC_PER_PAGE@GOTPCREL(%rip), %rcx
	cltd
	idivl	(%rcx)
                                        ## kill: def $eax killed $eax def $rax
	movl	%edx, %r13d
	movq	(%rdi), %rdi
	movq	16(%rdi), %r12
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movslq	%eax, %r14
	addq	$8, %rdi
	callq	_mutex_lock
	movq	%r14, %rbx
	shlq	$4, %rbx
	movq	(%r12,%rbx), %rax
	movslq	%r13d, %rcx
	movq	$0, (%rax,%rcx,8)
	movq	(%r15), %rax
	movl	%ecx, %edi
	notl	%edi
	movq	_MTHCA_DB_REC_PER_PAGE@GOTPCREL(%rip), %rdx
	addl	(%rdx), %edi
	cmpl	(%rax), %r14d
	cmovll	%ecx, %edi
	movl	12(%r12,%rbx), %esi
	callq	_clear_bit
	movl	12(%r12,%rbx), %edi
	movq	_MTHCA_DB_REC_PER_PAGE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_bitmap_empty
	movq	(%r15), %rdi
	testq	%rax, %rax
	je	LBB0_6
## %bb.1:
	movl	4(%rdi), %eax
	decl	%eax
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	cmpl	%eax, %r14d
	jl	LBB0_6
## %bb.2:
	leaq	(%r12,%rbx), %r13
	leaq	16(%r15), %rsi
	movq	%r15, %rdi
	movl	%r14d, %edx
	callq	_mthca_uarc_virt
	movq	%r15, %rdi
	movl	%eax, %esi
	movl	$1, %edx
	callq	_mthca_UNMAP_ICM
	movq	8(%r15), %rdi
	movq	_MTHCA_ICM_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	(%r13), %rdx
	movl	8(%r12,%rbx), %ecx
	callq	_dma_free_coherent
	movq	$0, (%r13)
	movq	(%r15), %rdi
	cmpl	4(%rdi), %r14d
	jne	LBB0_4
## %bb.3:
	leal	-1(%r14), %eax
	movl	%eax, 4(%rdi)
LBB0_4:
	cmpl	(%rdi), %r14d
	jne	LBB0_6
## %bb.5:
	incl	%r14d
	movl	%r14d, (%rdi)
LBB0_6:
	addq	$8, %rdi
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_mutex_unlock                   ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_MTHCA_DB_REC_PER_PAGE,4,2      ## @MTHCA_DB_REC_PER_PAGE
	.comm	_MTHCA_ICM_PAGE_SIZE,4,2        ## @MTHCA_ICM_PAGE_SIZE
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mthca_free_db                  ; -- Begin function mthca_free_db
	.p2align	2
_mthca_free_db:                         ; @mthca_free_db
	.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
	mov	x19, x0
Lloh0:
	adrp	x23, _MTHCA_DB_REC_PER_PAGE@GOTPAGE
Lloh1:
	ldr	x23, [x23, _MTHCA_DB_REC_PER_PAGE@GOTPAGEOFF]
	ldr	w8, [x23]
	sdiv	w20, w2, w8
	msub	w24, w20, w8, w2
	ldr	x8, [x0]
	ldr	x22, [x8, #16]
	add	x0, x8, #8
	bl	_mutex_lock
	add	x21, x22, w20, sxtw #4
	ldr	x8, [x21]
	str	xzr, [x8, w24, sxtw #3]
	ldr	x8, [x19]
	ldr	w8, [x8]
	ldr	w9, [x23]
	mvn	w10, w24
	add	w9, w9, w10
	cmp	w20, w8
	csel	w0, w24, w9, lt
	ldr	w1, [x21, #12]
	bl	_clear_bit
	ldr	w0, [x21, #12]
	ldr	w1, [x23]
	bl	_bitmap_empty
	ldr	x8, [x19]
	cbz	x0, LBB0_6
; %bb.1:
	sxtw	x20, w20
	ldr	w9, [x8, #4]
	sub	w9, w9, #1
	cmp	w20, w9
	b.lt	LBB0_6
; %bb.2:
	add	x1, x19, #16
	mov	x0, x19
	mov	x2, x20
	bl	_mthca_uarc_virt
	mov	x1, x0
	mov	x0, x19
	mov	w2, #1
	bl	_mthca_UNMAP_ICM
	ldr	x0, [x19, #8]
Lloh2:
	adrp	x8, _MTHCA_ICM_PAGE_SIZE@GOTPAGE
Lloh3:
	ldr	x8, [x8, _MTHCA_ICM_PAGE_SIZE@GOTPAGEOFF]
Lloh4:
	ldr	w1, [x8]
	ldr	x2, [x21]
	add	x8, x22, x20, lsl #4
	ldr	w3, [x8, #8]
	bl	_dma_free_coherent
	str	xzr, [x21]
	ldr	x8, [x19]
	ldr	w9, [x8, #4]
	cmp	w20, w9
	b.ne	LBB0_4
; %bb.3:
	sub	w9, w20, #1
	str	w9, [x8, #4]
LBB0_4:
	ldr	w9, [x8]
	cmp	w20, w9
	b.ne	LBB0_6
; %bb.5:
	add	w9, w20, #1
	str	w9, [x8]
LBB0_6:
	add	x0, x8, #8
	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
	b	_mutex_unlock
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_MTHCA_DB_REC_PER_PAGE,4,2      ; @MTHCA_DB_REC_PER_PAGE
	.comm	_MTHCA_ICM_PAGE_SIZE,4,2        ; @MTHCA_ICM_PAGE_SIZE
.subsections_via_symbols
