// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imstb_rectpack.h
// Function: stbrp_pack_rects(stbrp_context*, stbrp_rect*, int)
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
   int i, all_rects_packed = 1;

   // we use the 'was_packed' field internally to allow sorting/unsorting
   for (i=0; i < num_rects; ++i) {
      rects[i].was_packed = i;
   }

   // sort according to heuristic
   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);

   for (i=0; i < num_rects; ++i) {
      if (rects[i].w == 0 || rects[i].h == 0) {
         rects[i].x = rects[i].y = 0;  // empty rect needs no space
      } else {
         stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
         if (fr.prev_link) {
            rects[i].x = (stbrp_coord) fr.x;
            rects[i].y = (stbrp_coord) fr.y;
         } else {
            rects[i].x = rects[i].y = STBRP__MAXVAL;
         }
      }
   }

   // unsort
   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);

   // set was_packed flags and all_rects_packed status
   for (i=0; i < num_rects; ++i) {
      rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
      if (!rects[i].was_packed)
         all_rects_packed = 0;
   }

   // return the all_rects_packed status
   return all_rects_packed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
testl %edx, %edx
jle 0x80285
movq %rdi, %r12
movl %edx, -0x38(%rbp)
movl %edx, %r14d
leaq 0xc(%rbx), %rax
xorl %ecx, %ecx
movl %ecx, (%rax)
incq %rcx
addq $0x10, %rax
cmpq %rcx, %r14
jne 0x7fef6
leaq 0x4bbc(%rip), %rcx      # 0x84ac7
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc620
cmpl $0x0, -0x38(%rbp)
jle 0x8029f
leaq 0x18(%r12), %rax
movq %rax, -0x48(%rbp)
xorl %r9d, %r9d
movq %rbx, -0x70(%rbp)
movq %r14, -0x68(%rbp)
movq %r12, -0x60(%rbp)
movq %r9, %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %r10
movzwl 0x4(%rbx,%rax), %esi
testl %esi, %esi
je 0x7ffe0
movzwl 0x6(%r10), %ecx
movq %rcx, -0x40(%rbp)
testl %ecx, %ecx
je 0x7ffe0
movl 0x8(%r12), %ecx
leal (%rsi,%rcx), %r13d
decl %r13d
movl %r13d, %eax
cltd
idivl %ecx
subl %edx, %r13d
movl %r13d, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x80302
movl (%r12), %eax
cmpl %eax, %r13d
jg 0x801f6
movq -0x40(%rbp), %rcx
cmpl %ecx, 0x4(%r12)
jl 0x801f6
movq %rsi, -0x78(%rbp)
movq %r10, -0x80(%rbp)
movq %r9, -0x88(%rbp)
movq -0x48(%rbp), %rbx
movq (%rbx), %r15
movzwl (%r15), %esi
leal (%rsi,%r13), %ecx
cmpl %eax, %ecx
jle 0x7ffed
movl 0x10(%r12), %ecx
xorl %r14d, %r14d
movl $0x40000000, -0x2c(%rbp) # imm = 0x40000000
movl $0x40000000, -0x30(%rbp) # imm = 0x40000000
xorl %eax, %eax
jmp 0x80088
movl $0x0, 0x8(%r10)
jmp 0x801fe
movl $0x40000000, -0x2c(%rbp) # imm = 0x40000000
xorl %r14d, %r14d
movl $0x40000000, -0x30(%rbp) # imm = 0x40000000
movq %r15, %rdi
movl %r13d, %edx
leaq -0x50(%rbp), %rcx
callq 0x84b11
movl 0x10(%r12), %ecx
testl %ecx, %ecx
je 0x8004a
movq -0x40(%rbp), %rdx
addl %eax, %edx
cmpl 0x4(%r12), %edx
jg 0x80059
movl -0x50(%rbp), %edx
cmpl -0x2c(%rbp), %eax
jl 0x8003f
sete %sil
cmpl -0x30(%rbp), %edx
setl %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x80059
movl %edx, -0x30(%rbp)
movl %eax, -0x2c(%rbp)
movq %rbx, %r14
jmp 0x80059
movl -0x2c(%rbp), %edx
cmpl %edx, %eax
cmovll %eax, %edx
movl %edx, -0x2c(%rbp)
cmovlq %rbx, %r14
movq %r15, %rbx
movq 0x8(%r15), %r15
addq $0x8, %rbx
movzwl (%r15), %esi
leal (%rsi,%r13), %eax
cmpl (%r12), %eax
jle 0x7fffe
testq %r14, %r14
je 0x8007f
movq (%r14), %rax
movzwl (%rax), %eax
jmp 0x80084
xorl %r14d, %r14d
xorl %eax, %eax
movq -0x48(%rbp), %rbx
movl %eax, -0x34(%rbp)
movq %r14, -0x58(%rbp)
cmpl $0x1, %ecx
jne 0x80144
movq (%rbx), %r15
movzwl (%r15), %eax
movq %r15, %r12
cmpl %eax, %r13d
jle 0x800b9
movq %r15, %r12
movq 0x8(%r12), %r12
movzwl (%r12), %eax
cmpl %eax, %r13d
ja 0x800aa
movzwl (%r12), %r14d
subl %r13d, %r14d
movq %rbx, %rax
movq %r15, %rcx
js 0x802c4
movq %rcx, %r15
movq %rax, %rbx
leaq 0x8(%rcx), %rax
movq 0x8(%rcx), %rcx
movzwl (%rcx), %edx
cmpl %edx, %r14d
jae 0x800cd
movzwl (%r15), %eax
cmpl %eax, %r14d
jb 0x802e3
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
leaq -0x4c(%rbp), %rcx
callq 0x84b11
movq -0x40(%rbp), %rcx
addl %eax, %ecx
movq -0x60(%rbp), %rdx
cmpl 0x4(%rdx), %ecx
jg 0x80136
cmpl -0x2c(%rbp), %eax
jg 0x80136
movl -0x4c(%rbp), %ecx
jb 0x80128
cmpl -0x30(%rbp), %ecx
jl 0x80128
jne 0x80136
cmpl -0x34(%rbp), %r14d
jge 0x80136
movl %ecx, -0x30(%rbp)
movl %r14d, -0x34(%rbp)
movl %eax, -0x2c(%rbp)
movq %rbx, -0x58(%rbp)
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x800b9
movq -0x58(%rbp), %r8
testq %r8, %r8
movq -0x70(%rbp), %rbx
movq -0x68(%rbp), %r14
movq -0x60(%rbp), %r12
movq -0x88(%rbp), %r9
movq -0x80(%rbp), %r10
movq -0x78(%rbp), %rdi
je 0x801f6
movq -0x40(%rbp), %rax
addl -0x2c(%rbp), %eax
cmpl 0x4(%r12), %eax
jg 0x801f6
movq 0x20(%r12), %rcx
testq %rcx, %rcx
je 0x801f6
movq %rax, %rdx
movl -0x34(%rbp), %r11d
movl %r11d, %eax
movw %r11w, (%rcx)
movw %dx, 0x2(%rcx)
movq 0x8(%rcx), %rdx
movq %rdx, 0x20(%r12)
movq (%r8), %rdx
movzwl (%rdx), %esi
cmpl %esi, %r11d
jle 0x801b8
movq 0x8(%rdx), %rsi
addq $0x8, %rdx
movq %rdx, %r8
movq %rsi, %rdx
movq %rcx, (%r8)
movq 0x8(%rdx), %r8
addl %edi, %r11d
testq %r8, %r8
je 0x8020c
leaq 0x8(%rdx), %rdi
movq %r8, %rsi
movzwl (%r8), %r8d
cmpl %r8d, %r11d
jl 0x8020c
movq 0x20(%r12), %r8
movq %r8, (%rdi)
movq %rdx, 0x20(%r12)
leaq 0x8(%rsi), %rdi
movq 0x8(%rsi), %r8
movq %rsi, %rdx
testq %r8, %r8
jne 0x801cb
jmp 0x8020f
movl $0xffffffff, 0x8(%r10)  # imm = 0xFFFFFFFF
incq %r9
cmpq %r14, %r9
jne 0x7ff3d
jmp 0x8022e
movq %rdx, %rsi
movq %rsi, 0x8(%rcx)
movzwl (%rsi), %ecx
cmpl %ecx, %r11d
jle 0x8021f
movw %r11w, (%rsi)
movw %ax, 0x8(%r10)
movl -0x2c(%rbp), %eax
movw %ax, 0xa(%r10)
jmp 0x801fe
leaq 0x48c3(%rip), %rcx      # 0x84af8
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc620
cmpl $0x0, -0x38(%rbp)
jle 0x80276
shlq $0x4, %r14
xorl %eax, %eax
movl $0x1, %ecx
cmpw $-0x1, 0x8(%rbx,%rax)
jne 0x80269
xorl %ecx, %ecx
cmpw $-0x1, 0xa(%rbx,%rax)
setne %cl
movl %ecx, 0xc(%rbx,%rax)
addq $0x10, %rax
cmpq %rax, %r14
jne 0x80251
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %edx, %r14
leaq 0x4838(%rip), %rcx      # 0x84ac7
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc620
leaq 0x4852(%rip), %rcx      # 0x84af8
movl $0x10, %edx
movq %rbx, %rdi
movq %r14, %rsi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc620
leaq 0x4df37(%rip), %rdi     # 0xce202
leaq 0x4de6c(%rip), %rsi     # 0xce13e
leaq 0x4dedf(%rip), %rcx     # 0xce1b8
movl $0x1a8, %edx            # imm = 0x1A8
callq 0xc140
leaq 0x4df22(%rip), %rdi     # 0xce20c
leaq 0x4de4d(%rip), %rsi     # 0xce13e
leaq 0x4dec0(%rip), %rcx     # 0xce1b8
movl $0x1ae, %edx            # imm = 0x1AE
callq 0xc140
leaq 0x4de99(%rip), %rdi     # 0xce1a2
leaq 0x4de2e(%rip), %rsi     # 0xce13e
leaq 0x4dea1(%rip), %rcx     # 0xce1b8
movl $0x168, %edx            # imm = 0x168
callq 0xc140