// File: /workspace/github_cpp_makefile_star2_O1/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 0x81997
movq %rdi, %rbx
movl 0x50(%rdi), %r15d
testl %r15d, %r15d
jle 0x819b6
movq %rsi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl %r15d, %eax
jge 0x817d9
testl %eax, %eax
je 0x8178e
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
addl %eax, %r13d
jmp 0x81794
movl $0x8, %r13d
cmpl %r15d, %r13d
cmovlel %r15d, %r13d
cmpl %r13d, %eax
jge 0x817d9
movl %r13d, %edi
shlq $0x4, %rdi
callq 0x424fb
movq %rax, %r12
movq -0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x817d1
movslq -0x40(%rbp), %rdx
shlq $0x4, %rdx
movq %r12, %rdi
callq 0xc080
movq -0x38(%rbp), %rdi
callq 0x425d4
movq %r12, -0x38(%rbp)
movl %r13d, -0x3c(%rbp)
movl %r15d, -0x40(%rbp)
movq -0x38(%rbp), %rdi
shll $0x4, %r15d
xorl %esi, %esi
movq %r15, %rdx
callq 0xc260
movslq 0x50(%rbx), %rax
testq %rax, %rax
jle 0x81851
movq 0x58(%rbx), %rcx
movl $0x4, %edx
movq -0x38(%rbp), %rsi
xorl %edi, %edi
movslq -0x40(%rbp), %r8
cmpq %r8, %rdi
jge 0x81942
movzwl -0x8(%rcx,%rdx,2), %r8d
movw %r8w, (%rsi,%rdx)
movslq 0x50(%rbx), %r8
cmpq %r8, %rdi
jge 0x81959
movslq -0x40(%rbp), %r8
cmpq %r8, %rdi
jge 0x81942
movzwl -0x6(%rcx,%rdx,2), %r8d
movw %r8w, 0x2(%rsi,%rdx)
incq %rdi
addq $0x10, %rdx
cmpq %rdi, %rax
jne 0x81807
movl -0x40(%rbp), %edx
testl %edx, %edx
jle 0x81942
movq -0x38(%rbp), %rsi
movq %r14, %rdi
callq 0x819f1
movslq -0x40(%rbp), %rax
testq %rax, %rax
jle 0x81925
movl $0xc, %ecx
movq -0x38(%rbp), %rdx
xorl %esi, %esi
cmpl $0x0, (%rdx,%rcx)
je 0x81915
movslq 0x50(%rbx), %rdi
cmpq %rdi, %rsi
jge 0x81959
movzwl -0x4(%rdx,%rcx), %r8d
movq 0x58(%rbx), %rdi
movw %r8w, -0x14(%rdi,%rcx,2)
movslq -0x40(%rbp), %r8
cmpq %r8, %rsi
jge 0x81942
movslq 0x50(%rbx), %r8
cmpq %r8, %rsi
jge 0x81959
movzwl -0x2(%rdx,%rcx), %r8d
movw %r8w, -0x12(%rdi,%rcx,2)
movslq -0x40(%rbp), %r9
cmpq %r9, %rsi
jge 0x81942
movslq 0x50(%rbx), %r9
cmpq %r9, %rsi
jge 0x81959
movzwl -0x8(%rdx,%rcx), %r9d
cmpw -0x18(%rdi,%rcx,2), %r9w
jne 0x81978
movzwl -0x6(%rdx,%rcx), %r9d
cmpw -0x16(%rdi,%rcx,2), %r9w
jne 0x81978
movzwl %r8w, %edi
movl 0x2c(%rbx), %r8d
addl %edi, %r9d
cmpl %r9d, %r8d
cmovgl %r8d, %r9d
movl %r9d, 0x2c(%rbx)
incq %rsi
addq $0x10, %rcx
cmpq %rsi, %rax
jne 0x81880
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x81933
callq 0x425d4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x39d2f(%rip), %rdi     # 0xbb678
leaq 0x39d3b(%rip), %rsi     # 0xbb68b
leaq 0x4f3e1(%rip), %rcx     # 0xd0d38
jmp 0x8196e
leaq 0x39d18(%rip), %rdi     # 0xbb678
leaq 0x39d24(%rip), %rsi     # 0xbb68b
leaq 0x4f03a(%rip), %rcx     # 0xd09a8
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x4e1f9(%rip), %rdi     # 0xcfb78
leaq 0x4d850(%rip), %rsi     # 0xcf1d6
leaq 0x4e19a(%rip), %rcx     # 0xcfb27
movl $0x97f, %edx            # imm = 0x97F
callq 0xc140
leaq 0x4e172(%rip), %rdi     # 0xcfb10
leaq 0x4d831(%rip), %rsi     # 0xcf1d6
leaq 0x4e17b(%rip), %rcx     # 0xcfb27
movl $0x96c, %edx            # imm = 0x96C
callq 0xc140
leaq 0x4e1a6(%rip), %rdi     # 0xcfb63
leaq 0x4d812(%rip), %rsi     # 0xcf1d6
leaq 0x4e15c(%rip), %rcx     # 0xcfb27
movl $0x96f, %edx            # imm = 0x96F
callq 0xc140
movq %rax, %rdi
callq 0x3a5b4
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x87db2
movq %rbx, %rdi
callq 0xc560