// File: Alcaro[P]bridges/arlib/string.cpp
// Function: string::append(arrayview<unsigned char>)
void string::append(arrayview<uint8_t> newdat)
{
	// cache these four, for performance
	uint8_t* p1 = ptr();
	const uint8_t* p2 = newdat.ptr();
	uint32_t l1 = length();
	uint32_t l2 = newdat.size();
	
	if (UNLIKELY(p2 >= p1 && p2 < p1+l1))
	{
		uint32_t offset = p2-p1;
		resize(l1+l2);
		p1 = ptr();
		memcpy(p1+l1, p1+offset, l2);
	}
	else
	{
		resize(l1+l2);
		memcpy(ptr()+l1, p2, l2);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rsi, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
movq %rdi, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x37517
movq -0xc0(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x37525
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x62c0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0xa8(%rbp)
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x37593
movq -0xd0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
jmp 0x375a0
movq -0xd0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xac(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x6290
movl %eax, -0xb0(%rbp)
movq -0xa8(%rbp), %rcx
xorl %eax, %eax
cmpq -0xa0(%rbp), %rcx
movb %al, -0xd1(%rbp)
jb 0x375f6
movq -0xa8(%rbp), %rax
movq -0xa0(%rbp), %rcx
movl -0xac(%rbp), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0xd1(%rbp)
movb -0xd1(%rbp), %al
xorb $-0x1, %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x37609
jmp 0x376c7
movq -0xc8(%rbp), %rdi
movq -0xa8(%rbp), %rax
movq -0xa0(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xb4(%rbp)
movl -0xac(%rbp), %eax
addl -0xb0(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x36d20
movq -0xc8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x3767c
movq -0xe0(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3768a
movq -0xe0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movl -0xac(%rbp), %eax
addq %rax, %rdi
movq -0xa0(%rbp), %rsi
movl -0xb4(%rbp), %eax
addq %rax, %rsi
movl -0xb0(%rbp), %eax
movl %eax, %edx
callq 0x4280
jmp 0x37752
movq -0xc8(%rbp), %rdi
movl -0xac(%rbp), %eax
addl -0xb0(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x36d20
movq -0xc8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x37723
movq -0xe8(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x37731
movq -0xe8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0xac(%rbp), %eax
addq %rax, %rdi
movq -0xa8(%rbp), %rsi
movl -0xb0(%rbp), %eax
movl %eax, %edx
callq 0x4280
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)