	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function open_write_fd
_open_write_fd:                         ## @open_write_fd
	.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	_buffered_write@GOTPCREL(%rip), %rax
	movl	%esi, (%rax)
	movq	_Buff@GOTPCREL(%rip), %rax
	movq	_BUFFSIZE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	addq	(%rax), %rcx
	movq	_write_filename@GOTPCREL(%rip), %rax
	movq	%rdi, (%rax)
	movq	_wptr@GOTPCREL(%rip), %rax
	movq	%rcx, (%rax)
	movq	_rptr@GOTPCREL(%rip), %rax
	movq	%rcx, (%rax)
	movq	_write_off@GOTPCREL(%rip), %rax
	movq	$0, (%rax)
	testl	%edx, %edx
	js	LBB0_1
## %bb.5:
	movl	%edx, %ebx
	xorl	%edi, %edi
	cmpl	$1, %edx
	sete	%dil
	callq	_assert
LBB0_6:
	movq	_write_fd@GOTPCREL(%rip), %rax
	movl	%ebx, (%rax)
LBB0_7:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_1:
	movq	%rdi, %r14
	movq	_O_CREAT@GOTPCREL(%rip), %rax
	movq	_O_WRONLY@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	orl	(%rax), %esi
	movq	_O_EXCL@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	movl	$416, %edx                      ## imm = 0x1A0
	callq	_open
	testl	%eax, %eax
	js	LBB0_2
## %bb.3:
	movl	%eax, %ebx
	xorl	%edi, %edi
	cmpl	$2, %eax
	setae	%dil
	callq	_assert
	movq	_F_WRLCK@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%ebx, %edi
	callq	_lock_whole_file
	testq	%rax, %rax
	jg	LBB0_6
## %bb.4:
	leaq	L_.str.1(%rip), %rdi
	movq	%r14, %rsi
	callq	_kprintf
	movl	%ebx, %edi
	callq	_close
	xorl	%edi, %edi
	testl	%eax, %eax
	sete	%dil
	callq	_assert
	movl	$-1, %ebx
	jmp	LBB0_7
LBB0_2:
	leaq	L_.str(%rip), %rdi
	movq	%r14, %rsi
	callq	_kprintf
	movl	$-1, %ebx
	jmp	LBB0_7
	.cfi_endproc
                                        ## -- End function
	.comm	_buffered_write,4,2             ## @buffered_write
	.comm	_write_filename,8,3             ## @write_filename
	.comm	_Buff,8,3                       ## @Buff
	.comm	_BUFFSIZE,8,3                   ## @BUFFSIZE
	.comm	_wptr,8,3                       ## @wptr
	.comm	_rptr,8,3                       ## @rptr
	.comm	_write_off,8,3                  ## @write_off
	.comm	_O_CREAT,4,2                    ## @O_CREAT
	.comm	_O_WRONLY,4,2                   ## @O_WRONLY
	.comm	_O_EXCL,4,2                     ## @O_EXCL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"open (%s, O_CREAT | O_WRONLY | O_EXCL, 0640) failed. %m\n"

	.comm	_F_WRLCK,4,2                    ## @F_WRLCK
L_.str.1:                               ## @.str.1
	.asciz	"cannot lock file '%s' for writing\n"

	.comm	_write_fd,4,2                   ## @write_fd
	.no_dead_strip	_open_write_fd
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function open_write_fd
_open_write_fd:                         ; @open_write_fd
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
Lloh0:
	adrp	x8, _buffered_write@GOTPAGE
Lloh1:
	ldr	x8, [x8, _buffered_write@GOTPAGEOFF]
Lloh2:
	adrp	x9, _write_filename@GOTPAGE
Lloh3:
	ldr	x9, [x9, _write_filename@GOTPAGEOFF]
Lloh4:
	str	w1, [x8]
Lloh5:
	str	x0, [x9]
Lloh6:
	adrp	x8, _Buff@GOTPAGE
Lloh7:
	ldr	x8, [x8, _Buff@GOTPAGEOFF]
Lloh8:
	adrp	x9, _BUFFSIZE@GOTPAGE
Lloh9:
	ldr	x9, [x9, _BUFFSIZE@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
Lloh11:
	ldr	x9, [x9]
	add	x8, x9, x8
Lloh12:
	adrp	x9, _wptr@GOTPAGE
Lloh13:
	ldr	x9, [x9, _wptr@GOTPAGEOFF]
Lloh14:
	str	x8, [x9]
Lloh15:
	adrp	x9, _rptr@GOTPAGE
Lloh16:
	ldr	x9, [x9, _rptr@GOTPAGEOFF]
Lloh17:
	str	x8, [x9]
Lloh18:
	adrp	x8, _write_off@GOTPAGE
Lloh19:
	ldr	x8, [x8, _write_off@GOTPAGEOFF]
Lloh20:
	str	xzr, [x8]
	tbnz	w2, #31, LBB0_4
; %bb.1:
	mov	x19, x2
	cmp	w2, #1
	cset	w0, eq
	bl	_assert
LBB0_2:
Lloh21:
	adrp	x8, _write_fd@GOTPAGE
Lloh22:
	ldr	x8, [x8, _write_fd@GOTPAGEOFF]
Lloh23:
	str	w19, [x8]
LBB0_3:
	mov	x0, x19
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
LBB0_4:
	mov	x20, x0
Lloh24:
	adrp	x8, _O_CREAT@GOTPAGE
Lloh25:
	ldr	x8, [x8, _O_CREAT@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
Lloh27:
	adrp	x9, _O_WRONLY@GOTPAGE
Lloh28:
	ldr	x9, [x9, _O_WRONLY@GOTPAGEOFF]
Lloh29:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh30:
	adrp	x9, _O_EXCL@GOTPAGE
Lloh31:
	ldr	x9, [x9, _O_EXCL@GOTPAGEOFF]
Lloh32:
	ldr	w9, [x9]
	orr	w1, w8, w9
	mov	w2, #416
	bl	_open
	tbnz	w0, #31, LBB0_7
; %bb.5:
	mov	x19, x0
	cmp	w0, #1
	cset	w0, hi
	bl	_assert
Lloh33:
	adrp	x8, _F_WRLCK@GOTPAGE
Lloh34:
	ldr	x8, [x8, _F_WRLCK@GOTPAGEOFF]
Lloh35:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_lock_whole_file
	cmp	x0, #0
	b.gt	LBB0_2
; %bb.6:
Lloh36:
	adrp	x0, l_.str.1@PAGE
Lloh37:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x20
	bl	_kprintf
	mov	x0, x19
	bl	_close
	cmp	w0, #0
	cset	w0, eq
	bl	_assert
	mov	w19, #-1
	b	LBB0_3
LBB0_7:
Lloh38:
	adrp	x0, l_.str@PAGE
Lloh39:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x20
	bl	_kprintf
	mov	w19, #-1
	b	LBB0_3
	.loh AdrpLdrGotStr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotStr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotStr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh10
	.loh AdrpLdrGotStr	Lloh2, Lloh3, Lloh5
	.loh AdrpLdrGotStr	Lloh0, Lloh1, Lloh4
	.loh AdrpLdrGotStr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpAdd	Lloh36, Lloh37
	.loh AdrpAdd	Lloh38, Lloh39
	.cfi_endproc
                                        ; -- End function
	.comm	_buffered_write,4,2             ; @buffered_write
	.comm	_write_filename,8,3             ; @write_filename
	.comm	_Buff,8,3                       ; @Buff
	.comm	_BUFFSIZE,8,3                   ; @BUFFSIZE
	.comm	_wptr,8,3                       ; @wptr
	.comm	_rptr,8,3                       ; @rptr
	.comm	_write_off,8,3                  ; @write_off
	.comm	_O_CREAT,4,2                    ; @O_CREAT
	.comm	_O_WRONLY,4,2                   ; @O_WRONLY
	.comm	_O_EXCL,4,2                     ; @O_EXCL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"open (%s, O_CREAT | O_WRONLY | O_EXCL, 0640) failed. %m\n"

	.comm	_F_WRLCK,4,2                    ; @F_WRLCK
l_.str.1:                               ; @.str.1
	.asciz	"cannot lock file '%s' for writing\n"

	.comm	_write_fd,4,2                   ; @write_fd
	.no_dead_strip	_open_write_fd
.subsections_via_symbols
