// File: /workspace/github_c_makefile_star2_O1/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, %r15d
movl %edx, %ebp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x10(%rsp)
testl %edx, %edx
jne 0x35f56
movq 0x520bf(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3be51(%rip), %rsi     # 0x71d8c
leaq 0x3be68(%rip), %rdx     # 0x71daa
movl $0x41ba, %ecx           # imm = 0x41BA
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movq 0x70(%rsp), %rax
movl %r15d, 0xc(%rsp)
testl %r15d, %r15d
jne 0x35f97
movq 0x52084(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3be16(%rip), %rsi     # 0x71d8c
leaq 0x3be2d(%rip), %rdx     # 0x71daa
movl $0x41bb, %ecx           # imm = 0x41BB
movq %rax, %r15
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movq %r15, %rax
movq %rax, %r12
testq %rax, %rax
movq 0x10(%rsp), %r15
jne 0x35fd0
movq 0x52045(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3bdd7(%rip), %rsi     # 0x71d8c
leaq 0x3bdee(%rip), %rdx     # 0x71daa
movl $0x41bc, %ecx           # imm = 0x41BC
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl 0x78(%rsp), %eax
testq %r15, %r15
jne 0x36009
movq 0x52010(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3bda2(%rip), %rsi     # 0x71d8c
leaq 0x3bdb9(%rip), %rdx     # 0x71daa
movl $0x41bd, %ecx           # imm = 0x41BD
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl 0x78(%rsp), %eax
testl %eax, %eax
jne 0x3603d
movq 0x51fdc(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3bd6e(%rip), %rsi     # 0x71d8c
leaq 0x3bd85(%rip), %rdx     # 0x71daa
movl $0x41be, %ecx           # imm = 0x41BE
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl 0x78(%rsp), %eax
testl %r13d, %r13d
jne 0x36072
movq 0x51fa7(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3bd39(%rip), %rsi     # 0x71d8c
leaq 0x3bd50(%rip), %rdx     # 0x71daa
movl $0x41bf, %ecx           # imm = 0x41BF
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl 0x78(%rsp), %eax
testl %r13d, %r13d
movl 0xc(%rsp), %r14d
je 0x36482
testl %ebp, %ebp
je 0x36482
testl %r14d, %r14d
je 0x36482
testq %rbx, %rbx
je 0x36482
testq %r12, %r12
je 0x36482
testl %eax, %eax
je 0x36482
movl %ebp, %ecx
movl %eax, %ebp
movl %ecx, 0x28(%rsp)
movslq %ecx, %rax
movslq %r14d, %rsi
imulq %rax, %rsi
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x25316
movq %r12, 0x48(%r15)
movl %r14d, 0x2c(%r15)
testl %ebp, %ebp
jle 0x3616b
movq 0x10(%rsp), %rax
leaq 0x18(%rax), %r13
xorl %r14d, %r14d
movq 0x70(%rsp), %rax
movslq %r14d, %r14
imulq $0xb8, %r14, %r15
movq %rax, %rbp
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq 0x58(%rax), %r12
incq %r14
leaq (%r12,%r15), %rax
movq %rax, 0x20(%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 %r13, %rdi
movq 0x20(%rsp), %rsi
callq 0x13a60
movq 0x18(%rsp), %rax
movq 0x48(%rbp), %rbp
addq $0xb8, %r15
cmpq %rax, %rbp
jne 0x360fd
cmpl 0x78(%rsp), %r14d
jge 0x3616b
movq (%rax), %rax
testq %rax, %rax
jne 0x360eb
movq 0x10(%rsp), %r14
movq 0x18(%r14), %rax
movq 0x50(%r14), %rsi
movq (%rax), %rdi
callq *0x10(%rax)
movq 0x18(%r14), %rax
movq 0x20(%r14), %rsi
movq (%rax), %rdi
callq *0x10(%rax)
cmpl $0x0, 0x78(%rsp)
movq 0x70(%rsp), %rdi
movl 0x28(%rsp), %ecx
movl 0xc(%rsp), %edx
jle 0x36482
movq 0x58(%r14), %rax
movq %rax, 0x30(%rsp)
movd %edx, %xmm0
movd %ecx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm0
movaps %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm1     # xmm1 = xmm1[1,1],xmm0[1,1]
movaps 0x38416(%rip), %xmm2    # 0x6e5e0
divps %xmm0, %xmm2
movaps %xmm2, %xmm3
shufps $0x55, %xmm2, %xmm3     # xmm3 = xmm3[1,1],xmm2[1,1]
xorl %eax, %eax
movss 0x386d2(%rip), %xmm4    # 0x6e8b0
pxor %xmm5, %xmm5
xorl %r10d, %r10d
cltq
movq %rdi, %rsi
movq %rdi, 0x28(%rsp)
movq %rax, 0x10(%rsp)
imulq $0xb8, %rax, %rax
addq 0x30(%rsp), %rax
movq 0x38(%rsi), %rcx
movq %rcx, 0x18(%rsp)
cmpb $0x0, 0x19(%rsi)
jne 0x3629e
movss 0x20(%rsi), %xmm6
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 %xmm7, %xmm7
cvtsi2ss %r8d, %xmm7
subl %edx, %r8d
xorps %xmm8, %xmm8
cvtsi2ss %r8d, %xmm8
movq 0x30(%rsi), %rcx
movq 0x18(%rsp), %r8
movq %rcx, 0x18(%r8)
movss %xmm6, (%r8)
divss %xmm8, %xmm6
mulss %xmm6, %xmm7
movss %xmm7, 0x4(%r8)
xorps %xmm7, %xmm7
cvtsi2ss %edx, %xmm7
mulss %xmm6, %xmm7
movss %xmm7, 0x8(%r8)
movl %r10d, 0xc(%r8)
movl $0x0, 0x10(%r8)
movl %r10d, 0xc(%rsp)
movl 0xb0(%rax), %ecx
movq %rcx, 0x20(%rsp)
testq %rcx, %rcx
je 0x36442
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 0x36432
leaq (%r10,%rax,8), %rax
movq 0x18(%rax), %r15
movl 0x4(%rax), %r12d
movq 0x18(%rsp), %rdx
movl 0xc(%rdx), %r13d
movss 0x4(%rdx), %xmm6
addss %xmm4, %xmm6
movl 0x24(%rsi), %r14d
movss 0x28(%rsi), %xmm7
movb 0x1a(%rsi), %bpl
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
addl 0x10(%rdx), %r13d
xorl %edx, %edx
leal (%r8,%r13), %ecx
leaq (%rcx,%rcx,2), %r9
shlq $0x4, %r9
leaq (%rbx,%r9), %rcx
movd (%r15,%rdx), %xmm8
punpcklwd %xmm5, %xmm8    # xmm8 = xmm8[0],xmm5[0],xmm8[1],xmm5[1],xmm8[2],xmm5[2],xmm8[3],xmm5[3]
cvtdq2ps %xmm8, %xmm9
mulps %xmm2, %xmm9
movzwl 0x4(%r15,%rdx), %edi
xorps %xmm10, %xmm10
cvtsi2ss %edi, %xmm10
movzwl 0x6(%r15,%rdx), %edi
xorps %xmm8, %xmm8
cvtsi2ss %edi, %xmm8
mulss %xmm2, %xmm10
movsd 0x8(%r15,%rdx), %xmm11
movhps 0x14(%r15,%rdx), %xmm11 # xmm11 = xmm11[0,1],mem[0,1]
mulss %xmm3, %xmm8
movl %r12d, (%rbx,%r9)
addps %xmm5, %xmm11
movups %xmm11, 0x8(%rbx,%r9)
movaps %xmm11, %xmm12
movaps %xmm11, %xmm13
unpckhpd %xmm11, %xmm13          # xmm13 = xmm13[1],xmm11[1]
subss %xmm11, %xmm13
shufps $0x55, %xmm11, %xmm11   # xmm11 = xmm11[1,1,1,1]
addss %xmm6, %xmm11
movss %xmm11, 0xc(%rbx,%r9)
shufps $0xff, %xmm12, %xmm12   # xmm12 = xmm12[3,3,3,3]
addss %xmm6, %xmm12
movss %xmm12, 0x14(%rbx,%r9)
addss %xmm4, %xmm13
movss %xmm13, 0x18(%rbx,%r9)
subss %xmm11, %xmm12
movss %xmm12, 0x1c(%rbx,%r9)
cmpl $0x1, %r14d
jne 0x363e5
mulps %xmm0, %xmm9
movlps %xmm9, 0x20(%rcx)
mulss %xmm0, %xmm10
movss %xmm10, 0x28(%rcx)
mulss %xmm1, %xmm8
jmp 0x363f0
movlps %xmm9, 0x20(%rcx)
movss %xmm10, 0x28(%rcx)
movss %xmm8, 0x2c(%rcx)
movss 0x10(%r15,%rdx), %xmm8
addss %xmm7, %xmm8
movaps %xmm8, %xmm9
addss %xmm4, %xmm9
testb %bpl, %bpl
je 0x36419
cvttps2dq %xmm9, %xmm8
cvtdq2ps %xmm8, %xmm8
movss %xmm8, 0x4(%rcx)
incl %r8d
incl %r12d
addq $0x1c, %rdx
cmpq %rdx, %rax
jne 0x36312
incq %r11
cmpq 0x20(%rsp), %r11
jne 0x362c4
jmp 0x36445
xorl %r8d, %r8d
movq 0x18(%rsp), %rax
addl %r8d, 0x10(%rax)
movq 0x10(%rsp), %rax
incq %rax
movl 0xc(%rsp), %r10d
addl %r8d, %r10d
movq 0x48(%rsi), %rsi
movq 0x28(%rsp), %rdi
cmpq %rdi, %rsi
jne 0x361ef
cmpl 0x78(%rsp), %eax
jge 0x36482
movq (%rdi), %rdi
testq %rdi, %rdi
jne 0x361e5
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq