// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movl %edx, %r15d
movl %edx, -0x44(%rbp)
testl %edx, %edx
jle 0x81a26
leaq 0xc(%rbx), %rax
xorl %ecx, %ecx
movl %ecx, (%rax)
incq %rcx
addq $0x10, %rax
cmpq %rcx, %r15
jne 0x81a18
movl -0x44(%rbp), %r14d
movslq %r14d, %rsi
leaq 0x4ce6(%rip), %rcx      # 0x8671a
movl $0x10, %edx
movq %rbx, %rdi
movq %rsi, -0x70(%rbp)
callq 0xc620
testl %r14d, %r14d
jle 0x81d80
leaq 0x18(%r12), %rax
movq %rax, -0x88(%rbp)
xorl %r11d, %r11d
movq %r15, -0x78(%rbp)
movq %r12, -0x68(%rbp)
movq %rbx, -0x80(%rbp)
movq %r11, %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %r13
movzwl 0x4(%rbx,%rax), %eax
testl %eax, %eax
je 0x81acf
movzwl 0x6(%r13), %edx
movq %rdx, -0x58(%rbp)
testl %edx, %edx
je 0x81acf
movl 0x8(%r12), %ecx
movq %rax, -0x60(%rbp)
leal (%rax,%rcx), %r14d
decl %r14d
movl %r14d, %eax
cltd
idivl %ecx
subl %edx, %r14d
movl %r14d, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x81e14
movl (%r12), %eax
cmpl %eax, %r14d
jg 0x81ac5
movq -0x58(%rbp), %rcx
cmpl %ecx, 0x4(%r12)
jge 0x81adc
xorl %r8d, %r8d
xorl %eax, %eax
jmp 0x81caf
movl $0x0, 0x8(%r13)
jmp 0x81d4c
movq %r13, -0x90(%rbp)
movq %r11, -0x98(%rbp)
movq -0x88(%rbp), %r15
movq (%r15), %r13
movzwl (%r13), %esi
leal (%r14,%rsi), %ecx
cmpl %eax, %ecx
jle 0x81b1e
movl $0x40000000, -0x2c(%rbp) # imm = 0x40000000
movl $0x40000000, %eax       # imm = 0x40000000
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
jmp 0x81baf
movl $0x40000000, %eax       # imm = 0x40000000
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq %r15, %rbx
movl $0x40000000, -0x2c(%rbp) # imm = 0x40000000
movq %r13, %rdi
movl %r14d, %edx
leaq -0x4c(%rbp), %rcx
callq 0x86764
cmpl $0x0, 0x10(%r12)
je 0x81b7c
movq -0x58(%rbp), %rcx
addl %eax, %ecx
cmpl 0x4(%r12), %ecx
jg 0x81b95
cmpl -0x38(%rbp), %eax
jl 0x81b6c
jne 0x81b95
movl -0x2c(%rbp), %ecx
cmpl %ecx, -0x4c(%rbp)
jge 0x81b95
movl -0x4c(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
movq %rax, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
jmp 0x81b95
movq -0x38(%rbp), %rcx
cmpl %ecx, %eax
cmovll %eax, %ecx
movq %rcx, -0x38(%rbp)
movq -0x40(%rbp), %rax
cmovlq %rbx, %rax
movq %rax, -0x40(%rbp)
movq %r13, %rbx
movq 0x8(%r13), %r13
addq $0x8, %rbx
movzwl (%r13), %esi
leal (%r14,%rsi), %eax
cmpl (%r12), %eax
jle 0x81b39
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x81bc3
movq (%rax), %rax
movzwl (%rax), %eax
movl %eax, -0x30(%rbp)
jmp 0x81bca
movl $0x0, -0x30(%rbp)
cmpl $0x1, 0x10(%r12)
jne 0x81c83
movq (%r15), %r13
movzwl (%r13), %eax
movq %r13, %rbx
cmpl %eax, %r14d
jle 0x81bf5
movq %r13, %rbx
movq 0x8(%rbx), %rbx
movzwl (%rbx), %eax
cmpl %eax, %r14d
jg 0x81be9
movzwl (%rbx), %r12d
subl %r14d, %r12d
movq %r15, %rax
movq %r13, %rcx
js 0x81dd6
movq %rcx, %r13
movq %rax, %r15
leaq 0x8(%rcx), %rax
movq 0x8(%rcx), %rcx
movzwl (%rcx), %edx
cmpl %edx, %r12d
jge 0x81c08
movzwl (%r13), %eax
cmpl %eax, %r12d
jl 0x81df5
movq %r13, %rdi
movl %r12d, %esi
movl %r14d, %edx
leaq -0x48(%rbp), %rcx
callq 0x86764
movq -0x58(%rbp), %rcx
addl %eax, %ecx
movq -0x68(%rbp), %rdx
cmpl 0x4(%rdx), %ecx
jg 0x81c76
cmpl -0x38(%rbp), %eax
jg 0x81c76
jl 0x81c64
movl -0x2c(%rbp), %ecx
cmpl %ecx, -0x48(%rbp)
jl 0x81c64
jne 0x81c76
cmpl -0x30(%rbp), %r12d
jge 0x81c76
movl -0x48(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
movl %r12d, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %r15, -0x40(%rbp)
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x81bf5
movq -0x38(%rbp), %rcx
shlq $0x20, %rcx
movl -0x30(%rbp), %eax
orq %rcx, %rax
movq -0x80(%rbp), %rbx
movq -0x78(%rbp), %r15
movq -0x68(%rbp), %r12
movq -0x98(%rbp), %r11
movq -0x90(%rbp), %r13
movq -0x40(%rbp), %r8
testq %r8, %r8
je 0x81d44
movq %rax, %rcx
shrq $0x20, %rcx
movq -0x58(%rbp), %rdx
addl %ecx, %edx
cmpl 0x4(%r12), %edx
jg 0x81d44
movq %rdx, %rsi
movq 0x20(%r12), %rdx
testq %rdx, %rdx
je 0x81d44
movw %ax, (%rdx)
movw %si, 0x2(%rdx)
movq 0x8(%rdx), %rsi
movq %rsi, 0x20(%r12)
movq (%r8), %rsi
movzwl (%rsi), %edi
cmpl %eax, %edi
jge 0x81d01
movq 0x8(%rsi), %rdi
addq $0x8, %rsi
movq %rsi, %r8
movq %rdi, %rsi
movq %rdx, (%r8)
movq 0x8(%rsi), %r10
testq %r10, %r10
je 0x81d5a
leaq 0x8(%rsi), %r8
movq -0x60(%rbp), %rdi
leal (%rax,%rdi), %r9d
movq %r10, %rdi
movzwl (%r10), %r10d
cmpl %r10d, %r9d
jl 0x81d5a
movq 0x20(%r12), %r10
movq %r10, (%r8)
movq %rsi, 0x20(%r12)
leaq 0x8(%rdi), %r8
movq 0x8(%rdi), %r10
movq %rdi, %rsi
testq %r10, %r10
jne 0x81d19
jmp 0x81d5d
movl $0xffffffff, 0x8(%r13)  # imm = 0xFFFFFFFF
incq %r11
cmpq %r15, %r11
jne 0x81a69
jmp 0x81d80
movq %rsi, %rdi
movq %rdi, 0x8(%rdx)
movzwl (%rdi), %edx
movq -0x60(%rbp), %rsi
addl %eax, %esi
cmpl %edx, %esi
jle 0x81d74
movq %rsi, %rdx
movw %dx, (%rdi)
movw %ax, 0x8(%r13)
movw %cx, 0xa(%r13)
jmp 0x81d4c
leaq 0x49c4(%rip), %rcx      # 0x8674b
movl $0x10, %edx
movq %rbx, %rdi
movq -0x70(%rbp), %rsi
callq 0xc620
cmpl $0x0, -0x44(%rbp)
jle 0x81dc7
shlq $0x4, %r15
xorl %eax, %eax
movb $0x1, %cl
cmpw $-0x1, 0x8(%rbx,%rax)
jne 0x81db7
cmpw $-0x1, 0xa(%rbx,%rax)
setne %cl
movzbl %cl, %ecx
movl %ecx, 0xc(%rbx,%rax)
addq $0x10, %rax
cmpq %rax, %r15
jne 0x81da4
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e489(%rip), %rdi     # 0xd0266
leaq 0x4e3be(%rip), %rsi     # 0xd01a2
leaq 0x4e431(%rip), %rcx     # 0xd021c
movl $0x1a8, %edx            # imm = 0x1A8
callq 0xc140
leaq 0x4e474(%rip), %rdi     # 0xd0270
leaq 0x4e39f(%rip), %rsi     # 0xd01a2
leaq 0x4e412(%rip), %rcx     # 0xd021c
movl $0x1ae, %edx            # imm = 0x1AE
callq 0xc140
leaq 0x4e3eb(%rip), %rdi     # 0xd0206
leaq 0x4e380(%rip), %rsi     # 0xd01a2
leaq 0x4e3f3(%rip), %rcx     # 0xd021c
movl $0x168, %edx            # imm = 0x168
callq 0xc140