// File: rofl0r[P]ascc/util_string.cpp
// Function: AGS::Common::String::ReserveAndShift(bool, unsigned long)
void String::ReserveAndShift(bool left, size_t more_length)
{
    if (_meta)
    {
        size_t total_length = _meta->Length + more_length;
        if (_meta->Capacity < total_length)
        {
            // grow by 50% or at least to total_size
            size_t grow_length = _meta->Capacity + (_meta->Capacity >> 1);
            Copy(Math::Max(total_length, grow_length), left ? more_length : 0u);
        }
        else if (_meta->RefCount > 1)
        {
            Copy(total_length, left ? more_length : 0u);
        }
        else
        {
            // make sure we make use of all of our space
            const char *cstr_head = _data + sizeof(String::Header);
            size_t free_space = left ?
                _meta->CStr - cstr_head :
                (cstr_head + _meta->Capacity) - (_meta->CStr + _meta->Length);
            if (free_space < more_length)
            {
                Align((left ?
                    _meta->CStr + (more_length - free_space) :
                    _meta->CStr - (more_length - free_space)) - cstr_head);
            }
        }
    }
    else
    {
        Create(more_length);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, (%rax)
je 0x28369
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq 0x10(%rcx), %rcx
addq -0x18(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpq -0x20(%rbp), %rax
jae 0x28268
movq -0x40(%rbp), %rcx
movq (%rcx), %rax
movq 0x8(%rax), %rax
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
shrq %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2ada0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
testb $0x1, -0x9(%rbp)
je 0x2824a
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x28252
xorl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0x28252
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rdx
callq 0x29a20
jmp 0x28367
movq -0x40(%rbp), %rax
movq (%rax), %rax
cmpq $0x1, (%rax)
jbe 0x282ab
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
testb $0x1, -0x9(%rbp)
je 0x2828d
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x28295
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x28295
movq -0x58(%rbp), %rsi
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rdx
callq 0x29a20
jmp 0x28365
movq -0x40(%rbp), %rax
movq (%rax), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
testb $0x1, -0x9(%rbp)
je 0x282d8
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x282fc
movq -0x40(%rbp), %rdx
movq -0x30(%rbp), %rax
movq (%rdx), %rcx
addq 0x8(%rcx), %rax
movq (%rdx), %rcx
movq 0x18(%rcx), %rcx
movq (%rdx), %rdx
addq 0x10(%rdx), %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x28363
testb $0x1, -0x9(%rbp)
je 0x28330
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
subq -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
jmp 0x2834f
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rdx
subq -0x38(%rbp), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x30(%rbp), %rax
subq %rax, %rsi
callq 0x2aaf0
jmp 0x28365
jmp 0x28367
jmp 0x28376
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x29b30
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)