// File: /workspace/github_cpp_makefile_star2_O1/ahupowerdns[P]mcounter/./ext/doctest.h
// Function: doctest::String::operator+=(doctest::String const&)
String& String::operator+=(const String& other) {
    const unsigned my_old_size = size();
    const unsigned other_size  = other.size();
    const unsigned total_size  = my_old_size + other_size;
    if(isOnStack()) {
        if(total_size < len) {
            // append to the current stack space
            memcpy(buf + my_old_size, other.c_str(), other_size + 1);
            // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
            setLast(last - total_size);
        } else {
            // alloc new chunk
            char* temp = new char[total_size + 1];
            // copy current data to new location before writing in the union
            memcpy(temp, buf, my_old_size); // skip the +1 ('\0') for speed
            // update data in union
            setOnHeap();
            data.size     = total_size;
            data.capacity = data.size + 1;
            data.ptr      = temp;
            // transfer the rest of the data
            memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
        }
    } else {
        if(data.capacity > total_size) {
            // append to the current heap block
            data.size = total_size;
            memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
        } else {
            // resize
            data.capacity *= 2;
            if(data.capacity <= total_size)
                data.capacity = total_size + 1;
            // alloc new chunk
            char* temp = new char[data.capacity];
            // copy current data to new location before releasing it
            memcpy(temp, data.ptr, my_old_size); // skip the +1 ('\0') for speed
            // release old chunk
            delete[] data.ptr;
            // update the rest of the union members
            data.size = total_size;
            data.ptr  = temp;
            // transfer the rest of the data
            memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
        }
    }

    return *this;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movzbl 0x17(%rdi), %eax
movl $0x17, %r15d
testb %al, %al
jns 0x65e4
movl 0x8(%rbx), %ebp
jmp 0x65f0
movl %eax, %ecx
andl $0x1f, %ecx
movl $0x17, %ebp
subl %ecx, %ebp
movzbl 0x17(%r14), %ecx
testb %cl, %cl
jns 0x65ff
movl 0x8(%r14), %r15d
jmp 0x6607
movl %ecx, %edx
andl $0x1f, %edx
subl %edx, %r15d
leal (%r15,%rbp), %r13d
testb %al, %al
js 0x663c
cmpl $0x17, %r13d
ja 0x665f
movl %ebp, %edi
addq %rbx, %rdi
testb %cl, %cl
jns 0x6621
movq (%r14), %r14
incl %r15d
movq %r14, %rsi
movq %r15, %rdx
callq 0x5300
movb $0x17, %al
subb %r13b, %al
movb %al, 0x17(%rbx)
jmp 0x66f4
movl 0xc(%rbx), %eax
cmpl %r13d, %eax
jbe 0x6696
movl %r13d, 0x8(%rbx)
movl %ebp, %edi
addq (%rbx), %rdi
cmpb $0x0, 0x17(%r14)
jns 0x6657
movq (%r14), %r14
incl %r15d
jmp 0x66e9
leal 0x1(%r13), %edi
movq %rdi, (%rsp)
callq 0x5030
movq %rax, %r12
movl %ebp, %ebp
movq %rax, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x5300
movb $-0x80, 0x17(%rbx)
movl %r13d, 0x8(%rbx)
movq (%rsp), %rax
movl %eax, 0xc(%rbx)
movq %r12, (%rbx)
addq %rbp, %r12
jmp 0x66d9
addl %eax, %eax
leal 0x1(%r13), %edi
cmpl %r13d, %eax
cmoval %eax, %edi
movl %edi, 0xc(%rbx)
callq 0x5030
movq %rax, %r12
movq (%rbx), %rsi
movl %ebp, %edx
movq %rax, %rdi
movq %rsi, %rbp
movq %rdx, (%rsp)
callq 0x5300
testq %rbp, %rbp
je 0x66ce
movq %rbp, %rdi
callq 0x5480
movl %r13d, 0x8(%rbx)
movq %r12, (%rbx)
addq (%rsp), %r12
cmpb $0x0, 0x17(%r14)
jns 0x66e3
movq (%r14), %r14
incl %r15d
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5300
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq