// File: Ciaxur[P]yagb-emu/include/imgui/imstb_truetype.h
// Function: stbtt__tesselate_cubic(stbtt__point*, int*, float, float, float, float, float, float, float, float, float, int)
static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n)
{
   // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough
   float dx0 = x1-x0;
   float dy0 = y1-y0;
   float dx1 = x2-x1;
   float dy1 = y2-y1;
   float dx2 = x3-x2;
   float dy2 = y3-y2;
   float dx = x3-x0;
   float dy = y3-y0;
   float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2));
   float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy);
   float flatness_squared = longlen*longlen-shortlen*shortlen;

   if (n > 16) // 65536 segments on one curve better be enough!
      return;

   if (flatness_squared > objspace_flatness_squared) {
      float x01 = (x0+x1)/2;
      float y01 = (y0+y1)/2;
      float x12 = (x1+x2)/2;
      float y12 = (y1+y2)/2;
      float x23 = (x2+x3)/2;
      float y23 = (y2+y3)/2;

      float xa = (x01+x12)/2;
      float ya = (y01+y12)/2;
      float xb = (x12+x23)/2;
      float yb = (y12+y23)/2;

      float mx = (xa+xb)/2;
      float my = (ya+yb)/2;

      stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1);
      stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1);
   } else {
      stbtt__add_point(points, *num_points,x3,y3);
      *num_points = *num_points+1;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movss 0x10(%rbp), %xmm8
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movss %xmm1, -0x18(%rbp)
movss %xmm2, -0x1c(%rbp)
movss %xmm3, -0x20(%rbp)
movss %xmm4, -0x24(%rbp)
movss %xmm5, -0x28(%rbp)
movss %xmm6, -0x2c(%rbp)
movss %xmm7, -0x30(%rbp)
movl %edx, -0x34(%rbp)
movss -0x1c(%rbp), %xmm0
subss -0x14(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x20(%rbp), %xmm0
subss -0x18(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x24(%rbp), %xmm0
subss -0x1c(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x28(%rbp), %xmm0
subss -0x20(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x2c(%rbp), %xmm0
subss -0x24(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x30(%rbp), %xmm0
subss -0x28(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x2c(%rbp), %xmm0
subss -0x14(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x30(%rbp), %xmm0
subss -0x18(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x38(%rbp), %xmm0
movss -0x38(%rbp), %xmm2
movss -0x3c(%rbp), %xmm1
mulss -0x3c(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0xd960
movss %xmm0, -0x98(%rbp)
movss -0x40(%rbp), %xmm0
movss -0x40(%rbp), %xmm2
movss -0x44(%rbp), %xmm1
mulss -0x44(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0xd960
movaps %xmm0, %xmm1
movss -0x98(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x94(%rbp)
movss -0x48(%rbp), %xmm0
movss -0x48(%rbp), %xmm2
movss -0x4c(%rbp), %xmm1
mulss -0x4c(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0xd960
movaps %xmm0, %xmm1
movss -0x94(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x50(%rbp), %xmm0
movss -0x50(%rbp), %xmm2
movss -0x54(%rbp), %xmm1
mulss -0x54(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
callq 0xd960
movss %xmm0, -0x5c(%rbp)
movss -0x58(%rbp), %xmm0
movss -0x58(%rbp), %xmm2
movss -0x5c(%rbp), %xmm1
mulss -0x5c(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
cmpl $0x10, -0x34(%rbp)
jle 0x1246c1
jmp 0x1248f0
movss -0x60(%rbp), %xmm0
ucomiss 0x10(%rbp), %xmm0
jbe 0x1248c8
movss -0x14(%rbp), %xmm0
addss -0x1c(%rbp), %xmm0
movss 0x4d8ea(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x18(%rbp), %xmm0
addss -0x20(%rbp), %xmm0
movss 0x4d8cf(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x1c(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
movss 0x4d8b4(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x6c(%rbp)
movss -0x20(%rbp), %xmm0
addss -0x28(%rbp), %xmm0
movss 0x4d899(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x24(%rbp), %xmm0
addss -0x2c(%rbp), %xmm0
movss 0x4d87e(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x74(%rbp)
movss -0x28(%rbp), %xmm0
addss -0x30(%rbp), %xmm0
movss 0x4d863(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x78(%rbp)
movss -0x64(%rbp), %xmm0
addss -0x6c(%rbp), %xmm0
movss 0x4d848(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x7c(%rbp)
movss -0x68(%rbp), %xmm0
addss -0x70(%rbp), %xmm0
movss 0x4d82d(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x80(%rbp)
movss -0x6c(%rbp), %xmm0
addss -0x74(%rbp), %xmm0
movss 0x4d812(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x84(%rbp)
movss -0x70(%rbp), %xmm0
addss -0x78(%rbp), %xmm0
movss 0x4d7f4(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x88(%rbp)
movss -0x7c(%rbp), %xmm0
addss -0x84(%rbp), %xmm0
movss 0x4d7d3(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x8c(%rbp)
movss -0x80(%rbp), %xmm0
addss -0x88(%rbp), %xmm0
movss 0x4d7b2(%rip), %xmm1    # 0x171fcc
divss %xmm1, %xmm0
movss %xmm0, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movss -0x14(%rbp), %xmm0
movss -0x18(%rbp), %xmm1
movss -0x64(%rbp), %xmm2
movss -0x68(%rbp), %xmm3
movss -0x7c(%rbp), %xmm4
movss -0x80(%rbp), %xmm5
movss -0x8c(%rbp), %xmm6
movss -0x90(%rbp), %xmm7
movss 0x10(%rbp), %xmm8
movl -0x34(%rbp), %edx
addl $0x1, %edx
movss %xmm8, (%rsp)
callq 0x124510
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movss -0x8c(%rbp), %xmm0
movss -0x90(%rbp), %xmm1
movss -0x84(%rbp), %xmm2
movss -0x88(%rbp), %xmm3
movss -0x74(%rbp), %xmm4
movss -0x78(%rbp), %xmm5
movss -0x2c(%rbp), %xmm6
movss -0x30(%rbp), %xmm7
movss 0x10(%rbp), %xmm8
movl -0x34(%rbp), %edx
addl $0x1, %edx
movss %xmm8, (%rsp)
callq 0x124510
jmp 0x1248f0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
movss -0x2c(%rbp), %xmm0
movss -0x30(%rbp), %xmm1
callq 0x1242d0
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)