// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdi, %rbx
movzbl 0x17(%rdi), %eax
movl %eax, %ecx
andl $0x1f, %ecx
pushq $0x17
popq %r15
movl %r15d, %r14d
subl %ecx, %r14d
movl 0x8(%rdi), %ebp
testb %al, %al
movl %ebp, %r12d
cmovnsl %r14d, %r12d
movzbl 0x17(%rsi), %ecx
testb %cl, %cl
jns 0x5fa2
movl 0x8(%rsi), %r15d
jmp 0x5faa
movl %ecx, %edx
andl $0x1f, %edx
subl %edx, %r15d
addl %r15d, %r12d
testb %al, %al
js 0x5fdc
cmpl $0x17, %r12d
ja 0x5fff
movl %r14d, %edi
addq %rbx, %rdi
testb %cl, %cl
jns 0x5fc4
movq (%rsi), %rsi
incl %r15d
movq %r15, %rdx
callq 0x5330
movb $0x17, %al
subb %r12b, %al
movb %al, 0x17(%rbx)
jmp 0x60a5
movl 0xc(%rbx), %eax
cmpl %r12d, %eax
jbe 0x6044
movl %r12d, 0x8(%rbx)
addq (%rbx), %rbp
cmpb $0x0, 0x17(%rsi)
jns 0x5ff4
movq (%rsi), %rsi
incl %r15d
movq %rbp, %rdi
jmp 0x609d
leal 0x1(%r12), %edi
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
callq 0x5030
movq %rax, %r13
movl %r14d, %ebp
movq %rax, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x5330
movq 0x8(%rsp), %rsi
movb $-0x80, 0x17(%rbx)
movl %r12d, 0x8(%rbx)
movq 0x10(%rsp), %rax
movl %eax, 0xc(%rbx)
movq %r13, (%rbx)
addq %rbp, %r13
jmp 0x608e
movq %rsi, 0x8(%rsp)
addl %eax, %eax
leal 0x1(%r12), %edi
cmpl %r12d, %eax
cmoval %eax, %edi
movl %edi, 0xc(%rbx)
callq 0x5030
movq %rax, %r13
movq (%rbx), %r14
movq %rax, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x5330
testq %r14, %r14
je 0x607f
movq %r14, %rdi
callq 0x54b0
movl %r12d, 0x8(%rbx)
movq %r13, (%rbx)
addq %rbp, %r13
movq 0x8(%rsp), %rsi
cmpb $0x0, 0x17(%rsi)
jns 0x6097
movq (%rsi), %rsi
incl %r15d
movq %r13, %rdi
movq %r15, %rdx
callq 0x5330
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop