// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImFontAtlasBuildPackCustomRects(ImFontAtlas*, void*)
void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque)
{
    stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque;
    IM_ASSERT(pack_context != NULL);

    ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects;
    IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.

    ImVector<stbrp_rect> pack_rects;
    pack_rects.resize(user_rects.Size);
    memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes());
    for (int i = 0; i < user_rects.Size; i++)
    {
        pack_rects[i].w = user_rects[i].Width;
        pack_rects[i].h = user_rects[i].Height;
    }
    stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size);
    for (int i = 0; i < pack_rects.Size; i++)
        if (pack_rects[i].was_packed)
        {
            user_rects[i].X = pack_rects[i].x;
            user_rects[i].Y = pack_rects[i].y;
            IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height);
            atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h);
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x7fe71
movq %rdi, %rbx
movl 0x50(%rdi), %r14d
testl %r14d, %r14d
jle 0x7fe90
movq %rsi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
cmpl $0x9, %r14d
movl $0x8, %r13d
cmovael %r14d, %r13d
movq %r13, %rdi
shlq $0x4, %rdi
callq 0x41c63
movq %rax, %r15
movq %rax, -0x38(%rbp)
movl %r13d, -0x3c(%rbp)
movl %r14d, -0x40(%rbp)
movl %r14d, %edx
shll $0x4, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0xc260
movslq 0x50(%rbx), %rax
testq %rax, %rax
jle 0x7fd74
movq 0x58(%rbx), %rcx
movl $0x4, %edx
xorl %esi, %esi
cmpq %r14, %rsi
jae 0x7fe33
movzwl -0x8(%rcx,%rdx,2), %edi
movw %di, (%r15,%rdx)
movslq 0x50(%rbx), %rdi
cmpq %rdi, %rsi
jge 0x7fe1c
movzwl -0x6(%rcx,%rdx,2), %edi
movw %di, 0x2(%r15,%rdx)
incq %rsi
addq $0x10, %rdx
cmpq %rsi, %rax
jne 0x7fd3d
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x7fecb
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x0, 0xc(%r15,%rax)
je 0x7fdf9
movslq 0x50(%rbx), %rdx
cmpq %rdx, %rcx
jge 0x7fe1c
movzwl 0x8(%r15,%rax), %esi
movq 0x58(%rbx), %rdx
movw %si, 0x4(%rdx,%rax,2)
cmpq %r14, %rcx
jae 0x7fe33
movslq 0x50(%rbx), %rsi
cmpq %rsi, %rcx
jge 0x7fe1c
movzwl 0xa(%r15,%rax), %esi
movw %si, 0x6(%rdx,%rax,2)
movslq 0x50(%rbx), %rdi
cmpq %rdi, %rcx
jge 0x7fe1c
movzwl 0x4(%r15,%rax), %edi
cmpw (%rdx,%rax,2), %di
jne 0x7fe52
movzwl 0x6(%r15,%rax), %edi
cmpw 0x2(%rdx,%rax,2), %di
jne 0x7fe52
movzwl %si, %edx
movl 0x2c(%rbx), %esi
addl %edx, %edi
cmpl %edi, %esi
cmovgl %esi, %edi
movl %edi, 0x2c(%rbx)
incq %rcx
addq $0x10, %rax
cmpq %rcx, %r14
jne 0x7fd86
movq %r15, %rdi
callq 0x41d3c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x39855(%rip), %rdi     # 0xb9678
leaq 0x39861(%rip), %rsi     # 0xb968b
leaq 0x4eb13(%rip), %rcx     # 0xce944
jmp 0x7fe48
leaq 0x3983e(%rip), %rdi     # 0xb9678
leaq 0x3984a(%rip), %rsi     # 0xb968b
leaq 0x4eeb9(%rip), %rcx     # 0xced01
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x4dcef(%rip), %rdi     # 0xcdb48
leaq 0x4d346(%rip), %rsi     # 0xcd1a6
leaq 0x4dc90(%rip), %rcx     # 0xcdaf7
movl $0x97f, %edx            # imm = 0x97F
callq 0xc140
leaq 0x4dc68(%rip), %rdi     # 0xcdae0
leaq 0x4d327(%rip), %rsi     # 0xcd1a6
leaq 0x4dc71(%rip), %rcx     # 0xcdaf7
movl $0x96c, %edx            # imm = 0x96C
callq 0xc140
leaq 0x4dc9c(%rip), %rdi     # 0xcdb33
leaq 0x4d308(%rip), %rsi     # 0xcd1a6
leaq 0x4dc52(%rip), %rcx     # 0xcdaf7
movl $0x96f, %edx            # imm = 0x96F
callq 0xc140
movq %rax, %rdi
callq 0x39dbe
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x860b2
movq %rbx, %rdi
callq 0xc560