	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_libpe_write_pe_header          ## -- Begin function libpe_write_pe_header
	.p2align	4, 0x90
_libpe_write_pe_header:                 ## @libpe_write_pe_header
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	movq	(%rdi), %rax
	movq	_PE_C_RDWR@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_2
## %bb.1:
	movq	_LIBPE_F_BAD_PE_HEADER@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, 8(%rbx)
	je	LBB0_7
LBB0_2:
	movq	%rbx, %rdi
	movl	$8, %edx
	callq	_libpe_align
	movl	$-1, %r15d
	testl	%eax, %eax
	js	LBB0_6
## %bb.3:
	movl	%eax, %r14d
	movq	_PE_SIGNATURE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-36(%rbp), %r12
	movq	%r12, %rdi
	callq	_le32enc
	movl	12(%rbx), %edi
	movq	%r12, %rsi
	movl	$4, %edx
	callq	_write
	cmpq	$4, %rax
	jne	LBB0_4
## %bb.5:
	movq	_LIBPE_F_BAD_PE_HEADER@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	8(%rbx), %eax
	addl	$4, %r14d
	movq	_LIBPE_F_DIRTY_COFF_HEADER@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	_LIBPE_F_DIRTY_OPT_HEADER@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movl	%eax, 8(%rbx)
	movl	%r14d, %r15d
	jmp	LBB0_6
LBB0_4:
	movq	_EIO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	_errno@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
LBB0_6:
	movl	%r15d, %eax
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	xorl	%edi, %edi
	cmpq	$0, 16(%rbx)
	setne	%dil
	callq	_assert
	movl	12(%rbx), %edi
	movq	16(%rbx), %rax
	movl	(%rax), %esi
	addl	$4, %esi
	movq	_SEEK_SET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_lseek                          ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_PE_C_RDWR,8,3                  ## @PE_C_RDWR
	.comm	_LIBPE_F_BAD_PE_HEADER,4,2      ## @LIBPE_F_BAD_PE_HEADER
	.comm	_SEEK_SET,4,2                   ## @SEEK_SET
	.comm	_PE_SIGNATURE,4,2               ## @PE_SIGNATURE
	.comm	_EIO,4,2                        ## @EIO
	.comm	_errno,4,2                      ## @errno
	.comm	_LIBPE_F_DIRTY_COFF_HEADER,4,2  ## @LIBPE_F_DIRTY_COFF_HEADER
	.comm	_LIBPE_F_DIRTY_OPT_HEADER,4,2   ## @LIBPE_F_DIRTY_OPT_HEADER
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_libpe_write_pe_header          ; -- Begin function libpe_write_pe_header
	.p2align	2
_libpe_write_pe_header:                 ; @libpe_write_pe_header
	.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
	mov	x19, x0
	ldr	x8, [x0]
Lloh0:
	adrp	x9, _PE_C_RDWR@GOTPAGE
Lloh1:
	ldr	x9, [x9, _PE_C_RDWR@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_2
; %bb.1:
	ldr	w8, [x19, #8]
Lloh3:
	adrp	x9, _LIBPE_F_BAD_PE_HEADER@GOTPAGE
Lloh4:
	ldr	x9, [x9, _LIBPE_F_BAD_PE_HEADER@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_8
LBB0_2:
	mov	x0, x19
	mov	w2, #8
	bl	_libpe_align
	tbnz	w0, #31, LBB0_6
; %bb.3:
	mov	x20, x0
Lloh6:
	adrp	x8, _PE_SIGNATURE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _PE_SIGNATURE@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	add	x0, sp, #12
	bl	_le32enc
	ldr	w0, [x19, #12]
	add	x1, sp, #12
	mov	w2, #4
	bl	_write
	cmp	x0, #4
	b.ne	LBB0_5
; %bb.4:
	add	w0, w20, #4
Lloh9:
	adrp	x8, _LIBPE_F_BAD_PE_HEADER@GOTPAGE
Lloh10:
	ldr	x8, [x8, _LIBPE_F_BAD_PE_HEADER@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	ldr	w9, [x19, #8]
	bic	w8, w9, w8
Lloh12:
	adrp	x9, _LIBPE_F_DIRTY_COFF_HEADER@GOTPAGE
Lloh13:
	ldr	x9, [x9, _LIBPE_F_DIRTY_COFF_HEADER@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh15:
	adrp	x9, _LIBPE_F_DIRTY_OPT_HEADER@GOTPAGE
Lloh16:
	ldr	x9, [x9, _LIBPE_F_DIRTY_OPT_HEADER@GOTPAGEOFF]
Lloh17:
	ldr	w9, [x9]
	orr	w8, w9, w8
	str	w8, [x19, #8]
	b	LBB0_7
LBB0_5:
Lloh18:
	adrp	x8, _EIO@GOTPAGE
Lloh19:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
Lloh21:
	adrp	x9, _errno@GOTPAGE
Lloh22:
	ldr	x9, [x9, _errno@GOTPAGEOFF]
Lloh23:
	str	w8, [x9]
LBB0_6:
	mov	w0, #-1
LBB0_7:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
LBB0_8:
	ldr	x8, [x19, #16]
	cmp	x8, #0
	cset	w0, ne
	bl	_assert
	ldr	w0, [x19, #12]
	ldr	x8, [x19, #16]
	ldr	w8, [x8]
	add	w1, w8, #4
Lloh24:
	adrp	x8, _SEEK_SET@GOTPAGE
Lloh25:
	ldr	x8, [x8, _SEEK_SET@GOTPAGEOFF]
Lloh26:
	ldr	w2, [x8]
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	b	_lseek
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotStr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_PE_C_RDWR,8,3                  ; @PE_C_RDWR
	.comm	_LIBPE_F_BAD_PE_HEADER,4,2      ; @LIBPE_F_BAD_PE_HEADER
	.comm	_SEEK_SET,4,2                   ; @SEEK_SET
	.comm	_PE_SIGNATURE,4,2               ; @PE_SIGNATURE
	.comm	_EIO,4,2                        ; @EIO
	.comm	_errno,4,2                      ; @errno
	.comm	_LIBPE_F_DIRTY_COFF_HEADER,4,2  ; @LIBPE_F_DIRTY_COFF_HEADER
	.comm	_LIBPE_F_DIRTY_OPT_HEADER,4,2   ; @LIBPE_F_DIRTY_OPT_HEADER
.subsections_via_symbols
