// File: /workspace/github_cpp_makefile_star2_O1/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 $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testq %r8, %r8
je 0x1d0c8
movq %r8, %r12
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1d11f
testb $0x40, (%r15)
jne 0x1d11f
movq %rcx, %r13
callq 0x1d2a2
testq %r14, (%r15)
je 0x1d0f7
movq %rax, %rdx
subq %r12, %rdx
movq %r13, %rcx
jb 0x1d11f
cmpq $0x20, %rax
jb 0x1d104
shrq %rax
cmpq %rax, %rdx
setb %al
jmp 0x1d100
movq (%r15), %rax
testq %r14, %rax
je 0x1d0e5
shrq $0x8, %rax
movq %r15, %rcx
subq %rax, %rcx
movq (%rcx), %rdi
movq (%rbx), %rsi
callq 0x2893a
movq $0x0, (%rbx)
notq %r14
andq %r14, (%r15)
jmp 0x1d218
cmpq %r12, %rax
setae %al
movq %r13, %rcx
testb %al, %al
je 0x1d11f
movq (%rbx), %rdi
movq %rcx, %rsi
movq %r12, %rdx
callq 0x6090
movq (%rbx), %rax
movb $0x0, (%rax,%r12)
jmp 0x1d218
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq (%r15), %rax
shrq $0x8, %rax
negq %rax
movq (%r15,%rax), %rbp
leaq 0xc(%r12), %r14
movq %r14, %rbx
andq $-0x8, %rbx
movq 0x8(%rbp), %rax
leaq (%rax,%rbx), %rsi
cmpq $0x7fd9, %rsi           # imm = 0x7FD9
jae 0x1d229
movq (%rbp), %rdx
leaq (%rdx,%rax), %r13
addq $0x28, %r13
movq %rsi, 0x8(%rbp)
movq %rdx, (%rsp)
testq %r13, %r13
je 0x1d1d9
movq (%rsp), %rax
movq %r13, %rsi
subq %rax, %rsi
testb $0x7, %sil
jne 0x1d245
addq $-0x28, %rsi
cmpq $0x80000, %rsi          # imm = 0x80000
jae 0x1d264
movl %esi, %edx
shrl $0x3, %edx
movw %dx, (%r13)
cmpq $0x80000, %r14          # imm = 0x80000
jb 0x1d1bc
testq %rsi, %rsi
jne 0x1d283
cmpq %rbx, 0x18(%rax)
jne 0x1d283
movl %r14d, %eax
shrl $0x3, %eax
xorl %edx, %edx
cmpq $0x80000, %r14          # imm = 0x80000
cmovbl %eax, %edx
movw %dx, 0x2(%r13)
addq $0x4, %r13
jmp 0x1d1dc
xorl %r13d, %r13d
testq %r13, %r13
setne %al
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r14
je 0x1d21a
movq %r13, %rdi
movq %rcx, %rsi
movq %r12, %rdx
callq 0x6090
movb $0x0, (%r13,%r12)
testq %r14, (%r15)
je 0x1d212
movq (%rbx), %rsi
movq %rbp, %rdi
callq 0x2893a
movq %r13, (%rbx)
orq %r14, (%r15)
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdx
movq %rbp, %rdi
movq %rbx, %rsi
movq %rcx, %r13
callq 0x28a84
movq %r13, %rcx
movq %rax, %r13
jmp 0x1d16c
leaq 0x190d8(%rip), %rdi     # 0x36324
leaq 0x15ca2(%rip), %rsi     # 0x32ef5
leaq 0x190f8(%rip), %rcx     # 0x36352
movl $0x291, %edx            # imm = 0x291
callq 0x6120
leaq 0x19139(%rip), %rdi     # 0x363a4
leaq 0x15c83(%rip), %rsi     # 0x32ef5
leaq 0x190d9(%rip), %rcx     # 0x36352
movl $0x292, %edx            # imm = 0x292
callq 0x6120
leaq 0x19164(%rip), %rdi     # 0x363ee
leaq 0x15c64(%rip), %rsi     # 0x32ef5
leaq 0x190ba(%rip), %rcx     # 0x36352
movl $0x297, %edx            # imm = 0x297
callq 0x6120