// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
testq %rsi, %rsi
je 0x6a026
movq %rsi, %rax
movq %rdi, %rbx
movl 0x50(%rdi), %esi
testl %esi, %esi
jle 0x6a045
movq %rax, -0x48(%rbp)
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rdi
movaps %xmm0, (%rdi)
callq 0x6f9e8
leaq 0x50(%rbx), %r14
leaq -0x40(%rbp), %r15
movq 0x8(%r15), %rdi
movslq (%r15), %rdx
shlq $0x4, %rdx
xorl %r13d, %r13d
xorl %esi, %esi
callq 0xc270
cmpl (%r14), %r13d
jge 0x69ee4
movq %r14, %rdi
movl %r13d, %esi
callq 0x6fb92
movzwl (%rax), %r12d
movq %r15, %rdi
movl %r13d, %esi
callq 0x6fa64
movw %r12w, 0x4(%rax)
movq %r14, %rdi
movl %r13d, %esi
callq 0x6fb92
movzwl 0x2(%rax), %r12d
movq %r15, %rdi
movl %r13d, %esi
callq 0x6fa64
movw %r12w, 0x6(%rax)
incl %r13d
jmp 0x69e9b
leaq -0x40(%rbp), %r13
xorl %r15d, %r15d
movq %r13, %rdi
xorl %esi, %esi
callq 0x6fa64
movl (%r13), %edx
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x6a078
leaq -0x40(%rbp), %r12
movq %r14, -0x50(%rbp)
cmpl -0x40(%rbp), %r15d
jge 0x69fef
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
cmpl $0x0, 0xc(%rax)
je 0x69fe7
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movzwl 0x8(%rax), %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x6fb92
movw %r13w, 0x4(%rax)
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movzwl 0xa(%rax), %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x6fb92
movw %r13w, 0x6(%rax)
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movzwl 0x4(%rax), %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x6fb92
cmpw (%rax), %r13w
jne 0x6a007
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movzwl 0x6(%rax), %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x6fb92
cmpw 0x2(%rax), %r13w
jne 0x6a007
movl 0x2c(%rbx), %r13d
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movq %rbx, %r14
movzwl 0xa(%rax), %ebx
movq %r12, %rdi
movl %r15d, %esi
callq 0x6fa64
movzwl 0x6(%rax), %eax
addl %ebx, %eax
movq %r14, %rbx
movq -0x50(%rbp), %r14
cmpl %eax, %r13d
cmovgl %r13d, %eax
movl %eax, 0x2c(%rbx)
incl %r15d
jmp 0x69f0d
leaq -0x40(%rbp), %rdi
callq 0x6fb3e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4ae6a(%rip), %rdi     # 0xb4e78
leaq 0x4a4c1(%rip), %rsi     # 0xb44d6
leaq 0x4ae0b(%rip), %rcx     # 0xb4e27
movl $0x97f, %edx            # imm = 0x97F
callq 0xc140
leaq 0x4ade3(%rip), %rdi     # 0xb4e10
leaq 0x4a4a2(%rip), %rsi     # 0xb44d6
leaq 0x4adec(%rip), %rcx     # 0xb4e27
movl $0x96c, %edx            # imm = 0x96C
callq 0xc140
leaq 0x4ae17(%rip), %rdi     # 0xb4e63
leaq 0x4a483(%rip), %rsi     # 0xb44d6
leaq 0x4adcd(%rip), %rcx     # 0xb4e27
movl $0x96f, %edx            # imm = 0x96F
callq 0xc140
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x6fb3e
movq %rbx, %rdi
callq 0xc580