// File: /workspace/github_c_makefile_star2_O0/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: stbrp__skyline_find_min_y
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
{
   stbrp_node *node = first;
   int x1 = x0 + width;
   int min_y, visited_width, waste_area;

   STBRP__NOTUSED(c);

   STBRP_ASSERT(first->x <= x0);

   #if 0
   /*  skip in case we're past the node */
   while (node->next->x <= x0)
      ++node;
   #else
   STBRP_ASSERT(node->next->x > x0); /*  we ended up handling this in the caller for efficiency */
   #endif

   STBRP_ASSERT(node->x <= x0);

   min_y = 0;
   waste_area = 0;
   visited_width = 0;
   while (node->x < x1) {
      if (node->y > min_y) {
         /*  raise min_y higher. */
         /*  we've accounted for all waste up to min_y, */
         /*  but we'll now add more waste for everything we've visited */
         waste_area += visited_width * (node->y - min_y);
         min_y = node->y;
         /*  the first time through, visited_width might be reduced */
         if (node->x < x0)
            visited_width += node->next->x - x0;
         else
            visited_width += node->next->x - node->x;
      } else {
         /*  add waste area */
         int under_width = node->next->x - node->x;
         if (under_width + visited_width > width)
            under_width = width - visited_width;
         waste_area += under_width * (min_y - node->y);
         visited_width += under_width;
      }
      node = node->next;
   }

   *pwaste = waste_area;
   return min_y;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl %edx, 0x34(%rsp)
movl %ecx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x34(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x38(%rsp), %rax
movl (%rax), %eax
cmpl 0x34(%rsp), %eax
jg 0x7e270
jmp 0x7e28f
leaq 0x3359b(%rip), %rdi     # 0xb1812
leaq 0x33140(%rip), %rsi     # 0xb13be
movl $0x2b78, %edx           # imm = 0x2B78
leaq 0x33597(%rip), %rcx     # 0xb1821
callq 0x13b40
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
cmpl 0x34(%rsp), %eax
jle 0x7e2a2
jmp 0x7e2c1
leaq 0x335c6(%rip), %rdi     # 0xb186f
leaq 0x3310e(%rip), %rsi     # 0xb13be
movl $0x2b7f, %edx           # imm = 0x2B7F
leaq 0x33565(%rip), %rcx     # 0xb1821
callq 0x13b40
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl 0x34(%rsp), %eax
jg 0x7e2d0
jmp 0x7e2ef
leaq 0x335ab(%rip), %rdi     # 0xb1882
leaq 0x330e0(%rip), %rsi     # 0xb13be
movl $0x2b82, %edx           # imm = 0x2B82
leaq 0x33537(%rip), %rcx     # 0xb1821
callq 0x13b40
movl $0x0, 0x18(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl 0x1c(%rsp), %eax
jge 0x7e3f9
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
cmpl 0x18(%rsp), %eax
jle 0x7e38f
movl 0x14(%rsp), %eax
movq 0x20(%rsp), %rcx
movl 0x4(%rcx), %ecx
subl 0x18(%rsp), %ecx
imull %ecx, %eax
addl 0x10(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movl (%rax), %eax
cmpl 0x34(%rsp), %eax
jge 0x7e373
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
subl 0x34(%rsp), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x7e38d
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movq 0x20(%rsp), %rcx
subl (%rcx), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x7e3e6
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movq 0x20(%rsp), %rcx
subl (%rcx), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
addl 0x14(%rsp), %eax
cmpl 0x30(%rsp), %eax
jle 0x7e3bf
movl 0x30(%rsp), %eax
subl 0x14(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl 0x18(%rsp), %ecx
movq 0x20(%rsp), %rdx
subl 0x4(%rdx), %ecx
imull %ecx, %eax
addl 0x10(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0xc(%rsp), %eax
addl 0x14(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x7e307
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movl 0x18(%rsp), %eax
addq $0x48, %rsp
retq
nopl (%rax)