// File: Ciaxur[P]yagb-emu/include/imgui/imstb_truetype.h
// Function: stbtt__rasterize_sorted_edges(stbtt__bitmap*, stbtt__edge*, int, int, int, int, void*)
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 0xd2f0
movq $0x0, -0x40(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x40, (%rax)
jle 0x12499d
movq -0x8(%rbp), %rax
movl (%rax), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0xc4820
movq %rax, -0x258(%rbp)
jmp 0x1249ab
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 0x4c259(%rip), %xmm1    # 0x170c3c
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 0x124dcd
cvtsi2ssl -0x44(%rbp), %xmm0
xorps %xmm1, %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x264(%rbp)
cvtsi2ssl -0x44(%rbp), %xmm0
movss 0x4c210(%rip), %xmm1    # 0x170c3c
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 0xd2f0
movq -0x260(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0xd2f0
movq -0x270(%rbp), %rax
cmpq $0x0, (%rax)
je 0x124b3b
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 0x124b25
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 0x124ae1
jp 0x124ae1
jmp 0x124ae3
jmp 0x124b02
leaq 0x66a34(%rip), %rdi     # 0x18b51e
leaq 0x664f9(%rip), %rsi     # 0x18afea
movl $0xc63, %edx            # imm = 0xC63
leaq 0x66a2e(%rip), %rcx     # 0x18b52b
callq 0xd180
jmp 0x124b04
movq -0x278(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x14(%rax)
movq -0x278(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x125270
jmp 0x124b36
movq -0x270(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x270(%rbp)
jmp 0x124a7a
jmp 0x124b3d
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm1
movss -0x268(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x124c43
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0xc(%rax), %xmm0
jne 0x124b71
jp 0x124b71
jmp 0x124c32
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %edx
movss -0x264(%rbp), %xmm0
movq 0x10(%rbp), %rcx
leaq -0x38(%rbp), %rdi
callq 0x1252a0
movq %rax, -0x280(%rbp)
cmpq $0x0, -0x280(%rbp)
je 0x124c30
cmpl $0x0, -0x48(%rbp)
jne 0x124bdd
cmpl $0x0, -0x20(%rbp)
je 0x124bdd
movq -0x280(%rbp), %rax
movss 0x1c(%rax), %xmm1
movss -0x264(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x124bdb
movss -0x264(%rbp), %xmm0
movq -0x280(%rbp), %rax
movss %xmm0, 0x1c(%rax)
jmp 0x124bdd
jmp 0x124bdf
movq -0x280(%rbp), %rax
movss 0x1c(%rax), %xmm0
ucomiss -0x264(%rbp), %xmm0
jb 0x124bf6
jmp 0x124c15
leaq 0x6698d(%rip), %rdi     # 0x18b58a
leaq 0x663e6(%rip), %rsi     # 0x18afea
movl $0xc76, %edx            # imm = 0xC76
leaq 0x6691b(%rip), %rcx     # 0x18b52b
callq 0xd180
jmp 0x124c17
movq -0x40(%rbp), %rcx
movq -0x280(%rbp), %rax
movq %rcx, (%rax)
movq -0x280(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x124c32
movq -0x10(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x10(%rbp)
jmp 0x124b3d
cmpq $0x0, -0x40(%rbp)
je 0x124c73
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 0x125450
xorps %xmm0, %xmm0
movss %xmm0, -0x284(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x124d5d
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
movaps 0x4db1d(%rip), %xmm1    # 0x172800
pand %xmm1, %xmm0
movss 0x4da6d(%rip), %xmm1    # 0x17275c
mulss %xmm1, %xmm0
movss 0x4d2dd(%rip), %xmm1    # 0x171fd8
addss %xmm1, %xmm0
movss %xmm0, -0x288(%rbp)
cvttss2si -0x288(%rbp), %eax
movl %eax, -0x28c(%rbp)
cmpl $0xff, -0x28c(%rbp)
jle 0x124d2b
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 0x124c85
leaq -0x40(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rax
cmpq $0x0, (%rax)
je 0x124db6
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 0x124d68
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1249fb
movq 0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x125f40
movq -0x258(%rbp), %rax
leaq -0x250(%rbp), %rcx
cmpq %rcx, %rax
je 0x124df9
movq -0x258(%rbp), %rdi
callq 0xc4920
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
nopw %cs:(%rax,%rax)