// File: /workspace/github_c_makefile_star2_O2/ggerganov[P]font-rasterizer/./stb_truetype.h
// Function: stbtt_PackFontRangesRenderIntoRects
STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
{
   int i,j,k, return_value = 1;

   // save current values
   int old_h_over = spc->h_oversample;
   int old_v_over = spc->v_oversample;

   k = 0;
   for (i=0; i < num_ranges; ++i) {
      float fh = ranges[i].font_size;
      float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
      float recip_h,recip_v,sub_x,sub_y;
      spc->h_oversample = ranges[i].h_oversample;
      spc->v_oversample = ranges[i].v_oversample;
      recip_h = 1.0f / spc->h_oversample;
      recip_v = 1.0f / spc->v_oversample;
      sub_x = stbtt__oversample_shift(spc->h_oversample);
      sub_y = stbtt__oversample_shift(spc->v_oversample);
      for (j=0; j < ranges[i].num_chars; ++j) {
         stbrp_rect *r = &rects[k];
         if (r->was_packed && r->w != 0 && r->h != 0) {
            stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
            int advance, lsb, x0,y0,x1,y1;
            int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
            int glyph = stbtt_FindGlyphIndex(info, codepoint);
            stbrp_coord pad = (stbrp_coord) spc->padding;

            // pad on left and top
            r->x += pad;
            r->y += pad;
            r->w -= pad;
            r->h -= pad;
            stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
            stbtt_GetGlyphBitmapBox(info, glyph,
                                    scale * spc->h_oversample,
                                    scale * spc->v_oversample,
                                    &x0,&y0,&x1,&y1);
            stbtt_MakeGlyphBitmapSubpixel(info,
                                          spc->pixels + r->x + r->y*spc->stride_in_bytes,
                                          r->w - spc->h_oversample+1,
                                          r->h - spc->v_oversample+1,
                                          spc->stride_in_bytes,
                                          scale * spc->h_oversample,
                                          scale * spc->v_oversample,
                                          0,0,
                                          glyph);

            if (spc->h_oversample > 1)
               stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
                                  r->w, r->h, spc->stride_in_bytes,
                                  spc->h_oversample);

            if (spc->v_oversample > 1)
               stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
                                  r->w, r->h, spc->stride_in_bytes,
                                  spc->v_oversample);

            bc->x0       = (stbtt_int16)  r->x;
            bc->y0       = (stbtt_int16)  r->y;
            bc->x1       = (stbtt_int16) (r->x + r->w);
            bc->y1       = (stbtt_int16) (r->y + r->h);
            bc->xadvance =                scale * advance;
            bc->xoff     =       (float)  x0 * recip_h + sub_x;
            bc->yoff     =       (float)  y0 * recip_v + sub_y;
            bc->xoff2    =                (x0 + r->w) * recip_h + sub_x;
            bc->yoff2    =                (y0 + r->h) * recip_v + sub_y;
         } else {
            return_value = 0; // if any fail, report failure
         }

         ++k;
      }
   }

   // restore original values
   spc->h_oversample = old_h_over;
   spc->v_oversample = old_v_over;

   return return_value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r8, -0x80(%rbp)
movq %rdx, %rbx
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
movl 0x24(%rdi), %eax
movl %eax, -0x40(%rbp)
movl 0x28(%rdi), %eax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, -0x88(%rbp)
pushq $0x1
popq %rsi
xorl %r15d, %r15d
movq %rdx, -0x78(%rbp)
cmpq -0x88(%rbp), %rax
je 0x6e1a
movq %rax, -0x98(%rbp)
imulq $0x28, %rax, %rdi
movss (%rbx,%rdi), %xmm0
ucomiss 0x6ff7(%rip), %xmm0     # 0xdac4
jbe 0x6ae6
movq %rdi, %r13
movq -0x38(%rbp), %rdi
movl %esi, %r12d
callq 0x4b6c
movq %r13, %rdi
movl %r12d, %esi
jmp 0x6b0d
xorps 0x7043(%rip), %xmm0     # 0xdb30
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
movslq 0x1c(%rcx), %rcx
movzwl 0x12(%rax,%rcx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
addq %rbx, %rdi
movzbl 0x20(%rdi), %ecx
movl %ecx, 0x24(%r14)
cvtsi2ss %ecx, %xmm3
movzbl 0x21(%rdi), %eax
xorps %xmm1, %xmm1
movss %xmm1, -0x30(%rbp)
movss %xmm1, -0x2c(%rbp)
testl %ecx, %ecx
je 0x6b4a
pushq $0x1
popq %rdx
subl %ecx, %edx
cvtsi2ss %edx, %xmm2
movaps %xmm3, %xmm1
addss %xmm3, %xmm1
divss %xmm1, %xmm2
movss %xmm2, -0x2c(%rbp)
movl %eax, 0x28(%r14)
cvtsi2ss %eax, %xmm1
testl %eax, %eax
je 0x6b6f
pushq $0x1
popq %rcx
subl %eax, %ecx
cvtsi2ss %ecx, %xmm4
movaps %xmm1, %xmm2
addss %xmm1, %xmm2
divss %xmm2, %xmm4
movss %xmm4, -0x30(%rbp)
movss 0x6f15(%rip), %xmm2     # 0xda8c
movaps %xmm2, %xmm4
divss %xmm3, %xmm4
movss %xmm4, -0x48(%rbp)
divss %xmm1, %xmm2
movss %xmm2, -0x44(%rbp)
movslq %r15d, %r15
movq %r15, -0x90(%rbp)
imulq $0x18, %r15, %r13
addq -0x80(%rbp), %r13
xorl %r12d, %r12d
xorl %ecx, %ecx
movaps %xmm0, -0x70(%rbp)
movq %rdi, -0xa0(%rbp)
movslq 0x10(%rdi), %rax
cmpq %rax, %rcx
jge 0x6dfd
xorl %eax, %eax
cmpl $0x0, 0x14(%r13)
je 0x6deb
cmpl $0x0, 0xc(%r13)
je 0x6deb
cmpl $0x0, 0x10(%r13)
je 0x6deb
movl %esi, -0x4c(%rbp)
movq 0x8(%rdi), %rax
testq %rax, %rax
movq %rcx, -0xa8(%rbp)
je 0x6bf6
movl (%rax,%rcx,4), %esi
jmp 0x6bfb
movl 0x4(%rdi), %esi
addl %ecx, %esi
movq 0x18(%rdi), %rax
movq %rax, -0xb0(%rbp)
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x34bb
movl 0x1c(%r14), %ecx
addl %ecx, (%r13)
addl %ecx, 0x4(%r13)
subl %ecx, 0xc(%r13)
movl %eax, %ebx
subl %ecx, 0x10(%r13)
movq %r15, %rdi
movl %eax, %esi
leaq -0x58(%rbp), %rdx
leaq -0xbc(%rbp), %rcx
callq 0x4339
movl 0x24(%r14), %eax
movl 0x28(%r14), %ecx
cvtsi2ss %rax, %xmm0
movaps -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
cvtsi2ss %rcx, %xmm1
mulss %xmm2, %xmm1
movq %r15, %rdi
movl %ebx, %esi
leaq -0x54(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0xb8(%rbp), %r8
leaq -0xb4(%rbp), %r9
callq 0x4ce3
movslq (%r13), %rax
addq 0x30(%r14), %rax
movslq 0x4(%r13), %rsi
movslq 0x18(%r14), %r8
imulq %r8, %rsi
addq %rax, %rsi
movl 0x24(%r14), %eax
movl 0x28(%r14), %edi
movl 0xc(%r13), %edx
movl 0x10(%r13), %ecx
subl %eax, %edx
incl %edx
subl %edi, %ecx
incl %ecx
cvtsi2ss %rax, %xmm0
movaps -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
cvtsi2ss %rdi, %xmm1
mulss %xmm2, %xmm1
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
movq %r15, %rdi
movl %ebx, %r9d
callq 0x5e69
movl 0x24(%r14), %r8d
cmpl $0x2, %r8d
jb 0x6cff
movslq (%r13), %rax
addq 0x30(%r14), %rax
movslq 0x4(%r13), %rdi
movslq 0x18(%r14), %rcx
imulq %rcx, %rdi
addq %rax, %rdi
movl 0xc(%r13), %esi
movl 0x10(%r13), %edx
callq 0x6615
movl 0x28(%r14), %r8d
cmpl $0x2, %r8d
jb 0x6d2d
movslq (%r13), %rax
addq 0x30(%r14), %rax
movslq 0x4(%r13), %rdi
movslq 0x18(%r14), %rcx
imulq %rcx, %rdi
addq %rax, %rdi
movl 0xc(%r13), %esi
movl 0x10(%r13), %edx
callq 0x6821
movl (%r13), %eax
movq -0xb0(%rbp), %rdi
movw %ax, (%rdi,%r12)
movl 0x4(%r13), %edx
movw %dx, 0x2(%rdi,%r12)
movl 0xc(%r13), %ecx
addl %ecx, %eax
movw %ax, 0x4(%rdi,%r12)
movl 0x10(%r13), %eax
addl %eax, %edx
movw %dx, 0x6(%rdi,%r12)
cvtsi2ssl -0x58(%rbp), %xmm0
mulss -0x70(%rbp), %xmm0
movss %xmm0, 0x10(%rdi,%r12)
movl -0x54(%rbp), %edx
cvtsi2ss %edx, %xmm0
movss -0x48(%rbp), %xmm4
mulss %xmm4, %xmm0
movss -0x2c(%rbp), %xmm3
addss %xmm3, %xmm0
movss %xmm0, 0x8(%rdi,%r12)
movl -0x50(%rbp), %esi
cvtsi2ss %esi, %xmm0
movss -0x44(%rbp), %xmm5
mulss %xmm5, %xmm0
movss -0x30(%rbp), %xmm2
addss %xmm2, %xmm0
addl %ecx, %edx
cvtsi2ss %edx, %xmm1
movss %xmm0, 0xc(%rdi,%r12)
mulss %xmm4, %xmm1
addss %xmm3, %xmm1
movss %xmm1, 0x14(%rdi,%r12)
addl %eax, %esi
cvtsi2ss %esi, %xmm0
mulss %xmm5, %xmm0
addss %xmm2, %xmm0
movss %xmm0, 0x18(%rdi,%r12)
movl -0x4c(%rbp), %eax
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rcx
incq %rcx
addq $0x1c, %r12
addq $0x18, %r13
movl %eax, %esi
jmp 0x6bae
movq -0x98(%rbp), %rax
incq %rax
movq -0x90(%rbp), %r15
addq %rcx, %r15
movq -0x78(%rbp), %rbx
jmp 0x6aa9
movl -0x40(%rbp), %eax
movl %eax, 0x24(%r14)
movl -0x3c(%rbp), %eax
movl %eax, 0x28(%r14)
movl %esi, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq