// File: /workspace/github_cpp_makefile_star2_O3/jliesch[P]ofxget/pugixml/pugixml.cpp
// Function: bool pugi::impl::(anonymous namespace)::strcpy_insitu<char*, unsigned long>(char*&, unsigned long&, unsigned long, char const*, unsigned long)
PUGI__FN bool strcpy_insitu(String& dest, Header& header, uintptr_t header_mask, const char_t* source, size_t source_length)
	{
		if (source_length == 0)
		{
			// empty string and null pointer are equivalent, so just deallocate old memory
			xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator;

			if (header & header_mask) alloc->deallocate_string(dest);

			// mark the string as not allocated
			dest = 0;
			header &= ~header_mask;

			return true;
		}
		else if (dest && strcpy_insitu_allow(source_length, header, header_mask, dest))
		{
			// we can reuse old buffer, so just copy the new data (including zero terminator)
			memcpy(dest, source, source_length * sizeof(char_t));
			dest[source_length] = 0;

			return true;
		}
		else
		{
			xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator;

			if (!alloc->reserve()) return false;

			// allocate new buffer
			char_t* buf = alloc->allocate_string(source_length + 1);
			if (!buf) return false;

			// copy the string (including zero terminator)
			memcpy(buf, source, source_length * sizeof(char_t));
			buf[source_length] = 0;

			// deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures)
			if (header & header_mask) alloc->deallocate_string(dest);

			// the string is now allocated, so set the flag
			dest = buf;
			header |= header_mask;

			return true;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testq %r8, %r8
je 0x1d190
movq %r8, %r12
movq (%r15), %rdi
testq %rdi, %rdi
setne %al
movq (%rbx), %rsi
testb $0x40, %sil
sete %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x1d1f9
movq %rcx, %r13
callq 0x1d379
movq (%rbx), %rsi
testq %r14, %rsi
je 0x1d1c3
movq %rax, %rdx
subq %r12, %rdx
jae 0x1d1cd
movq %r13, %rcx
jmp 0x1d1f9
movq (%rbx), %rax
testq %r14, %rax
je 0x1d1ae
shrq $0x8, %rax
negq %rax
movq (%rbx,%rax), %rdi
movq (%r15), %rsi
callq 0x2864c
movq (%rbx), %rax
movq $0x0, (%r15)
notq %r14
andq %rax, %r14
movq %r14, (%rbx)
jmp 0x1d2de
cmpq %r12, %rax
movq %r13, %rcx
jae 0x1d1de
jmp 0x1d1f9
cmpq $0x20, %rax
movq %r13, %rcx
jb 0x1d1de
shrq %rax
cmpq %rax, %rdx
jae 0x1d1f9
movq (%r15), %rdi
movq %rcx, %rsi
movq %r12, %rdx
callq 0x6090
movq (%r15), %rax
movb $0x0, (%rax,%r12)
jmp 0x1d2de
movq %r15, 0x18(%rsp)
shrq $0x8, %rsi
movq %rbx, %rax
subq %rsi, %rax
movq (%rax), %rdi
leaq 0xc(%r12), %r15
movq %r15, %rbp
andq $-0x8, %rbp
movq 0x8(%rdi), %rsi
leaq (%rsi,%rbp), %rdx
cmpq $0x7fd8, %rdx           # imm = 0x7FD8
movq %rdi, 0x10(%rsp)
ja 0x1d2ef
movq (%rdi), %rax
leaq (%rax,%rsi), %r13
addq $0x28, %r13
movq %rdx, 0x8(%rdi)
movq %r13, %rsi
subq %rax, %rsi
testb $0x7, %sil
jne 0x1d31c
addq $-0x28, %rsi
cmpq $0x80000, %rsi          # imm = 0x80000
jae 0x1d33b
movl %esi, %edx
shrl $0x3, %edx
movw %dx, (%r13)
cmpq $0x80000, %r15          # imm = 0x80000
jb 0x1d287
testq %rsi, %rsi
jne 0x1d35a
cmpq %rbp, 0x18(%rax)
jne 0x1d35a
movl %r15d, %eax
shrl $0x3, %eax
xorl %edx, %edx
cmpq $0x80000, %r15          # imm = 0x80000
cmovbl %eax, %edx
movw %dx, 0x2(%r13)
leaq 0x4(%r13), %r15
movq %r15, %rdi
movq %rcx, %rsi
movq %r12, %rdx
callq 0x6090
movb $0x0, 0x4(%r13,%r12)
movq (%rbx), %rax
testq %r14, %rax
movq 0x18(%rsp), %r12
je 0x1d2d4
movq (%r12), %rsi
movq 0x10(%rsp), %rdi
callq 0x2864c
movq (%rbx), %rax
movq %r15, (%r12)
orq %r14, %rax
movq %rax, (%rbx)
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x8(%rsp)
leaq 0x20(%rsp), %rdx
movq %rbp, %rsi
callq 0x28796
testq %rax, %rax
je 0x1d318
movq %rax, %r13
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rcx
jmp 0x1d240
xorl %eax, %eax
jmp 0x1d2e0
leaq 0x17e57(%rip), %rdi     # 0x3517a
leaq 0x14bfb(%rip), %rsi     # 0x31f25
leaq 0x17e77(%rip), %rcx     # 0x351a8
movl $0x291, %edx            # imm = 0x291
callq 0x6120
leaq 0x17eb8(%rip), %rdi     # 0x351fa
leaq 0x14bdc(%rip), %rsi     # 0x31f25
leaq 0x17e58(%rip), %rcx     # 0x351a8
movl $0x292, %edx            # imm = 0x292
callq 0x6120
leaq 0x17ee3(%rip), %rdi     # 0x35244
leaq 0x14bbd(%rip), %rsi     # 0x31f25
leaq 0x17e39(%rip), %rcx     # 0x351a8
movl $0x297, %edx            # imm = 0x297
callq 0x6120