// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movq %r8, -0x80(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdi, %r13
movl 0x24(%rdi), %eax
movl %eax, -0x40(%rbp)
movl 0x28(%rdi), %eax
movl %eax, -0x3c(%rbp)
testl %ecx, %ecx
jle 0x7356
movl %ecx, %eax
movq %rax, -0x88(%rbp)
movl $0x1, %eax
xorl %r10d, %r10d
xorl %r11d, %r11d
movq %rdx, -0x78(%rbp)
leaq (%r10,%r10,4), %rcx
movss (%rdx,%rcx,8), %xmm3
ucomiss 0x7b22(%rip), %xmm3     # 0xeac0
jbe 0x6fe4
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %r9
movslq 0x24(%rsi), %rsi
movzbl 0x5(%r9,%rsi), %edi
movzbl 0x4(%r9,%rsi), %r8d
shll $0x8, %r8d
movswl %r8w, %r8d
orl %edi, %r8d
movzbl 0x7(%r9,%rsi), %edi
movzbl 0x6(%r9,%rsi), %esi
shll $0x8, %esi
movswl %si, %esi
orl %edi, %esi
subl %esi, %r8d
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
jmp 0x700a
xorps 0x7b45(%rip), %xmm3     # 0xeb30
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %rdi
movslq 0x1c(%rsi), %rsi
movzwl 0x12(%rdi,%rsi), %esi
rolw $0x8, %si
movzwl %si, %esi
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
divss %xmm0, %xmm3
leaq (%rdx,%rcx,8), %rdi
movzbl 0x20(%rdi), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movl %ecx, 0x24(%r13)
xorps %xmm1, %xmm1
movss %xmm1, -0x38(%rbp)
movss %xmm1, -0x34(%rbp)
testl %ecx, %ecx
je 0x7050
movl $0x1, %esi
subl %ecx, %esi
xorps %xmm2, %xmm2
cvtsi2ss %esi, %xmm2
movaps %xmm0, %xmm1
addss %xmm0, %xmm1
divss %xmm1, %xmm2
movss %xmm2, -0x34(%rbp)
movzbl 0x21(%rdi), %ecx
movl %ecx, 0x28(%r13)
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
testl %ecx, %ecx
je 0x7081
movl $0x1, %esi
subl %ecx, %esi
xorps %xmm4, %xmm4
cvtsi2ss %esi, %xmm4
movaps %xmm1, %xmm2
addss %xmm1, %xmm2
divss %xmm2, %xmm4
movss %xmm4, -0x38(%rbp)
movl 0x10(%rdi), %ecx
testl %ecx, %ecx
jle 0x7344
movq %r10, -0x90(%rbp)
movss 0x79ed(%rip), %xmm2     # 0xea88
movaps %xmm2, %xmm4
divss %xmm0, %xmm4
movss %xmm4, -0x4c(%rbp)
divss %xmm1, %xmm2
movss %xmm2, -0x48(%rbp)
movl %r11d, -0x44(%rbp)
movslq %r11d, %rdx
leaq (%rdx,%rdx,2), %rdx
movq -0x80(%rbp), %rsi
leaq (%rsi,%rdx,8), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movaps %xmm3, -0x70(%rbp)
movq %rdi, -0x98(%rbp)
movl %eax, %edx
xorl %eax, %eax
cmpl $0x0, 0x14(%r14)
je 0x731b
cmpl $0x0, 0xc(%r14)
je 0x731b
cmpl $0x0, 0x10(%r14)
je 0x731b
movq 0x8(%rdi), %rax
testq %rax, %rax
movl %edx, -0x50(%rbp)
je 0x710b
movl (%rax,%r12,4), %esi
jmp 0x7111
movl 0x4(%rdi), %esi
addl %r12d, %esi
movq 0x18(%rdi), %rax
movq %rax, -0xa0(%rbp)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x359a
movl 0x1c(%r13), %ecx
addl %ecx, (%r14)
addl %ecx, 0x4(%r14)
subl %ecx, 0xc(%r14)
subl %ecx, 0x10(%r14)
movq %rbx, %rdi
movl %eax, %esi
movl %eax, %ebx
leaq -0x5c(%rbp), %rdx
leaq -0xac(%rbp), %rcx
callq 0x44da
movl 0x24(%r13), %eax
movl 0x28(%r13), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movaps -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
mulss %xmm2, %xmm1
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
movq -0x30(%rbp), %rdi
movl %ebx, %esi
leaq -0x58(%rbp), %rdx
leaq -0x54(%rbp), %rcx
leaq -0xa8(%rbp), %r8
leaq -0xa4(%rbp), %r9
callq 0x4d75
movslq (%r14), %rax
addq 0x30(%r13), %rax
movslq 0x4(%r14), %rsi
movslq 0x18(%r13), %r8
imulq %r8, %rsi
addq %rax, %rsi
movl 0x24(%r13), %eax
movl 0x28(%r13), %edi
movl 0xc(%r14), %edx
movl 0x10(%r14), %ecx
subl %eax, %edx
incl %edx
subl %edi, %ecx
incl %ecx
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movaps -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rdi, %xmm1
mulss %xmm2, %xmm1
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
movq -0x30(%rbp), %rdi
movl %ebx, %r9d
callq 0x6161
movl 0x24(%r13), %r8d
cmpl $0x2, %r8d
jb 0x7226
movslq (%r14), %rax
addq 0x30(%r13), %rax
movslq 0x4(%r14), %rdi
movslq 0x18(%r13), %rcx
imulq %rcx, %rdi
addq %rax, %rdi
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
callq 0x6a43
movl 0x28(%r13), %r8d
cmpl $0x2, %r8d
jb 0x7253
movslq (%r14), %rax
addq 0x30(%r13), %rax
movslq 0x4(%r14), %rdi
movslq 0x18(%r13), %rcx
imulq %rcx, %rdi
addq %rax, %rdi
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
callq 0x6c9d
movl (%r14), %eax
movq -0xa0(%rbp), %rdi
movw %ax, (%rdi,%r15)
movl 0x4(%r14), %edx
movw %dx, 0x2(%rdi,%r15)
movl 0xc(%r14), %ecx
addl %ecx, %eax
movw %ax, 0x4(%rdi,%r15)
movl 0x10(%r14), %eax
addl %eax, %edx
movw %dx, 0x6(%rdi,%r15)
xorps %xmm0, %xmm0
cvtsi2ssl -0x5c(%rbp), %xmm0
mulss -0x70(%rbp), %xmm0
movss %xmm0, 0x10(%rdi,%r15)
movl -0x58(%rbp), %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss -0x4c(%rbp), %xmm3
mulss %xmm3, %xmm0
movss -0x34(%rbp), %xmm2
addss %xmm2, %xmm0
movss %xmm0, 0x8(%rdi,%r15)
movl -0x54(%rbp), %esi
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movss -0x48(%rbp), %xmm4
mulss %xmm4, %xmm0
movss -0x38(%rbp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0xc(%rdi,%r15)
addl %ecx, %edx
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
mulss %xmm3, %xmm0
addss %xmm2, %xmm0
movss %xmm0, 0x14(%rdi,%r15)
addl %eax, %esi
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
mulss %xmm4, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x18(%rdi,%r15)
movq -0x98(%rbp), %rdi
movl 0x10(%rdi), %ecx
movl -0x50(%rbp), %eax
incq %r12
movslq %ecx, %rdx
addq $0x18, %r14
addq $0x1c, %r15
cmpq %rdx, %r12
jl 0x70d4
movl -0x44(%rbp), %r11d
addl %r12d, %r11d
movq -0x78(%rbp), %rdx
movq -0x90(%rbp), %r10
incq %r10
cmpq -0x88(%rbp), %r10
jne 0x6f8e
jmp 0x735b
movl $0x1, %eax
movl -0x40(%rbp), %ecx
movl %ecx, 0x24(%r13)
movl -0x3c(%rbp), %ecx
movl %ecx, 0x28(%r13)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq