// File: donfreiday[P]gb/./imgui/stb_rect_pack.h
// Function: stbrp_pack_rects(stbrp_context*, stbrp_rect*, int)
STBRP_DEF void stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
   int i;

   // we use the 'was_packed' field internally to allow sorting/unsorting
   for (i=0; i < num_rects; ++i) {
      rects[i].was_packed = i;
      #ifndef STBRP_LARGE_RECTS
      STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff);
      #endif
   }

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

   for (i=0; i < num_rects; ++i) {
      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
   qsort(rects, num_rects, sizeof(rects[0]), rect_original_order);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x448a3
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %ecx
xorl %eax, %eax
cmpl $0xffff, %ecx           # imm = 0xFFFF
movb %al, -0x29(%rbp)
jg 0x44869
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
setle %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x44872
jmp 0x44874
jmp 0x44893
leaq 0x20253(%rip), %rdi     # 0x64ace
leaq 0x20163(%rip), %rsi     # 0x649e5
movl $0x20b, %edx            # imm = 0x20B
leaq 0x2026d(%rip), %rcx     # 0x64afb
callq 0x7160
jmp 0x44895
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4480a
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rsi
movl $0x10, %edx
leaq 0x1e29(%rip), %rcx      # 0x466e0
callq 0x7560
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4497b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %esi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x6(%rax), %edx
callq 0x46780
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x44941
movl -0x28(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movw %cx, 0x8(%rax)
movl -0x24(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movw %cx, 0xa(%rax)
jmp 0x4496b
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw $0xffff, 0xa(%rax)      # imm = 0xFFFF
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw $0xffff, 0x8(%rax)      # imm = 0xFFFF
jmp 0x4496d
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x448c3
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rsi
movl $0x10, %edx
leaq 0x1f71(%rip), %rcx      # 0x46900
callq 0x7560
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x44a08
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x8(%rax), %ecx
xorl %eax, %eax
cmpl $0xffff, %ecx           # imm = 0xFFFF
movb %al, -0x2a(%rbp)
jne 0x449e1
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0xa(%rax), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
sete %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4499b
addq $0x30, %rsp
popq %rbp
retq
nop