	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_metadata_write                 ## -- Begin function metadata_write
	.p2align	4, 0x90
_metadata_write:                        ## @metadata_write
	.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
	movq	%rdi, %rbx
	movq	_METADATA_SIZE@GOTPCREL(%rip), %r13
	movq	(%r13), %rsi
	movl	$1, %edi
	callq	_calloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r14
	xorl	%eax, %eax
	callq	_nv_alloc
	movq	%rax, %r15
	movl	72(%rbx), %esi
	leaq	L_.str.1(%rip), %rdx
	movq	%rax, %rdi
	callq	_nv_add_string
	movl	64(%rbx), %esi
	leaq	L_.str.2(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	movl	56(%rbx), %esi
	leaq	L_.str.3(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint32
	movl	48(%rbx), %esi
	leaq	L_.str.4(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint32
	movl	40(%rbx), %esi
	leaq	L_.str.5(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	movl	36(%rbx), %esi
	leaq	L_.str.6(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	movq	(%rbx), %rax
	movq	_HAST_ROLE_PRIMARY@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_4
## %bb.3:
	movq	_HAST_ROLE_INIT@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_4
## %bb.5:
	movq	_HAST_ROLE_SECONDARY@GOTPCREL(%rip), %rcx
	xorl	%edi, %edi
	cmpq	(%rcx), %rax
	sete	%dil
	callq	_PJDLOG_ASSERT
	movl	24(%rbx), %esi
	leaq	L_.str.7(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	leaq	20(%rbx), %rax
	jmp	LBB0_6
LBB0_1:
	movq	(%r13), %rsi
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_pjdlog_error
	movl	$-1, %ebx
	jmp	LBB0_13
LBB0_4:
	movl	32(%rbx), %esi
	leaq	L_.str.7(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	leaq	28(%rbx), %rax
LBB0_6:
	movl	(%rax), %esi
	leaq	L_.str.8(%rip), %rdx
	movq	%r15, %rdi
	callq	_nv_add_uint64
	movq	(%rbx), %rdi
	callq	_role2str
	leaq	L_.str.9(%rip), %rdx
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_nv_add_string
	movq	%r15, %rdi
	callq	_nv_error
	testq	%rax, %rax
	je	LBB0_8
## %bb.7:
	leaq	L_.str.10(%rip), %rdi
	xorl	%eax, %eax
	callq	_pjdlog_error
	jmp	LBB0_11
LBB0_8:
	movq	(%rbx), %rax
	movq	%rax, 8(%rbx)
	movq	%r15, %rdi
	callq	_nv_hton
	movq	%rax, %r12
	xorl	%edi, %edi
	testq	%rax, %rax
	setne	%dil
	callq	_PJDLOG_ASSERT
	leaq	-48(%rbp), %rsi
	movq	%r12, %rdi
	callq	_ebuf_data
	movq	%rax, %r12
	xorl	%edi, %edi
	testq	%rax, %rax
	setne	%dil
	callq	_PJDLOG_ASSERT
	movq	-48(%rbp), %rax
	xorl	%edi, %edi
	cmpq	(%r13), %rax
	setb	%dil
	callq	_PJDLOG_ASSERT
	movq	-48(%rbp), %rdx
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_memmove
	movl	16(%rbx), %edi
	movq	(%r13), %rdx
	xorl	%ebx, %ebx
	movq	%r14, %rsi
	xorl	%ecx, %ecx
	callq	_pwrite
	cmpl	$-1, %eax
	je	LBB0_10
## %bb.9:
	cltq
	cmpq	%rax, (%r13)
	je	LBB0_12
LBB0_10:
	movq	_LOG_ERR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.11(%rip), %rsi
	callq	_pjdlog_errno
LBB0_11:
	movl	$-1, %ebx
LBB0_12:
	movq	%r14, %rdi
	callq	_free
	movq	%r15, %rdi
	callq	_nv_free
LBB0_13:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_METADATA_SIZE,8,3              ## @METADATA_SIZE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unable to allocate %zu bytes for metadata."

L_.str.1:                               ## @.str.1
	.asciz	"resource"

L_.str.2:                               ## @.str.2
	.asciz	"datasize"

L_.str.3:                               ## @.str.3
	.asciz	"extentsize"

L_.str.4:                               ## @.str.4
	.asciz	"keepdirty"

L_.str.5:                               ## @.str.5
	.asciz	"offset"

L_.str.6:                               ## @.str.6
	.asciz	"resuid"

	.comm	_HAST_ROLE_PRIMARY,8,3          ## @HAST_ROLE_PRIMARY
	.comm	_HAST_ROLE_INIT,8,3             ## @HAST_ROLE_INIT
L_.str.7:                               ## @.str.7
	.asciz	"localcnt"

L_.str.8:                               ## @.str.8
	.asciz	"remotecnt"

	.comm	_HAST_ROLE_SECONDARY,8,3        ## @HAST_ROLE_SECONDARY
L_.str.9:                               ## @.str.9
	.asciz	"prevrole"

L_.str.10:                              ## @.str.10
	.asciz	"Unable to create metadata."

	.comm	_LOG_ERR,4,2                    ## @LOG_ERR
L_.str.11:                              ## @.str.11
	.asciz	"Unable to write metadata"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_metadata_write                 ; -- Begin function metadata_write
	.p2align	2
_metadata_write:                        ; @metadata_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	mov	x21, x0
Lloh0:
	adrp	x23, _METADATA_SIZE@GOTPAGE
Lloh1:
	ldr	x23, [x23, _METADATA_SIZE@GOTPAGEOFF]
	ldr	x1, [x23]
	mov	w0, #1
	bl	_calloc
	cbz	x0, LBB0_3
; %bb.1:
	mov	x19, x0
	bl	_nv_alloc
	mov	x20, x0
	ldr	w1, [x21, #72]
Lloh2:
	adrp	x2, l_.str.1@PAGE
Lloh3:
	add	x2, x2, l_.str.1@PAGEOFF
	bl	_nv_add_string
	ldr	w1, [x21, #64]
Lloh4:
	adrp	x2, l_.str.2@PAGE
Lloh5:
	add	x2, x2, l_.str.2@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	ldr	w1, [x21, #56]
Lloh6:
	adrp	x2, l_.str.3@PAGE
Lloh7:
	add	x2, x2, l_.str.3@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint32
	ldr	w1, [x21, #48]
Lloh8:
	adrp	x2, l_.str.4@PAGE
Lloh9:
	add	x2, x2, l_.str.4@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint32
	ldr	w1, [x21, #40]
Lloh10:
	adrp	x2, l_.str.5@PAGE
Lloh11:
	add	x2, x2, l_.str.5@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	ldr	w1, [x21, #36]
Lloh12:
	adrp	x2, l_.str.6@PAGE
Lloh13:
	add	x2, x2, l_.str.6@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	ldr	x8, [x21]
Lloh14:
	adrp	x9, _HAST_ROLE_PRIMARY@GOTPAGE
Lloh15:
	ldr	x9, [x9, _HAST_ROLE_PRIMARY@GOTPAGEOFF]
Lloh16:
	ldr	x9, [x9]
Lloh17:
	adrp	x10, _HAST_ROLE_INIT@GOTPAGE
Lloh18:
	ldr	x10, [x10, _HAST_ROLE_INIT@GOTPAGEOFF]
Lloh19:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_4
; %bb.2:
	ldr	w1, [x21, #32]
Lloh20:
	adrp	x2, l_.str.7@PAGE
Lloh21:
	add	x2, x2, l_.str.7@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	add	x8, x21, #28
	b	LBB0_5
LBB0_3:
	ldr	x8, [x23]
	str	x8, [sp]
Lloh22:
	adrp	x0, l_.str@PAGE
Lloh23:
	add	x0, x0, l_.str@PAGEOFF
	bl	_pjdlog_error
	mov	w21, #-1
	b	LBB0_13
LBB0_4:
Lloh24:
	adrp	x9, _HAST_ROLE_SECONDARY@GOTPAGE
Lloh25:
	ldr	x9, [x9, _HAST_ROLE_SECONDARY@GOTPAGEOFF]
Lloh26:
	ldr	x9, [x9]
	cmp	x8, x9
	cset	w0, eq
	bl	_PJDLOG_ASSERT
	ldr	w1, [x21, #24]
Lloh27:
	adrp	x2, l_.str.7@PAGE
Lloh28:
	add	x2, x2, l_.str.7@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	add	x8, x21, #20
LBB0_5:
	ldr	w1, [x8]
Lloh29:
	adrp	x2, l_.str.8@PAGE
Lloh30:
	add	x2, x2, l_.str.8@PAGEOFF
	mov	x0, x20
	bl	_nv_add_uint64
	ldr	x0, [x21]
	bl	_role2str
	mov	x1, x0
Lloh31:
	adrp	x2, l_.str.9@PAGE
Lloh32:
	add	x2, x2, l_.str.9@PAGEOFF
	mov	x0, x20
	bl	_nv_add_string
	mov	x0, x20
	bl	_nv_error
	cbz	x0, LBB0_7
; %bb.6:
Lloh33:
	adrp	x0, l_.str.10@PAGE
Lloh34:
	add	x0, x0, l_.str.10@PAGEOFF
	bl	_pjdlog_error
	b	LBB0_11
LBB0_7:
	ldr	x8, [x21]
	str	x8, [x21, #8]
	mov	x0, x20
	bl	_nv_hton
	mov	x22, x0
	cmp	x0, #0
	cset	w0, ne
	bl	_PJDLOG_ASSERT
	add	x1, sp, #8
	mov	x0, x22
	bl	_ebuf_data
	mov	x22, x0
	cmp	x0, #0
	cset	w0, ne
	bl	_PJDLOG_ASSERT
	ldr	x8, [sp, #8]
	ldr	x9, [x23]
	cmp	x8, x9
	cset	w0, lo
	bl	_PJDLOG_ASSERT
	ldr	x2, [sp, #8]
	mov	x0, x19
	mov	x1, x22
	bl	_memmove
	ldr	w0, [x21, #16]
	ldr	x2, [x23]
	mov	x1, x19
	mov	w3, #0
	bl	_pwrite
	cmn	w0, #1
	b.eq	LBB0_10
; %bb.8:
	ldr	x8, [x23]
	cmp	x8, w0, sxtw
	b.ne	LBB0_10
; %bb.9:
	mov	w21, #0
	b	LBB0_12
LBB0_10:
Lloh35:
	adrp	x8, _LOG_ERR@GOTPAGE
Lloh36:
	ldr	x8, [x8, _LOG_ERR@GOTPAGEOFF]
Lloh37:
	ldr	w0, [x8]
Lloh38:
	adrp	x1, l_.str.11@PAGE
Lloh39:
	add	x1, x1, l_.str.11@PAGEOFF
	bl	_pjdlog_errno
LBB0_11:
	mov	w21, #-1
LBB0_12:
	mov	x0, x19
	bl	_free
	mov	x0, x20
	bl	_nv_free
LBB0_13:
	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
	add	sp, sp, #80
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh33, Lloh34
	.loh AdrpAdd	Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.cfi_endproc
                                        ; -- End function
	.comm	_METADATA_SIZE,8,3              ; @METADATA_SIZE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unable to allocate %zu bytes for metadata."

l_.str.1:                               ; @.str.1
	.asciz	"resource"

l_.str.2:                               ; @.str.2
	.asciz	"datasize"

l_.str.3:                               ; @.str.3
	.asciz	"extentsize"

l_.str.4:                               ; @.str.4
	.asciz	"keepdirty"

l_.str.5:                               ; @.str.5
	.asciz	"offset"

l_.str.6:                               ; @.str.6
	.asciz	"resuid"

	.comm	_HAST_ROLE_PRIMARY,8,3          ; @HAST_ROLE_PRIMARY
	.comm	_HAST_ROLE_INIT,8,3             ; @HAST_ROLE_INIT
l_.str.7:                               ; @.str.7
	.asciz	"localcnt"

l_.str.8:                               ; @.str.8
	.asciz	"remotecnt"

	.comm	_HAST_ROLE_SECONDARY,8,3        ; @HAST_ROLE_SECONDARY
l_.str.9:                               ; @.str.9
	.asciz	"prevrole"

l_.str.10:                              ; @.str.10
	.asciz	"Unable to create metadata."

	.comm	_LOG_ERR,4,2                    ; @LOG_ERR
l_.str.11:                              ; @.str.11
	.asciz	"Unable to write metadata"

.subsections_via_symbols
