// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt__rasterize_sorted_edges
static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
{
   stbtt__hheap hh = { 0, 0, 0 };
   stbtt__active_edge *active = NULL;
   int y,j=0, i;
   float scanline_data[129], *scanline, *scanline2;

   STBTT__NOTUSED(vsubsample);

   if (result->w > 64)
      scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata);
   else
      scanline = scanline_data;

   scanline2 = scanline + result->w;

   y = off_y;
   e[n].y0 = (float) (off_y + result->h) + 1;

   while (j < result->h) {
      // find center of pixel for this scanline
      float scan_y_top    = y + 0.0f;
      float scan_y_bottom = y + 1.0f;
      stbtt__active_edge **step = &active;

      STBTT_memset(scanline , 0, result->w*sizeof(scanline[0]));
      STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0]));

      // update all active edges;
      // remove all active edges that terminate before the top of this scanline
      while (*step) {
         stbtt__active_edge * z = *step;
         if (z->ey <= scan_y_top) {
            *step = z->next; // delete from list
            STBTT_assert(z->direction);
            z->direction = 0;
            stbtt__hheap_free(&hh, z);
         } else {
            step = &((*step)->next); // advance through list
         }
      }

      // insert all edges that start before the bottom of this scanline
      while (e->y0 <= scan_y_bottom) {
         if (e->y0 != e->y1) {
            stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
            if (z != NULL) {
               if (j == 0 && off_y != 0) {
                  if (z->ey < scan_y_top) {
                     // this can happen due to subpixel positioning and some kind of fp rounding error i think
                     z->ey = scan_y_top;
                  }
               }
               STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds
               // insert at front
               z->next = active;
               active = z;
            }
         }
         ++e;
      }

      // now process all active edges
      if (active)
         stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);

      {
         float sum = 0;
         for (i=0; i < result->w; ++i) {
            float k;
            int m;
            sum += scanline2[i];
            k = scanline[i] + sum;
            k = (float) STBTT_fabs(k)*255 + 0.5f;
            m = (int) k;
            if (m > 255) m = 255;
            result->pixels[j*result->stride + i] = (unsigned char) m;
         }
      }
      // advance all the edges
      step = &active;
      while (*step) {
         stbtt__active_edge *z = *step;
         z->fx += z->fdx; // advance to position for current scanline
         step = &((*step)->next); // advance through list
      }

      ++y;
      ++j;
   }

   stbtt__hheap_cleanup(&hh, userdata);

   if (scanline != scanline_data)
      STBTT_free(scanline, userdata);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x10b0
movq $0x0, -0x40(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x40, (%rax)
jle 0x1194d
movq -0x8(%rbp), %rax
movl (%rax), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x1140
movq %rax, -0x258(%rbp)
jmp 0x1195b
leaq -0x250(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x260(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x4(%rcx), %eax
cvtsi2ss %eax, %xmm0
movss 0x4c89(%rip), %xmm1     # 0x1661c
addss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movl -0x48(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x11d7f
cvtsi2ssl -0x44(%rbp), %xmm0
xorps %xmm1, %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x264(%rbp)
cvtsi2ssl -0x44(%rbp), %xmm0
movss 0x4c40(%rip), %xmm1     # 0x1661c
addss %xmm1, %xmm0
movss %xmm0, -0x268(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x258(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq (%rax), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x10b0
movq -0x260(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x10b0
movq -0x270(%rbp), %rax
cmpq $0x0, (%rax)
je 0x11ae9
movq -0x270(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
movss 0x1c(%rax), %xmm1
movss -0x264(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x11ad3
movq -0x278(%rbp), %rax
movq (%rax), %rcx
movq -0x270(%rbp), %rax
movq %rcx, (%rax)
movq -0x278(%rbp), %rax
movss 0x14(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x11a91
jp 0x11a91
jmp 0x11a93
jmp 0x11ab2
leaq 0x561d(%rip), %rdi      # 0x170b7
leaq 0x4d16(%rip), %rsi      # 0x167b7
movl $0xc4e, %edx            # imm = 0xC4E
leaq 0x5617(%rip), %rcx      # 0x170c4
callq 0x10a0
movq -0x278(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x14(%rax)
movq -0x278(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x12220
jmp 0x11ae4
movq -0x270(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x270(%rbp)
jmp 0x11a2a
jmp 0x11aeb
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm1
movss -0x268(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x11bed
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0xc(%rax), %xmm0
jne 0x11b1f
jp 0x11b1f
jmp 0x11bdc
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movss -0x264(%rbp), %xmm0
movq 0x10(%rbp), %rcx
leaq -0x38(%rbp), %rdi
callq 0x12250
movq %rax, -0x280(%rbp)
cmpq $0x0, -0x280(%rbp)
je 0x11bda
cmpl $0x0, -0x48(%rbp)
jne 0x11b8b
cmpl $0x0, -0x20(%rbp)
je 0x11b8b
movq -0x280(%rbp), %rax
movss 0x1c(%rax), %xmm1
movss -0x264(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x11b89
movss -0x264(%rbp), %xmm0
movq -0x280(%rbp), %rax
movss %xmm0, 0x1c(%rax)
jmp 0x11b8b
movq -0x280(%rbp), %rax
movss 0x1c(%rax), %xmm0
ucomiss -0x264(%rbp), %xmm0
jb 0x11ba2
jmp 0x11bc1
leaq 0x557a(%rip), %rdi      # 0x17123
leaq 0x4c07(%rip), %rsi      # 0x167b7
movl $0xc61, %edx            # imm = 0xC61
leaq 0x5508(%rip), %rcx      # 0x170c4
callq 0x10a0
movq -0x40(%rbp), %rcx
movq -0x280(%rbp), %rax
movq %rcx, (%rax)
movq -0x280(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x11bdc
movq -0x10(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x10(%rbp)
jmp 0x11aeb
cmpq $0x0, -0x40(%rbp)
je 0x11c1d
movq -0x258(%rbp), %rdi
movq -0x260(%rbp), %rsi
addq $0x4, %rsi
movq -0x8(%rbp), %rax
movl (%rax), %edx
movq -0x40(%rbp), %rcx
movss -0x264(%rbp), %xmm0
callq 0x12400
xorps %xmm0, %xmm0
movss %xmm0, -0x284(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x11d0f
movq -0x260(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x284(%rbp), %xmm0
movss %xmm0, -0x284(%rbp)
movq -0x258(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x284(%rbp), %xmm0
movss %xmm0, -0x288(%rbp)
movss -0x288(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movaps 0x49ef(%rip), %xmm1     # 0x16680
pand %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss 0x4993(%rip), %xmm1     # 0x16634
mulss %xmm1, %xmm0
movss 0x494f(%rip), %xmm1     # 0x165fc
addss %xmm1, %xmm0
movss %xmm0, -0x288(%rbp)
cvttss2si -0x288(%rbp), %eax
movl %eax, -0x28c(%rbp)
cmpl $0xff, -0x28c(%rbp)
jle 0x11cdd
movl $0xff, -0x28c(%rbp)
movl -0x28c(%rbp), %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x48(%rbp), %ecx
movq -0x8(%rbp), %rsi
imull 0x8(%rsi), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x11c2f
leaq -0x40(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rax
cmpq $0x0, (%rax)
je 0x11d68
movq -0x270(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x298(%rbp), %rax
addss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rax)
movq -0x270(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x270(%rbp)
jmp 0x11d1a
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x119ab
movq 0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x12ec0
movq -0x258(%rbp), %rax
leaq -0x250(%rbp), %rcx
cmpq %rcx, %rax
je 0x11dab
movq -0x258(%rbp), %rdi
callq 0x1030
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
nopw %cs:(%rax,%rax)