	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_writefileimage                 ## -- Begin function writefileimage
	.p2align	4, 0x90
_writefileimage:                        ## @writefileimage
	.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	_fd@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	movq	_SEEK_SET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%esi, %esi
	callq	_lseek
	cmpq	$-1, %rax
	jne	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rdi
	callq	_prterr
	movl	$171, %edi
	callq	_report_failure
LBB0_2:
	movl	(%r14), %edi
	movq	_good_buf@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_file_size@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdx
	callq	_write
	movslq	%eax, %rsi
	movq	(%rbx), %rdx
	cmpq	%rsi, %rdx
	je	LBB0_7
## %bb.3:
	cmpl	$-1, %eax
	je	LBB0_4
## %bb.5:
	leaq	L_.str.2(%rip), %rdi
	xorl	%eax, %eax
	callq	_prt
	jmp	LBB0_6
LBB0_4:
	leaq	L_.str.1(%rip), %rdi
	callq	_prterr
LBB0_6:
	movl	$172, %edi
	callq	_report_failure
LBB0_7:
	movq	_lite@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	jne	LBB0_9
## %bb.8:
	movl	(%r14), %edi
	movq	(%rbx), %rsi
	callq	_ftruncate
	cmpl	$-1, %eax
	je	LBB0_10
LBB0_9:
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_10:
	movq	(%rbx), %rsi
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_prt
	leaq	L_.str.4(%rip), %rdi
	callq	_prterr
	movl	$173, %edi
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_report_failure                 ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_fd,4,2                         ## @fd
	.comm	_SEEK_SET,4,2                   ## @SEEK_SET
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"writefileimage: lseek"

	.comm	_good_buf,4,2                   ## @good_buf
	.comm	_file_size,8,3                  ## @file_size
L_.str.1:                               ## @.str.1
	.asciz	"writefileimage: write"

L_.str.2:                               ## @.str.2
	.asciz	"short write: 0x%x bytes instead of 0x%llx\n"

	.comm	_lite,8,3                       ## @lite
L_.str.3:                               ## @.str.3
	.asciz	"ftruncate2: %llx\n"

L_.str.4:                               ## @.str.4
	.asciz	"writefileimage: ftruncate"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_writefileimage                 ; -- Begin function writefileimage
	.p2align	2
_writefileimage:                        ; @writefileimage
	.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
Lloh0:
	adrp	x19, _fd@GOTPAGE
Lloh1:
	ldr	x19, [x19, _fd@GOTPAGEOFF]
	ldr	w0, [x19]
Lloh2:
	adrp	x8, _SEEK_SET@GOTPAGE
Lloh3:
	ldr	x8, [x8, _SEEK_SET@GOTPAGEOFF]
Lloh4:
	ldr	w2, [x8]
	mov	x1, #0
	bl	_lseek
	cmn	x0, #1
	b.ne	LBB0_2
; %bb.1:
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	bl	_prterr
	mov	w0, #171
	bl	_report_failure
LBB0_2:
	ldr	w0, [x19]
Lloh7:
	adrp	x8, _good_buf@GOTPAGE
Lloh8:
	ldr	x8, [x8, _good_buf@GOTPAGEOFF]
Lloh9:
	ldr	w1, [x8]
Lloh10:
	adrp	x20, _file_size@GOTPAGE
Lloh11:
	ldr	x20, [x20, _file_size@GOTPAGEOFF]
	ldr	x2, [x20]
	bl	_write
                                        ; kill: def $w0 killed $w0 def $x0
	sxtw	x1, w0
	ldr	x8, [x20]
	cmp	x8, x1
	b.eq	LBB0_7
; %bb.3:
	cmn	w1, #1
	b.eq	LBB0_5
; %bb.4:
	str	x8, [sp]
Lloh12:
	adrp	x0, l_.str.2@PAGE
Lloh13:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_prt
	b	LBB0_6
LBB0_5:
Lloh14:
	adrp	x0, l_.str.1@PAGE
Lloh15:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_prterr
LBB0_6:
	mov	w0, #172
	bl	_report_failure
LBB0_7:
Lloh16:
	adrp	x8, _lite@GOTPAGE
Lloh17:
	ldr	x8, [x8, _lite@GOTPAGEOFF]
Lloh18:
	ldr	x8, [x8]
	cbnz	x8, LBB0_9
; %bb.8:
	ldr	w0, [x19]
	ldr	x1, [x20]
	bl	_ftruncate
	cmn	w0, #1
	b.eq	LBB0_10
LBB0_9:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
LBB0_10:
	ldr	x1, [x20]
Lloh19:
	adrp	x0, l_.str.3@PAGE
Lloh20:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_prt
Lloh21:
	adrp	x0, l_.str.4@PAGE
Lloh22:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_prterr
	mov	w0, #173
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	b	_report_failure
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_fd,4,2                         ; @fd
	.comm	_SEEK_SET,4,2                   ; @SEEK_SET
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"writefileimage: lseek"

	.comm	_good_buf,4,2                   ; @good_buf
	.comm	_file_size,8,3                  ; @file_size
l_.str.1:                               ; @.str.1
	.asciz	"writefileimage: write"

l_.str.2:                               ; @.str.2
	.asciz	"short write: 0x%x bytes instead of 0x%llx\n"

	.comm	_lite,8,3                       ; @lite
l_.str.3:                               ; @.str.3
	.asciz	"ftruncate2: %llx\n"

l_.str.4:                               ; @.str.4
	.asciz	"writefileimage: ftruncate"

.subsections_via_symbols
