// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_font_bake
NK_INTERN void
nk_font_bake(struct nk_font_baker *baker, void *image_memory, int width, int height,
    struct nk_font_glyph *glyphs, int glyphs_count,
    const struct nk_font_config *config_list, int font_count)
{
    int input_i = 0;
    nk_rune glyph_n = 0;
    const struct nk_font_config *config_iter;
    const struct nk_font_config *it;

    NK_ASSERT(image_memory);
    NK_ASSERT(width);
    NK_ASSERT(height);
    NK_ASSERT(config_list);
    NK_ASSERT(baker);
    NK_ASSERT(font_count);
    NK_ASSERT(glyphs_count);
    if (!image_memory || !width || !height || !config_list ||
        !font_count || !glyphs || !glyphs_count)
        return;

    /* second font pass: render glyphs */
    nk_zero(image_memory, (nk_size)((nk_size)width * (nk_size)height));
    baker->spc.pixels = (unsigned char*)image_memory;
    baker->spc.height = (int)height;
    for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
        config_iter = config_iter->next) {
        it = config_iter;
        do {const struct nk_font_config *cfg = it;
            struct nk_font_bake_data *tmp = &baker->build[input_i++];
            stbtt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
            stbtt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges, (int)tmp->range_count, tmp->rects);
        } while ((it = it->n) != config_iter);
    } stbtt_PackEnd(&baker->spc);

    /* third pass: setup font and glyphs */
    for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
        config_iter = config_iter->next) {
        it = config_iter;
        do {nk_size i = 0;
            int char_idx = 0;
            nk_rune glyph_count = 0;
            const struct nk_font_config *cfg = it;
            struct nk_font_bake_data *tmp = &baker->build[input_i++];
            struct nk_baked_font *dst_font = cfg->font;

            float font_scale = stbtt_ScaleForPixelHeight(&tmp->info, cfg->size);
            int unscaled_ascent, unscaled_descent, unscaled_line_gap;
            stbtt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
                                    &unscaled_line_gap);

            /* fill baked font */
            if (!cfg->merge_mode) {
                dst_font->ranges = cfg->range;
                dst_font->height = cfg->size;
                dst_font->ascent = ((float)unscaled_ascent * font_scale);
                dst_font->descent = ((float)unscaled_descent * font_scale);
                dst_font->glyph_offset = glyph_n;
                /*
                    Need to zero this, or it will carry over from a previous
                    bake, and cause a segfault when accessing glyphs[].
                */
                dst_font->glyph_count = 0;
            }

            /* fill own baked font glyph array */
            for (i = 0; i < tmp->range_count; ++i) {
                stbtt_pack_range *range = &tmp->ranges[i];
                for (char_idx = 0; char_idx < range->num_chars; char_idx++)
                {
                    nk_rune codepoint = 0;
                    float dummy_x = 0, dummy_y = 0;
                    stbtt_aligned_quad q;
                    struct nk_font_glyph *glyph;

                    /* query glyph bounds from stb_truetype */
                    const stbtt_packedchar *pc = &range->chardata_for_range[char_idx];
                    codepoint = (nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
                    stbtt_GetPackedQuad(range->chardata_for_range, (int)width,
                        (int)height, char_idx, &dummy_x, &dummy_y, &q, 0);

                    /* fill own glyph type with data */
                    glyph = &glyphs[dst_font->glyph_offset + dst_font->glyph_count + (unsigned int)glyph_count];
                    glyph->codepoint = codepoint;
                    glyph->x0 = q.x0; glyph->y0 = q.y0;
                    glyph->x1 = q.x1; glyph->y1 = q.y1;
                    glyph->y0 += (dst_font->ascent + 0.5f);
                    glyph->y1 += (dst_font->ascent + 0.5f);
                    glyph->w = glyph->x1 - glyph->x0 + 0.5f;
                    glyph->h = glyph->y1 - glyph->y0;

                    if (cfg->coord_type == NK_COORD_PIXEL) {
                        glyph->u0 = q.s0 * (float)width;
                        glyph->v0 = q.t0 * (float)height;
                        glyph->u1 = q.s1 * (float)width;
                        glyph->v1 = q.t1 * (float)height;
                    } else {
                        glyph->u0 = q.s0;
                        glyph->v0 = q.t0;
                        glyph->u1 = q.s1;
                        glyph->v1 = q.t1;
                    }
                    glyph->xadvance = (pc->xadvance + cfg->spacing.x);
                    if (cfg->pixel_snap)
                        glyph->xadvance = (float)(int)(glyph->xadvance + 0.5f);
                    glyph_count++;
                }
            }
            dst_font->glyph_count += glyph_count;
            glyph_n += glyph_count;
        } while ((it = it->n) != config_iter);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r13d
movq %r8, %rbx
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x70(%rsp), %r15
testl %edx, %edx
jne 0x35a4b
movq 0x515ca(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b36c(%rip), %rsi     # 0x70d9c
leaq 0x3b383(%rip), %rdx     # 0x70dba
movl $0x41ba, %ecx           # imm = 0x41BA
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl %r12d, 0x1c(%rsp)
testl %r12d, %r12d
jne 0x35a81
movq 0x51594(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b336(%rip), %rsi     # 0x70d9c
leaq 0x3b34d(%rip), %rdx     # 0x70dba
movl $0x41bb, %ecx           # imm = 0x41BB
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r15, %r15
movq 0x10(%rsp), %r12
jne 0x35ab7
movq 0x5155e(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b300(%rip), %rsi     # 0x70d9c
leaq 0x3b317(%rip), %rdx     # 0x70dba
movl $0x41bc, %ecx           # imm = 0x41BC
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r12, %r12
jne 0x35ae8
movq 0x5152d(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b2cf(%rip), %rsi     # 0x70d9c
leaq 0x3b2e6(%rip), %rdx     # 0x70dba
movl $0x41bd, %ecx           # imm = 0x41BD
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpl $0x0, 0x4(%rsp)
jne 0x35b1b
movq 0x514fa(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b29c(%rip), %rsi     # 0x70d9c
leaq 0x3b2b3(%rip), %rdx     # 0x70dba
movl $0x41be, %ecx           # imm = 0x41BE
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testl %r13d, %r13d
je 0x35edb
cmpl $0x0, 0x4(%rsp)
sete %al
testq %r15, %r15
sete %cl
movl 0x1c(%rsp), %r14d
testl %r14d, %r14d
sete %dl
testl %ebp, %ebp
sete %sil
testq %rbx, %rbx
sete %dil
orb %dl, %dil
orb %sil, %dil
orb %cl, %dil
orb %al, %dil
jne 0x35ecc
movq %r15, 0x20(%rsp)
movl %ebp, 0x34(%rsp)
movslq %ebp, %rax
movslq %r14d, %rsi
imulq %rax, %rsi
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2542e
movq %r15, 0x48(%r12)
movl %r14d, 0x2c(%r12)
cmpl $0x0, 0x4(%rsp)
jle 0x35c27
leaq 0x18(%r12), %r13
xorl %r14d, %r14d
movq 0x20(%rsp), %rax
movslq %r14d, %r14
imulq $0xb8, %r14, %r15
movq %rax, %rbp
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq 0x58(%rax), %r12
incq %r14
leaq (%r12,%r15), %rax
movq %rax, 0x8(%rsp)
movzbl 0x1c(%rbp), %esi
movzbl 0x1b(%rbp), %edx
movq %r13, %rdi
callq 0x13ed0
movq 0xa0(%r12,%r15), %r8
movq 0xa8(%r12,%r15), %rdx
movl 0xb0(%r12,%r15), %ecx
movq 0x10(%rsp), %r12
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x13a60
movq 0x28(%rsp), %rax
movq 0x48(%rbp), %rbp
addq $0xb8, %r15
cmpq %rax, %rbp
jne 0x35bb0
cmpl 0x4(%rsp), %r14d
jge 0x35c27
movq (%rax), %rax
testq %rax, %rax
jne 0x35b9e
movq 0x18(%r12), %rax
movq 0x50(%r12), %rsi
movq (%rax), %rdi
callq *0x10(%rax)
movq 0x18(%r12), %rax
movq 0x20(%r12), %rsi
movq (%rax), %rdi
callq *0x10(%rax)
cmpl $0x0, 0x4(%rsp)
movq 0x20(%rsp), %r10
movl 0x34(%rsp), %ecx
movl 0x1c(%rsp), %edx
jle 0x35ecc
movq 0x58(%r12), %rax
movq %rax, 0x28(%rsp)
movd %edx, %xmm0
movd %ecx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm0
movaps 0x37961(%rip), %xmm1    # 0x6d5e0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movlhps %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divps %xmm0, %xmm1
xorl %eax, %eax
movss 0x37c0e(%rip), %xmm2    # 0x6d8a0
pxor %xmm3, %xmm3
xorps %xmm4, %xmm4
xorl %r11d, %r11d
cltq
movq %r10, %rsi
movq %r10, 0x20(%rsp)
movq %rax, 0x10(%rsp)
imulq $0xb8, %rax, %rax
addq 0x28(%rsp), %rax
movq 0x38(%rsi), %rdi
cmpb $0x0, 0x19(%rsi)
jne 0x35d45
movss 0x20(%rsi), %xmm5
movq 0x8(%rax), %rcx
movslq 0x24(%rax), %rdx
movzbl 0x4(%rcx,%rdx), %r8d
shll $0x8, %r8d
movzbl 0x5(%rcx,%rdx), %r9d
movswl %r8w, %r8d
orl %r9d, %r8d
movzbl 0x6(%rcx,%rdx), %r9d
shll $0x8, %r9d
movzbl 0x7(%rcx,%rdx), %ecx
movswl %r9w, %edx
orl %ecx, %edx
xorps %xmm6, %xmm6
cvtsi2ss %r8d, %xmm6
subl %edx, %r8d
xorps %xmm7, %xmm7
cvtsi2ss %r8d, %xmm7
movq 0x30(%rsi), %rcx
movq %rcx, 0x18(%rdi)
movss %xmm5, (%rdi)
divss %xmm7, %xmm5
mulss %xmm5, %xmm6
movss %xmm6, 0x4(%rdi)
xorps %xmm6, %xmm6
cvtsi2ss %edx, %xmm6
mulss %xmm5, %xmm6
movss %xmm6, 0x8(%rdi)
movl %r11d, 0xc(%rdi)
movl $0x0, 0x10(%rdi)
movl %r11d, 0x8(%rsp)
movl 0xb0(%rax), %r9d
testq %r9, %r9
je 0x35e91
movq 0xa8(%rax), %r10
xorl %r11d, %r11d
xorl %r8d, %r8d
leaq (%r11,%r11,4), %rax
movslq 0x10(%r10,%rax,8), %rcx
testq %rcx, %rcx
jle 0x35e83
leaq (%r10,%rax,8), %rax
movq 0x18(%rax), %r15
movl 0x4(%rax), %r12d
movl 0xc(%rdi), %r13d
movss 0x4(%rdi), %xmm5
addss %xmm2, %xmm5
movl 0x24(%rsi), %ebp
movss 0x28(%rsi), %xmm6
movb 0x1a(%rsi), %r14b
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
addl 0x10(%rdi), %r13d
xorl %edx, %edx
movq (%r15,%rdx), %xmm7
punpcklwd %xmm3, %xmm7    # xmm7 = xmm7[0],xmm3[0],xmm7[1],xmm3[1],xmm7[2],xmm3[2],xmm7[3],xmm3[3]
cvtdq2ps %xmm7, %xmm7
mulps %xmm1, %xmm7
cmpl $0x1, %ebp
jne 0x35dc7
mulps %xmm0, %xmm7
leal (%r8,%r13), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movss 0x8(%r15,%rdx), %xmm8
addss %xmm4, %xmm8
movss 0xc(%r15,%rdx), %xmm9
addss %xmm4, %xmm9
movss 0x14(%r15,%rdx), %xmm10
addss %xmm4, %xmm10
movss 0x18(%r15,%rdx), %xmm11
addss %xmm4, %xmm11
movl %r12d, (%rbx,%rcx)
movss %xmm8, 0x8(%rbx,%rcx)
movss %xmm10, 0x10(%rbx,%rcx)
addss %xmm5, %xmm9
movss %xmm9, 0xc(%rbx,%rcx)
addss %xmm5, %xmm11
movss %xmm11, 0x14(%rbx,%rcx)
subss %xmm8, %xmm10
addss %xmm2, %xmm10
movss %xmm10, 0x18(%rbx,%rcx)
subss %xmm9, %xmm11
movss %xmm11, 0x1c(%rbx,%rcx)
movups %xmm7, 0x20(%rbx,%rcx)
movss 0x10(%r15,%rdx), %xmm7
addss %xmm6, %xmm7
testb %r14b, %r14b
je 0x35e6a
addss %xmm2, %xmm7
cvttps2dq %xmm7, %xmm7
cvtdq2ps %xmm7, %xmm7
movss %xmm7, 0x4(%rbx,%rcx)
incl %r8d
incl %r12d
addq $0x1c, %rdx
cmpq %rdx, %rax
jne 0x35daf
incq %r11
cmpq %r9, %r11
jne 0x35d67
jmp 0x35e94
xorl %r8d, %r8d
addl %r8d, 0x10(%rdi)
movq 0x10(%rsp), %rax
incq %rax
movl 0x8(%rsp), %r11d
addl %r8d, %r11d
movq 0x48(%rsi), %rsi
movq 0x20(%rsp), %r10
cmpq %r10, %rsi
jne 0x35ca6
cmpl 0x4(%rsp), %eax
jge 0x35ecc
movq (%r10), %r10
testq %r10, %r10
jne 0x35c9c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5110e(%rip), %rbx     # 0x86ff0
movq (%rbx), %rdi
leaq 0x3aeb0(%rip), %rsi     # 0x70d9c
leaq 0x3aec7(%rip), %rdx     # 0x70dba
movl $0x41bf, %ecx           # imm = 0x41BF
xorl %eax, %eax
callq 0x12d80
movq (%rbx), %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13780