// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_buffer_realloc
NK_LIB void*
nk_buffer_realloc(struct nk_buffer *b, nk_size capacity, nk_size *size)
{
    void *temp;
    nk_size buffer_size;

    NK_ASSERT(b);
    NK_ASSERT(size);
    if (!b || !size || !b->pool.alloc || !b->pool.free)
        return 0;

    buffer_size = b->memory.size;
    temp = b->pool.alloc(b->pool.userdata, b->memory.ptr, capacity);
    NK_ASSERT(temp);
    if (!temp) return 0;

    *size = capacity;
    if (temp != b->memory.ptr) {
        NK_MEMCPY(temp, b->memory.ptr, buffer_size);
        b->pool.free(b->pool.userdata, b->memory.ptr);
    }

    if (b->size == buffer_size) {
        /* no back buffer so just set correct size */
        b->size = capacity;
        return temp;
    } else {
        /* copy back buffer to the end of the new buffer */
        void *dst, *src;
        nk_size back_size;
        back_size = buffer_size - b->size;
        dst = nk_ptr_add(void, temp, capacity - back_size);
        src = nk_ptr_add(void, temp, b->size);
        NK_MEMCPY(dst, src, back_size);
        b->size = capacity - back_size;
    }
    return temp;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x7cc9e
movq 0x4837e(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x34724(%rip), %rsi     # 0xb13a0
leaq 0x3473b(%rip), %rdx     # 0xb13be
movl $0x2074, %ecx           # imm = 0x2074
movb $0x0, %al
callq 0x13ec0
movq 0x4835a(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x7cca0
jmp 0x7cca2
cmpq $0x0, 0x28(%rsp)
jne 0x7ccdd
movq 0x4833f(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x346e5(%rip), %rsi     # 0xb13a0
leaq 0x346fc(%rip), %rdx     # 0xb13be
movl $0x2075, %ecx           # imm = 0x2075
movb $0x0, %al
callq 0x13ec0
movq 0x4831b(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x7ccdf
cmpq $0x0, 0x38(%rsp)
je 0x7cd07
cmpq $0x0, 0x28(%rsp)
je 0x7cd07
movq 0x38(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x7cd07
movq 0x38(%rsp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x7cd15
movq $0x0, 0x40(%rsp)
jmp 0x7ce83
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x40(%rdx), %rsi
movq 0x30(%rsp), %rdx
movq 0x20(%rcx), %rdi
callq *%rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x7cd85
movq 0x48297(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
leaq 0x3463d(%rip), %rsi     # 0xb13a0
leaq 0x34654(%rip), %rdx     # 0xb13be
movl $0x207b, %ecx           # imm = 0x207B
movb $0x0, %al
callq 0x13ec0
movq 0x48273(%rip), %rax     # 0xc4ff0
movq (%rax), %rdi
callq 0x149a0
jmp 0x7cd87
cmpq $0x0, 0x20(%rsp)
jne 0x7cd9d
movq $0x0, 0x40(%rsp)
jmp 0x7ce83
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq 0x40(%rcx), %rax
je 0x7cdef
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x40(%rax), %rsi
movq 0x18(%rsp), %rdx
callq 0x2f750
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x40(%rdx), %rsi
movq 0x20(%rcx), %rdi
callq *%rax
movq 0x38(%rsp), %rax
movq 0x70(%rax), %rax
cmpq 0x18(%rsp), %rax
jne 0x7ce19
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x7ce83
movq 0x18(%rsp), %rax
movq 0x38(%rsp), %rcx
subq 0x70(%rcx), %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
subq (%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x38(%rsp), %rcx
addq 0x70(%rcx), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
callq 0x2f750
movq 0x30(%rsp), %rcx
subq (%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopl (%rax)