	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function buffer_encrypt_record
_buffer_encrypt_record:                 ## @buffer_encrypt_record
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	(%rdi), %r12
	movq	8(%rdi), %r13
	subq	%rsi, %r12
	leaq	-5(%r12), %r15
	movq	(%r13,%rsi,8), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	_PTLS_MAX_PLAINTEXT_RECORD_SIZE@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r15
	jbe	LBB0_1
## %bb.3:
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_4
## %bb.5:
	leaq	(,%r14,8), %rsi
	addq	%r13, %rsi
	addq	$40, %rsi
	movq	%rax, %r13
	movq	%rax, %rdi
	movq	%r15, %rdx
	callq	_memcpy
	leaq	(,%r14,8), %rdi
	addq	8(%rbx), %rdi
	movq	%r12, %rsi
	callq	_ptls_clear_memory
	movq	%r14, (%rbx)
	movq	%rbx, %rdi
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
	movq	%r13, %rdx
	movq	%r15, %rcx
	movq	-56(%rbp), %r8                  ## 8-byte Reload
	callq	_buffer_push_encrypted_records
	movl	%eax, %ebx
	movq	%r13, %rdi
	movq	%r15, %rsi
	callq	_ptls_clear_memory
	movq	%r13, %rdi
	callq	_free
	movl	%ebx, %eax
	jmp	LBB0_6
LBB0_1:
	movq	(%rdx), %rax
	movq	(%rax), %rax
	movslq	(%rax), %r13
	incq	%r13
	movq	%rbx, %rdi
	movq	%r13, %rsi
	movq	%rdx, %r12
	callq	_ptls_buffer_reserve
	testl	%eax, %eax
	jne	LBB0_6
## %bb.2:
	movq	8(%rbx), %rax
	leaq	(%rax,%r14,8), %rdx
	addq	$40, %rdx
	movq	%r12, %rdi
	movq	%rdx, %rsi
	movq	%r15, %rcx
	movq	-48(%rbp), %r8                  ## 8-byte Reload
	callq	_aead_encrypt
	movq	%rax, %r12
	addq	%r13, %r15
	xorl	%edi, %edi
	cmpq	%r15, %rax
	sete	%dil
	callq	_assert
	addq	%r13, (%rbx)
	movq	_PTLS_CONTENT_TYPE_APPDATA@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	8(%rbx), %rcx
	movq	%rax, (%rcx,%r14,8)
	movq	%r12, %rdx
	movzbl	%dh, %eax
	movq	%rax, 24(%rcx,%r14,8)
	movzbl	%dl, %eax
	movq	%rax, 32(%rcx,%r14,8)
	xorl	%eax, %eax
	jmp	LBB0_6
LBB0_4:
	movq	_PTLS_ERROR_NO_MEMORY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_6:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_PTLS_MAX_PLAINTEXT_RECORD_SIZE,8,3 ## @PTLS_MAX_PLAINTEXT_RECORD_SIZE
	.comm	_PTLS_CONTENT_TYPE_APPDATA,8,3  ## @PTLS_CONTENT_TYPE_APPDATA
	.comm	_PTLS_ERROR_NO_MEMORY,4,2       ## @PTLS_ERROR_NO_MEMORY
	.no_dead_strip	_buffer_encrypt_record
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function buffer_encrypt_record
_buffer_encrypt_record:                 ; @buffer_encrypt_record
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x21, x2
	mov	x23, x1
	mov	x19, x0
	ldp	x8, x9, [x0]
	sub	x25, x8, x1
	sub	x20, x25, #5
	add	x26, x9, x1, lsl #3
	ldr	x22, [x26]
Lloh0:
	adrp	x8, _PTLS_MAX_PLAINTEXT_RECORD_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PTLS_MAX_PLAINTEXT_RECORD_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x20, x8
	b.ls	LBB0_3
; %bb.1:
	mov	x0, x20
	bl	_malloc
	cbz	x0, LBB0_5
; %bb.2:
	mov	x24, x0
	add	x1, x26, #40
	mov	x2, x20
	bl	_memcpy
	ldr	x8, [x19, #8]
	add	x0, x8, x23, lsl #3
	mov	x1, x25
	bl	_ptls_clear_memory
	str	x23, [x19]
	mov	x0, x19
	mov	x1, x22
	mov	x2, x24
	mov	x3, x20
	mov	x4, x21
	bl	_buffer_push_encrypted_records
	mov	x19, x0
	mov	x0, x24
	mov	x1, x20
	bl	_ptls_clear_memory
	mov	x0, x24
	bl	_free
	mov	x0, x19
	b	LBB0_6
LBB0_3:
	ldr	x8, [x21]
	ldr	x8, [x8]
	ldrsw	x8, [x8]
	add	x24, x8, #1
	mov	x0, x19
	mov	x1, x24
	bl	_ptls_buffer_reserve
	cbnz	w0, LBB0_6
; %bb.4:
	ldr	x8, [x19, #8]
	lsl	x23, x23, #3
	add	x8, x8, x23
	add	x1, x8, #40
	mov	x0, x21
	mov	x2, x1
	mov	x3, x20
	mov	x4, x22
	bl	_aead_encrypt
	mov	x21, x0
	add	x8, x20, x24
	cmp	x0, x8
	cset	w0, eq
	bl	_assert
	mov	w0, #0
	ldp	x8, x9, [x19]
	add	x8, x8, x24
	str	x8, [x19]
Lloh3:
	adrp	x8, _PTLS_CONTENT_TYPE_APPDATA@GOTPAGE
Lloh4:
	ldr	x8, [x8, _PTLS_CONTENT_TYPE_APPDATA@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	add	x9, x9, x23
	str	x8, [x9]
	ubfx	x8, x21, #8, #8
	and	x10, x21, #0xff
	stp	x8, x10, [x9, #24]
	b	LBB0_6
LBB0_5:
Lloh6:
	adrp	x8, _PTLS_ERROR_NO_MEMORY@GOTPAGE
Lloh7:
	ldr	x8, [x8, _PTLS_ERROR_NO_MEMORY@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
LBB0_6:
	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
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_PTLS_MAX_PLAINTEXT_RECORD_SIZE,8,3 ; @PTLS_MAX_PLAINTEXT_RECORD_SIZE
	.comm	_PTLS_CONTENT_TYPE_APPDATA,8,3  ; @PTLS_CONTENT_TYPE_APPDATA
	.comm	_PTLS_ERROR_NO_MEMORY,4,2       ; @PTLS_ERROR_NO_MEMORY
	.no_dead_strip	_buffer_encrypt_record
.subsections_via_symbols
