	.file	"extr_xlog.c_ReserveXLogSwitch.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	ReserveXLogSwitch, @function
ReserveXLogSwitch:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, rsi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	sub	rsp, 40
	.cfi_def_cfa_offset 96
	mov	r12, QWORD PTR XLogCtl[rip]
	mov	QWORD PTR 8[rsp], rdi
	mov	edi, DWORD PTR SizeOfXLogRecord[rip]
	lea	r14, 16[r12]
	mov	QWORD PTR 16[rsp], rdx
	call	MAXALIGN@PLT
	mov	rdi, r14
	mov	rbx, rax
	call	SpinLockAcquire@PLT
	mov	r15, QWORD PTR [r12]
	mov	rdi, r15
	call	XLogBytePosToEndRecPtr@PLT
	mov	rsi, QWORD PTR wal_segment_size[rip]
	mov	edi, eax
	mov	r13d, eax
	call	XLogSegmentOffset@PLT
	test	rax, rax
	je	.L7
	mov	rdi, r15
	mov	r13, QWORD PTR 8[r12]
	add	rbx, r15
	call	XLogBytePosToRecPtr@PLT
	mov	rdx, QWORD PTR 8[rsp]
	mov	rdi, rbx
	mov	DWORD PTR [rdx], eax
	call	XLogBytePosToEndRecPtr@PLT
	mov	rcx, QWORD PTR wal_segment_size[rip]
	mov	DWORD PTR 0[rbp], eax
	mov	edi, eax
	mov	rsi, rcx
	mov	QWORD PTR 24[rsp], rcx
	call	XLogSegmentOffset@PLT
	mov	rcx, QWORD PTR 24[rsp]
	sub	rcx, rax
	cmp	QWORD PTR wal_segment_size[rip], rcx
	jne	.L8
.L4:
	mov	QWORD PTR [r12], rbx
	mov	rdi, r14
	mov	QWORD PTR 8[r12], r15
	call	SpinLockRelease@PLT
	mov	rdi, r13
	call	XLogBytePosToRecPtr@PLT
	mov	r14, QWORD PTR 16[rsp]
	mov	rsi, QWORD PTR wal_segment_size[rip]
	mov	DWORD PTR [r14], eax
	mov	edi, DWORD PTR 0[rbp]
	call	XLogSegmentOffset@PLT
	xor	edi, edi
	test	rax, rax
	sete	dil
	call	Assert@PLT
	mov	edi, DWORD PTR 0[rbp]
	call	XLogRecPtrToBytePos@PLT
	xor	edi, edi
	cmp	rax, rbx
	sete	dil
	call	Assert@PLT
	mov	rax, QWORD PTR 8[rsp]
	mov	edi, DWORD PTR [rax]
	call	XLogRecPtrToBytePos@PLT
	xor	edi, edi
	cmp	rax, r15
	sete	dil
	call	Assert@PLT
	mov	edi, DWORD PTR [r14]
	call	XLogRecPtrToBytePos@PLT
	xor	edi, edi
	cmp	rax, r13
	sete	dil
	call	Assert@PLT
	add	rsp, 40
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	mov	eax, 1
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	mov	edi, DWORD PTR 0[rbp]
	add	edi, ecx
	mov	DWORD PTR 0[rbp], edi
	call	XLogRecPtrToBytePos@PLT
	mov	rbx, rax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L7:
	mov	rdi, r14
	call	SpinLockRelease@PLT
	mov	rax, QWORD PTR 8[rsp]
	mov	DWORD PTR [rax], r13d
	xor	eax, eax
	mov	DWORD PTR 0[rbp], r13d
	add	rsp, 40
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE0:
	.size	ReserveXLogSwitch, .-ReserveXLogSwitch
	.comm	wal_segment_size,8,8
	.comm	XLogCtl,8,8
	.comm	SizeOfXLogRecord,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_xlog.c_ReserveXLogSwitch.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	ReserveXLogSwitch, %function
ReserveXLogSwitch:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	mov	r7, r0
	ldr	r0, .L9
	ldr	r3, .L9+4
	sub	sp, sp, #12
	ldr	r0, [r0]
	ldr	r6, [r3]
	str	r2, [sp, #4]
	mov	r5, r1
	str	r7, [sp]
	bl	MAXALIGN
	add	r7, r6, #8
	mov	r4, r0
	mov	r0, r7
	bl	SpinLockAcquire
	ldr	r8, [r6]
	ldr	r10, .L9+8
	mov	r0, r8
	bl	XLogBytePosToEndRecPtr
	ldr	r1, [r10]
	mov	fp, r0
	bl	XLogSegmentOffset
	subs	r2, r0, #0
	beq	.L7
	mov	r0, r8
	ldr	fp, [r6, #4]
	bl	XLogBytePosToRecPtr
	ldr	r3, [sp]
	add	r9, r4, r8
	str	r0, [r3]
	mov	r0, r9
	bl	XLogBytePosToEndRecPtr
	ldr	r4, [r10]
	str	r0, [r5]
	mov	r1, r4
	bl	XLogSegmentOffset
	ldr	ip, [r10]
	sub	r4, r4, r0
	cmp	ip, r4
	bne	.L8
.L4:
	mov	r0, r7
	str	r9, [r6]
	str	r8, [r6, #4]
	bl	SpinLockRelease
	mov	r0, fp
	bl	XLogBytePosToRecPtr
	ldr	r4, [sp, #4]
	ldr	r1, [r10]
	str	r0, [r4]
	ldr	r0, [r5]
	bl	XLogSegmentOffset
	clz	r0, r0
	lsr	r0, r0, #5
	bl	Assert
	ldr	r0, [r5]
	bl	XLogRecPtrToBytePos
	sub	r0, r0, r9
	clz	r0, r0
	lsr	r0, r0, #5
	bl	Assert
	ldr	r3, [sp]
	ldr	r0, [r3]
	bl	XLogRecPtrToBytePos
	sub	r0, r0, r8
	clz	r0, r0
	lsr	r0, r0, #5
	bl	Assert
	ldr	r0, [r4]
	bl	XLogRecPtrToBytePos
	sub	r0, r0, fp
	clz	r0, r0
	lsr	r0, r0, #5
	bl	Assert
	mov	r2, #1
	mov	r0, r2
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L8:
	ldr	r0, [r5]
	add	r0, r4, r0
	str	r0, [r5]
	bl	XLogRecPtrToBytePos
	mov	r9, r0
	b	.L4
.L7:
	mov	r0, r7
	str	r2, [sp, #4]
	bl	SpinLockRelease
	ldr	r2, [sp, #4]
	ldr	r3, [sp]
	mov	r0, r2
	str	fp, [r3]
	str	fp, [r5]
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L10:
	.align	2
.L9:
	.word	SizeOfXLogRecord
	.word	XLogCtl
	.word	wal_segment_size
	.size	ReserveXLogSwitch, .-ReserveXLogSwitch
	.comm	wal_segment_size,4,4
	.comm	XLogCtl,4,4
	.comm	SizeOfXLogRecord,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
