	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_write_ctf                      ## -- Begin function write_ctf
	.p2align	4, 0x90
_write_ctf:                             ## @write_ctf
	.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
	subq	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movq	%rdx, %r12
	movq	%rsi, %r14
	movq	%rdi, -64(%rbp)                 ## 8-byte Spill
	movq	_EV_CURRENT@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_elf_version
	movq	_O_RDONLY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_open
	movl	%eax, %r15d
	testl	%eax, %eax
	js	LBB0_2
## %bb.1:
	leaq	-48(%rbp), %rsi
	movl	%r15d, %edi
	callq	_fstat
	testq	%rax, %rax
	jns	LBB0_3
LBB0_2:
	leaq	L_.str(%rip), %rdi
	movq	%r14, %rsi
	callq	_terminate
LBB0_3:
	movq	_ELF_C_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%r15d, %edi
	xorl	%edx, %edx
	callq	_elf_begin
	movq	%rax, %r13
	testq	%rax, %rax
	jne	LBB0_5
## %bb.4:
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	callq	_elfterminate
LBB0_5:
	movq	_O_RDWR@GOTPCREL(%rip), %rax
	movq	_O_CREAT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	orl	(%rax), %esi
	movq	_O_TRUNC@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	movl	-48(%rbp), %edx
	movq	%r12, %rdi
	xorl	%eax, %eax
	callq	_open
	movl	%eax, %ebx
	testl	%eax, %eax
	jns	LBB0_7
## %bb.6:
	leaq	L_.str.2(%rip), %rdi
	movq	%r12, %rsi
	callq	_terminate
LBB0_7:
	movq	%r12, -72(%rbp)                 ## 8-byte Spill
	movq	_ELF_C_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	movl	%ebx, %edi
	xorl	%edx, %edx
	callq	_elf_begin
	movq	%rax, %r12
	testq	%rax, %rax
	jne	LBB0_9
## %bb.8:
	leaq	L_.str.3(%rip), %rsi
	movq	%r14, %rdi
	callq	_elfterminate
LBB0_9:
	leaq	-88(%rbp), %rsi
	movq	%r13, %rdi
	callq	_gelf_getehdr
	testq	%rax, %rax
	movl	%r15d, -56(%rbp)                ## 4-byte Spill
	je	LBB0_12
## %bb.10:
	movq	_ELFDATA2MSB@GOTPCREL(%rip), %rax
	movq	-88(%rbp), %rcx
	movq	_EI_DATA@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movl	(%rcx,%rdx,4), %ecx
	cmpl	(%rax), %ecx
	jne	LBB0_13
## %bb.11:
	movq	_CTF_SWAP_BYTES@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	%eax, -44(%rbp)                 ## 4-byte Folded Spill
	jmp	LBB0_13
LBB0_12:
	leaq	L_.str.4(%rip), %rsi
	movq	%r14, %rdi
	callq	_elfterminate
LBB0_13:
	leaq	-80(%rbp), %rcx
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %r8d
	callq	_make_ctf_data
	movl	%eax, %r15d
	movq	-80(%rbp), %r9
	movl	%ebx, (%rsp)
	movq	%r13, %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	movl	%eax, %r8d
	callq	_write_file
	movl	%r15d, %edi
	callq	_free
	movq	%r12, %rdi
	callq	_elf_end
	movq	%r13, %rdi
	callq	_elf_end
	movl	-56(%rbp), %edi                 ## 4-byte Reload
	callq	_close
	movl	-52(%rbp), %edi                 ## 4-byte Reload
	callq	_close
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EV_CURRENT,4,2                 ## @EV_CURRENT
	.comm	_O_RDONLY,4,2                   ## @O_RDONLY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s: Cannot open for re-reading"

	.comm	_ELF_C_READ,4,2                 ## @ELF_C_READ
L_.str.1:                               ## @.str.1
	.asciz	"Cannot re-read"

	.comm	_O_RDWR,4,2                     ## @O_RDWR
	.comm	_O_CREAT,4,2                    ## @O_CREAT
	.comm	_O_TRUNC,4,2                    ## @O_TRUNC
L_.str.2:                               ## @.str.2
	.asciz	"Cannot open temp file %s for writing"

	.comm	_ELF_C_WRITE,4,2                ## @ELF_C_WRITE
L_.str.3:                               ## @.str.3
	.asciz	"Cannot write"

	.comm	_ELFDATA2MSB,4,2                ## @ELFDATA2MSB
	.comm	_EI_DATA,8,3                    ## @EI_DATA
	.comm	_CTF_SWAP_BYTES,4,2             ## @CTF_SWAP_BYTES
L_.str.4:                               ## @.str.4
	.asciz	"Failed to get EHDR"

	.comm	_ELFDATA2LSB,4,2                ## @ELFDATA2LSB
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_write_ctf                      ; -- Begin function write_ctf
	.p2align	2
_write_ctf:                             ; @write_ctf
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x3
	mov	x21, x2
	mov	x22, x1
	mov	x23, x0
Lloh0:
	adrp	x8, _EV_CURRENT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EV_CURRENT@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	bl	_elf_version
Lloh3:
	adrp	x8, _O_RDONLY@GOTPAGE
Lloh4:
	ldr	x8, [x8, _O_RDONLY@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x22
	bl	_open
	mov	x20, x0
	tbnz	w0, #31, LBB0_2
; %bb.1:
	add	x1, sp, #24
	mov	x0, x20
	bl	_fstat
	tbz	x0, #63, LBB0_3
LBB0_2:
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x22
	bl	_terminate
LBB0_3:
Lloh8:
	adrp	x8, _ELF_C_READ@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ELF_C_READ@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	x0, x20
	mov	x2, #0
	bl	_elf_begin
	mov	x24, x0
	cbnz	x0, LBB0_5
; %bb.4:
Lloh11:
	adrp	x1, l_.str.1@PAGE
Lloh12:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x22
	bl	_elfterminate
LBB0_5:
Lloh13:
	adrp	x8, _O_RDWR@GOTPAGE
Lloh14:
	ldr	x8, [x8, _O_RDWR@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
Lloh16:
	adrp	x9, _O_CREAT@GOTPAGE
Lloh17:
	ldr	x9, [x9, _O_CREAT@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh19:
	adrp	x9, _O_TRUNC@GOTPAGE
Lloh20:
	ldr	x9, [x9, _O_TRUNC@GOTPAGEOFF]
Lloh21:
	ldr	w9, [x9]
	orr	w1, w8, w9
	ldr	w8, [sp, #24]
	str	x8, [sp]
	mov	x0, x21
	bl	_open
	mov	x25, x0
	tbz	w0, #31, LBB0_7
; %bb.6:
Lloh22:
	adrp	x0, l_.str.2@PAGE
Lloh23:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x21
	bl	_terminate
LBB0_7:
Lloh24:
	adrp	x8, _ELF_C_WRITE@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ELF_C_WRITE@GOTPAGEOFF]
Lloh26:
	ldr	w1, [x8]
	mov	x0, x25
	mov	x2, #0
	bl	_elf_begin
	mov	x26, x0
	cbnz	x0, LBB0_9
; %bb.8:
Lloh27:
	adrp	x1, l_.str.3@PAGE
Lloh28:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x22
	bl	_elfterminate
LBB0_9:
	add	x1, sp, #16
	mov	x0, x24
	bl	_gelf_getehdr
	cbz	x0, LBB0_12
; %bb.10:
Lloh29:
	adrp	x8, _ELFDATA2MSB@GOTPAGE
Lloh30:
	ldr	x8, [x8, _ELFDATA2MSB@GOTPAGEOFF]
Lloh31:
	ldr	w8, [x8]
	ldr	x9, [sp, #16]
Lloh32:
	adrp	x10, _EI_DATA@GOTPAGE
Lloh33:
	ldr	x10, [x10, _EI_DATA@GOTPAGEOFF]
Lloh34:
	ldr	x10, [x10]
	ldr	w9, [x9, x10, lsl #2]
	cmp	w9, w8
	b.ne	LBB0_13
; %bb.11:
Lloh35:
	adrp	x8, _CTF_SWAP_BYTES@GOTPAGE
Lloh36:
	ldr	x8, [x8, _CTF_SWAP_BYTES@GOTPAGEOFF]
Lloh37:
	ldr	w8, [x8]
	bic	w19, w19, w8
	b	LBB0_13
LBB0_12:
Lloh38:
	adrp	x1, l_.str.4@PAGE
Lloh39:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x22
	bl	_elfterminate
LBB0_13:
	add	x3, sp, #8
	mov	x0, x23
	mov	x1, x24
	mov	x2, x22
	mov	x4, x19
	bl	_make_ctf_data
	mov	x23, x0
	ldr	x5, [sp, #8]
	mov	x0, x24
	mov	x1, x22
	mov	x2, x26
	mov	x3, x21
	mov	x4, x23
	mov	x6, x19
	bl	_write_file
	mov	x0, x23
	bl	_free
	mov	x0, x26
	bl	_elf_end
	mov	x0, x24
	bl	_elf_end
	mov	x0, x20
	bl	_close
	mov	x0, x25
	bl	_close
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpAdd	Lloh38, Lloh39
	.cfi_endproc
                                        ; -- End function
	.comm	_EV_CURRENT,4,2                 ; @EV_CURRENT
	.comm	_O_RDONLY,4,2                   ; @O_RDONLY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s: Cannot open for re-reading"

	.comm	_ELF_C_READ,4,2                 ; @ELF_C_READ
l_.str.1:                               ; @.str.1
	.asciz	"Cannot re-read"

	.comm	_O_RDWR,4,2                     ; @O_RDWR
	.comm	_O_CREAT,4,2                    ; @O_CREAT
	.comm	_O_TRUNC,4,2                    ; @O_TRUNC
l_.str.2:                               ; @.str.2
	.asciz	"Cannot open temp file %s for writing"

	.comm	_ELF_C_WRITE,4,2                ; @ELF_C_WRITE
l_.str.3:                               ; @.str.3
	.asciz	"Cannot write"

	.comm	_ELFDATA2MSB,4,2                ; @ELFDATA2MSB
	.comm	_EI_DATA,8,3                    ; @EI_DATA
	.comm	_CTF_SWAP_BYTES,4,2             ; @CTF_SWAP_BYTES
l_.str.4:                               ; @.str.4
	.asciz	"Failed to get EHDR"

	.comm	_ELFDATA2LSB,4,2                ; @ELFDATA2LSB
.subsections_via_symbols
