// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: stbrp__skyline_pack_rectangle
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
{
   /*  find best position according to heuristic */
   stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
   stbrp_node *node, *cur;

   /*  bail if: */
   /*     1. it failed */
   /*     2. the best node doesn't fit (we don't always check this) */
   /*     3. we're out of memory */
   if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
      res.prev_link = NULL;
      return res;
   }

   /*  on success, create new node */
   node = context->free_head;
   node->x = (stbrp_coord) res.x;
   node->y = (stbrp_coord) (res.y + height);

   context->free_head = node->next;

   /*  insert the new node into the right starting point, and */
   /*  let 'cur' point to the remaining nodes needing to be */
   /*  stitched back in */

   cur = *res.prev_link;
   if (cur->x < res.x) {
      /*  preserve the existing one, so start testing with the next one */
      stbrp_node *next = cur->next;
      cur->next = node;
      cur = next;
   } else {
      *res.prev_link = node;
   }

   /*  from here, traverse cur and free the nodes, until we get to one */
   /*  that shouldn't be freed */
   while (cur->next && cur->next->x <= res.x + width) {
      stbrp_node *next = cur->next;
      /*  move the current node to the free list */
      cur->next = context->free_head;
      context->free_head = cur;
      cur = next;
   }

   /*  stitch the list back in */
   node->next = cur;

   if (cur->x < res.x + width)
      cur->x = (stbrp_coord) (res.x + width);

#ifdef _DEBUG
   cur = context->active_head;
   while (cur->x < context->width) {
      STBRP_ASSERT(cur->x < cur->next->x);
      cur = cur->next;
   }
   STBRP_ASSERT(cur->next == NULL);

   {
      int count=0;
      cur = context->active_head;
      while (cur) {
         cur = cur->next;
         ++count;
      }
      cur = context->free_head;
      while (cur) {
         cur = cur->next;
         ++count;
      }
      STBRP_ASSERT(count == context->num_nodes+2);
   }
#endif

   return res;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x30(%rsp)
movl %esi, 0x2c(%rsp)
movl %edx, 0x28(%rsp)
movq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %esi
movl 0x28(%rsp), %edx
callq 0x7de50
movq %rax, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0x3c7a3
movl 0x3c(%rsp), %eax
addl 0x28(%rsp), %eax
movq 0x30(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jg 0x3c7a3
movq 0x30(%rsp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x3c7b1
movq $0x0, 0x40(%rsp)
jmp 0x3c8e1
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x20(%rsp)
movl 0x38(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
movl 0x3c(%rsp), %ecx
addl 0x28(%rsp), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl (%rax), %eax
cmpl 0x38(%rsp), %eax
jge 0x3c82e
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3c83b
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
jmp 0x3c83d
movq 0x18(%rsp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x8(%rcx)
movb %al, 0x7(%rsp)
je 0x3c86b
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl 0x38(%rsp), %ecx
addl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
setle %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x3c875
jmp 0x3c8af
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3c83d
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl 0x38(%rsp), %ecx
addl 0x2c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x3c8df
movl 0x38(%rsp), %ecx
addl 0x2c(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
jmp 0x3c8e1
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rdx
addq $0x48, %rsp
retq