	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_append_to_binlog_ext           ## -- Begin function append_to_binlog_ext
	.p2align	4, 0x90
_append_to_binlog_ext:                  ## @append_to_binlog_ext
	.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
	movl	%esi, %r15d
	movq	%rdi, %r14
	xorl	%edi, %edi
	testq	%r14, %r14
	je	LBB0_5
## %bb.1:
	movq	16(%r14), %rax
	testq	%rax, %rax
	je	LBB0_5
## %bb.2:
	cmpq	$0, (%rax)
	js	LBB0_5
## %bb.3:
	movq	8(%rax), %rcx
	movq	_kfs_binlog@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	jne	LBB0_5
## %bb.4:
	xorl	%edi, %edi
	cmpq	$0, 40(%rax)
	setne	%dil
LBB0_5:
	callq	_assert
	movq	16(%r14), %r13
	movq	40(%r13), %rbx
	movl	(%r14), %r12d
	testl	%r12d, %r12d
	js	LBB0_7
## %bb.6:
	movl	%r12d, %edi
	callq	_close
	shrq	$63, %rax
	xorl	$1, %eax
	movl	%eax, %edi
	callq	_assert
	movl	$-1, (%r14)
	testq	%rbx, %rbx
	jne	LBB0_8
	jmp	LBB0_12
LBB0_7:
	movl	$-1, %r12d
	testq	%rbx, %rbx
	je	LBB0_12
LBB0_8:
	movslq	(%rbx), %rcx
	movq	8(%rbx), %rax
	movq	$-1, %rbx
	movq	$-1, %rsi
	testq	%rcx, %rcx
	je	LBB0_11
## %bb.9:
	cmpq	%r13, -8(%rax,%rcx,8)
	je	LBB0_12
## %bb.10:
	decq	%rcx
	movq	%rcx, %rsi
LBB0_11:
	movq	_stderr@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	movq	16(%r13), %rdx
	movq	(%rax,%rsi,8), %rax
	movq	16(%rax), %rcx
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf
	jmp	LBB0_26
LBB0_12:
	movq	16(%r13), %rdi
	testl	%r15d, %r15d
	jne	LBB0_14
## %bb.13:
	movq	_O_WRONLY@GOTPCREL(%rip), %rax
	jmp	LBB0_15
LBB0_14:
	movq	_O_RDWR@GOTPCREL(%rip), %rax
LBB0_15:
	movl	(%rax), %esi
	callq	_open
	testl	%eax, %eax
	js	LBB0_19
## %bb.16:
	movl	%eax, %ebx
	testl	%r12d, %r12d
	jle	LBB0_21
## %bb.17:
	cmpl	%r12d, %ebx
	je	LBB0_21
## %bb.18:
	movl	%ebx, %edi
	movl	%r12d, %esi
	callq	_dup2
	xorl	%edi, %edi
	cmpl	%r12d, %eax
	sete	%dil
	callq	_assert
	movl	%ebx, %edi
	callq	_close
	jmp	LBB0_22
LBB0_19:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	16(%r13), %rdx
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_25
LBB0_21:
	movl	%ebx, %r12d
LBB0_22:
	movq	_SEEK_END@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%r12d, %edi
	xorl	%esi, %esi
	callq	_lseek
	movq	%rax, %rbx
	movslq	24(%r13), %rax
	shlq	$12, %rax
	xorl	%edi, %edi
	cmpq	%rax, %rbx
	setg	%dil
	callq	_assert
	movq	%rbx, 32(%r13)
	movl	%r12d, (%r14)
	movl	$0, 4(%r14)
	movl	24(%r13), %eax
	shll	$12, %eax
	movl	%eax, 8(%r14)
	movq	_F_WRLCK@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	%r12d, %edi
	callq	_lock_whole_file
	testq	%rax, %rax
	jle	LBB0_24
## %bb.23:
	movl	$-1, 4(%r14)
	addq	(%r13), %rbx
	movslq	8(%r14), %rax
	subq	%rax, %rbx
	jmp	LBB0_26
LBB0_24:
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	16(%r13), %rdx
	leaq	L_.str.2(%rip), %rsi
LBB0_25:
	xorl	%eax, %eax
	callq	_fprintf
	movq	$-1, %rbx
LBB0_26:
	movq	%rbx, %rax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_kfs_binlog,8,3                 ## @kfs_binlog
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cannot append to last read binlog file %s: newer binlog %s already exists\n"

	.comm	_O_RDWR,4,2                     ## @O_RDWR
	.comm	_O_WRONLY,4,2                   ## @O_WRONLY
L_.str.1:                               ## @.str.1
	.asciz	"cannot reopen binlog file %s in write mode: %m\n"

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

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_append_to_binlog_ext           ; -- Begin function append_to_binlog_ext
	.p2align	2
_append_to_binlog_ext:                  ; @append_to_binlog_ext
	.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, x1
	mov	x19, x0
	cbz	x0, LBB0_6
; %bb.1:
	ldr	x8, [x19, #16]
	cbz	x8, LBB0_5
; %bb.2:
	ldr	x9, [x8]
	tbnz	x9, #63, LBB0_5
; %bb.3:
	ldr	x9, [x8, #8]
Lloh0:
	adrp	x10, _kfs_binlog@GOTPAGE
Lloh1:
	ldr	x10, [x10, _kfs_binlog@GOTPAGEOFF]
Lloh2:
	ldr	x10, [x10]
	cmp	x9, x10
	b.ne	LBB0_5
; %bb.4:
	ldr	x8, [x8, #40]
	cmp	x8, #0
	cset	w0, ne
	b	LBB0_6
LBB0_5:
	mov	w0, #0
LBB0_6:
	bl	_assert
	ldr	x23, [x19, #16]
	ldr	x24, [x23, #40]
	ldr	w22, [x19]
	mov	w20, #-1
	tbnz	w22, #31, LBB0_8
; %bb.7:
	mov	x0, x22
	bl	_close
	lsr	x8, x0, #63
	eor	w0, w8, #0x1
	bl	_assert
	str	w20, [x19]
	mov	x20, x22
LBB0_8:
	cbz	x24, LBB0_11
; %bb.9:
	ldrsw	x9, [x24]
	ldr	x8, [x24, #8]
	cbz	w9, LBB0_15
; %bb.10:
	sub	x9, x9, #1
	ldr	x10, [x8, x9, lsl #3]
	cmp	x10, x23
	b.ne	LBB0_16
LBB0_11:
Lloh3:
	adrp	x8, _O_RDWR@GOTPAGE
Lloh4:
	ldr	x8, [x8, _O_RDWR@GOTPAGEOFF]
	ldr	x0, [x23, #16]
Lloh5:
	adrp	x9, _O_WRONLY@GOTPAGE
Lloh6:
	ldr	x9, [x9, _O_WRONLY@GOTPAGEOFF]
	cmp	w21, #0
	csel	x8, x9, x8, eq
	ldr	w1, [x8]
	bl	_open
	tbnz	w0, #31, LBB0_17
; %bb.12:
	mov	x21, x0
	cmp	w20, #1
	b.lt	LBB0_18
; %bb.13:
	cmp	w21, w20
	b.eq	LBB0_18
; %bb.14:
	mov	x0, x21
	mov	x1, x20
	bl	_dup2
	cmp	w0, w20
	cset	w0, eq
	bl	_assert
	mov	x0, x21
	bl	_close
	b	LBB0_19
LBB0_15:
	mov	x9, #-1
LBB0_16:
Lloh7:
	adrp	x10, _stderr@GOTPAGE
Lloh8:
	ldr	x10, [x10, _stderr@GOTPAGEOFF]
Lloh9:
	ldr	w0, [x10]
	ldr	x2, [x23, #16]
	ldr	x8, [x8, x9, lsl #3]
	ldr	x8, [x8, #16]
	str	x8, [sp]
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_22
LBB0_17:
Lloh12:
	adrp	x8, _stderr@GOTPAGE
Lloh13:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
	ldr	x2, [x23, #16]
Lloh15:
	adrp	x1, l_.str.1@PAGE
Lloh16:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_22
LBB0_18:
	mov	x20, x21
LBB0_19:
Lloh17:
	adrp	x8, _SEEK_END@GOTPAGE
Lloh18:
	ldr	x8, [x8, _SEEK_END@GOTPAGEOFF]
Lloh19:
	ldr	w2, [x8]
	mov	x0, x20
	mov	w1, #0
	bl	_lseek
	mov	x21, x0
	ldrsw	x8, [x23, #24]
	cmp	x0, x8, lsl #12
	cset	w0, gt
	bl	_assert
	str	x21, [x23, #32]
	stp	w20, wzr, [x19]
	ldr	w8, [x23, #24]
	lsl	w8, w8, #12
	str	w8, [x19, #8]
Lloh20:
	adrp	x8, _F_WRLCK@GOTPAGE
Lloh21:
	ldr	x8, [x8, _F_WRLCK@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_lock_whole_file
	cmp	x0, #0
	b.le	LBB0_21
; %bb.20:
	mov	w8, #-1
	str	w8, [x19, #4]
	ldr	x8, [x23]
	ldrsw	x9, [x19, #8]
	add	x8, x8, x21
	sub	x0, x8, x9
	b	LBB0_23
LBB0_21:
Lloh23:
	adrp	x8, _stderr@GOTPAGE
Lloh24:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh25:
	ldr	w0, [x8]
	ldr	x2, [x23, #16]
Lloh26:
	adrp	x1, l_.str.2@PAGE
Lloh27:
	add	x1, x1, l_.str.2@PAGEOFF
LBB0_22:
	bl	_fprintf
	mov	x0, #-1
LBB0_23:
	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 AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_kfs_binlog,8,3                 ; @kfs_binlog
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cannot append to last read binlog file %s: newer binlog %s already exists\n"

	.comm	_O_RDWR,4,2                     ; @O_RDWR
	.comm	_O_WRONLY,4,2                   ; @O_WRONLY
l_.str.1:                               ; @.str.1
	.asciz	"cannot reopen binlog file %s in write mode: %m\n"

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

.subsections_via_symbols
