// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %r8
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %r13d
cmovgl %edx, %r13d
leaq 0xc(%rsi), %rcx
cmpq %rax, %r13
je 0x6a0b1
movl %eax, (%rcx)
incq %rax
addq $0x10, %rcx
jmp 0x6a0a1
movslq %edx, %rsi
leaq 0x3c7b(%rip), %rcx      # 0x6dd36
pushq $0x10
popq %rdx
movq %r14, %rdi
movq %rsi, -0x80(%rbp)
movq %r8, -0x48(%rbp)
callq 0xc650
movq -0x48(%rbp), %r8
leaq 0x18(%r8), %rax
movq %rax, -0x58(%rbp)
xorl %r9d, %r9d
movq %r14, -0x90(%rbp)
movq %r13, -0x88(%rbp)
cmpq %r13, %r9
je 0x6a3b7
movq %r9, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %r10
movzwl 0x4(%r14,%rax), %esi
testl %esi, %esi
je 0x6a20c
movzwl 0x6(%r10), %ecx
movq %rcx, -0x50(%rbp)
testl %ecx, %ecx
je 0x6a20c
movl 0x8(%r8), %ecx
leal (%rsi,%rcx), %r15d
decl %r15d
movl %r15d, %eax
cltd
idivl %ecx
subl %edx, %r15d
movl %r15d, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x6a44a
movl (%r8), %eax
cmpl %eax, %r15d
jg 0x6a38a
movq -0x50(%rbp), %rcx
cmpl %ecx, 0x4(%r8)
jl 0x6a38a
movq %rsi, -0x60(%rbp)
movq %r10, -0x68(%rbp)
movq %r9, -0x70(%rbp)
movq -0x58(%rbp), %rbx
movq (%rbx), %r12
movl $0x40000000, -0x34(%rbp) # imm = 0x40000000
movl $0x40000000, -0x2c(%rbp) # imm = 0x40000000
movq $0x0, -0x40(%rbp)
movzwl (%r12), %esi
leal (%r15,%rsi), %ecx
cmpl %eax, %ecx
jg 0x6a216
movq %r12, %rdi
movl %r15d, %edx
leaq -0x78(%rbp), %rcx
callq 0x6dd84
movq -0x48(%rbp), %rdi
cmpl $0x0, 0x10(%rdi)
je 0x6a1df
movq -0x50(%rbp), %rcx
addl %eax, %ecx
cmpl 0x4(%rdi), %ecx
jg 0x6a1f6
movl -0x78(%rbp), %ecx
cmpl -0x2c(%rbp), %eax
jl 0x6a1d3
sete %dl
cmpl -0x34(%rbp), %ecx
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x6a1f6
movl %ecx, -0x34(%rbp)
movl %eax, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
jmp 0x6a1f6
movl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x40(%rbp), %rax
cmovlq %rbx, %rax
movq %rax, -0x40(%rbp)
movq 0x8(%r12), %rcx
addq $0x8, %r12
movl (%rdi), %eax
movq %r12, %rbx
movq %rcx, %r12
jmp 0x6a183
andl $0x0, 0x8(%r10)
jmp 0x6a38f
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x6a22a
movq (%rdi), %rax
movzwl (%rax), %eax
movl %eax, -0x30(%rbp)
jmp 0x6a231
movl $0x0, -0x30(%rbp)
movq -0x48(%rbp), %r8
movq -0x70(%rbp), %r9
movq -0x68(%rbp), %r10
movq -0x60(%rbp), %rsi
cmpl $0x1, 0x10(%r8)
jne 0x6a316
movq -0x58(%rbp), %rax
movq (%rax), %r12
movq %r12, %rbx
movzwl (%rbx), %eax
cmpl %eax, %r15d
jle 0x6a264
movq 0x8(%rbx), %rbx
jmp 0x6a256
movq -0x58(%rbp), %r14
testq %rbx, %rbx
je 0x6a2f8
movzwl (%rbx), %r13d
subl %r15d, %r13d
movq %r14, %rax
movq %r12, %rcx
js 0x6a42b
movq %rcx, %r12
movq %rax, %r14
leaq 0x8(%rcx), %rax
movq 0x8(%rcx), %rcx
movzwl (%rcx), %edx
cmpl %edx, %r13d
jae 0x6a284
movzwl (%r12), %eax
cmpl %eax, %r13d
jb 0x6a40c
movq %r12, %rdi
movl %r13d, %esi
movl %r15d, %edx
leaq -0x74(%rbp), %rcx
callq 0x6dd84
movq -0x50(%rbp), %rcx
addl %eax, %ecx
movq -0x48(%rbp), %r8
cmpl 0x4(%r8), %ecx
jg 0x6a2ef
cmpl -0x2c(%rbp), %eax
jg 0x6a2ef
movl -0x74(%rbp), %ecx
jb 0x6a2e1
cmpl -0x34(%rbp), %ecx
jl 0x6a2e1
jne 0x6a2ef
cmpl -0x30(%rbp), %r13d
jge 0x6a2ef
movl %ecx, -0x34(%rbp)
movl %r13d, -0x30(%rbp)
movl %eax, -0x2c(%rbp)
movq %r14, -0x40(%rbp)
movq 0x8(%rbx), %rbx
jmp 0x6a268
movq -0x90(%rbp), %r14
movq -0x88(%rbp), %r13
movq -0x70(%rbp), %r9
movq -0x68(%rbp), %r10
movq -0x60(%rbp), %rsi
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x6a38a
movq -0x50(%rbp), %rax
addl -0x2c(%rbp), %eax
cmpl 0x4(%r8), %eax
jg 0x6a38a
movq %rax, %rcx
movq 0x20(%r8), %rax
testq %rax, %rax
je 0x6a38a
movl -0x30(%rbp), %r11d
movw %r11w, (%rax)
movw %cx, 0x2(%rax)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%r8)
movq (%rdi), %rcx
movzwl (%rcx), %edx
cmpl %edx, %r11d
jle 0x6a361
movq 0x8(%rcx), %rdx
addq $0x8, %rcx
movq %rcx, %rdi
movq %rdx, %rcx
movq %rax, (%rdi)
movl -0x30(%rbp), %edx
addl %esi, %edx
movq 0x8(%rcx), %rsi
testq %rsi, %rsi
je 0x6a397
movzwl (%rsi), %edi
cmpl %edi, %edx
jl 0x6a397
movq 0x20(%r8), %rdi
movq %rdi, 0x8(%rcx)
movq %rcx, 0x20(%r8)
movq %rsi, %rcx
jmp 0x6a369
orl $-0x1, 0x8(%r10)
incq %r9
jmp 0x6a0eb
movq %rcx, 0x8(%rax)
movzwl (%rcx), %eax
cmpl %eax, %edx
jle 0x6a3a5
movw %dx, (%rcx)
movl -0x30(%rbp), %eax
movw %ax, 0x8(%r10)
movl -0x2c(%rbp), %eax
movw %ax, 0xa(%r10)
jmp 0x6a38f
leaq 0x39ad(%rip), %rcx      # 0x6dd6b
pushq $0x10
popq %rdx
movq %r14, %rdi
movq -0x80(%rbp), %rsi
callq 0xc650
shlq $0x4, %r13
xorl %eax, %eax
pushq $0x1
popq %rcx
cmpq %rax, %r13
je 0x6a3fd
cmpw $-0x1, 0x8(%r14,%rax)
movl %ecx, %edx
jne 0x6a3f2
xorl %edx, %edx
cmpw $-0x1, 0xa(%r14,%rax)
setne %dl
movl %edx, 0xc(%r14,%rax)
addq $0x10, %rax
jmp 0x6a3d6
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4b129(%rip), %rdi     # 0xb553c
leaq 0x4b054(%rip), %rsi     # 0xb546e
leaq 0x4b0c7(%rip), %rcx     # 0xb54e8
movl $0x1ae, %edx            # imm = 0x1AE
callq 0xc140
leaq 0x4b100(%rip), %rdi     # 0xb5532
leaq 0x4b035(%rip), %rsi     # 0xb546e
leaq 0x4b0a8(%rip), %rcx     # 0xb54e8
movl $0x1a8, %edx            # imm = 0x1A8
callq 0xc140
leaq 0x4b081(%rip), %rdi     # 0xb54d2
leaq 0x4b016(%rip), %rsi     # 0xb546e
leaq 0x4b089(%rip), %rcx     # 0xb54e8
movl $0x168, %edx            # imm = 0x168
callq 0xc140