// File: /workspace/github_c_makefile_star2_O0/justinmeiners[P]text2image/text2image.c
// Function: render_text
void render_text(stbtt_fontinfo* font_info,
                 unsigned char* bitmap,
                 int* w,
                 float scale,
                 const char* text,
                 size_t text_size)
                
{
    int ascent, descent, line_gap;
    stbtt_GetFontVMetrics(font_info, &ascent, &descent, &line_gap);
    
    ascent *= scale;
    descent *= scale;

    int x = 0;
    for (int i = 0; i < text_size; ++i)
    {
        if (iscntrl(text[i])) continue;

        int c_x1, c_y1, c_x2, c_y2;
        stbtt_GetCodepointBitmapBox(font_info, text[i], scale, scale, &c_x1, &c_y1, &c_x2, &c_y2);
        
        int y = ascent + c_y1;
        
        /* render character (stride and offset is important here) */
        if (bitmap)
        {
            int offset = x + (y * (*w));
            stbtt_MakeCodepointBitmap(font_info, bitmap + offset, c_x2 - c_x1, c_y2 - c_y1, *w, scale, scale, text[i]);
        }
       
        int ax;
        stbtt_GetCodepointHMetrics(font_info, text[i], &ax, 0);
        x += ax * scale;
        
        int kern = stbtt_GetCodepointKernAdvance(font_info, text[i], text[i + 1]);
        x += kern * scale;
    }

    *w = x;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movss %xmm0, 0x4c(%rsp)
movq %rcx, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movq 0x60(%rsp), %rdi
leaq 0x34(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x2c(%rsp), %rcx
callq 0x7410
movss 0x4c(%rsp), %xmm1
cvtsi2ssl 0x34(%rsp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x34(%rsp)
movss 0x4c(%rsp), %xmm1
cvtsi2ssl 0x30(%rsp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movslq 0x24(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0xeb56
callq 0x1210
movq (%rax), %rax
movq 0x40(%rsp), %rcx
movslq 0x24(%rsp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xea06
jmp 0xeb46
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movslq 0x24(%rsp), %rcx
movsbl (%rax,%rcx), %esi
movss 0x4c(%rsp), %xmm0
movss 0x4c(%rsp), %xmm1
leaq 0x20(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x14(%rsp), %r9
callq 0x7b20
movl 0x34(%rsp), %eax
addl 0x1c(%rsp), %eax
movl %eax, 0x10(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0xeab2
movl 0x28(%rsp), %eax
movl 0x10(%rsp), %ecx
movq 0x50(%rsp), %rdx
imull (%rdx), %ecx
addl %ecx, %eax
movl %eax, 0xc(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
movslq 0xc(%rsp), %rax
addq %rax, %rsi
movl 0x18(%rsp), %edx
subl 0x20(%rsp), %edx
movl 0x14(%rsp), %ecx
subl 0x1c(%rsp), %ecx
movq 0x50(%rsp), %rax
movl (%rax), %r8d
movss 0x4c(%rsp), %xmm0
movss 0x4c(%rsp), %xmm1
movq 0x40(%rsp), %rax
movslq 0x24(%rsp), %r9
movsbl (%rax,%r9), %r9d
callq 0x8df0
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movslq 0x24(%rsp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x73c0
cvtsi2ssl 0x8(%rsp), %xmm0
movss 0x4c(%rsp), %xmm2
cvtsi2ssl 0x28(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x28(%rsp)
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movslq 0x24(%rsp), %rcx
movsbl (%rax,%rcx), %esi
movq 0x40(%rsp), %rax
movl 0x24(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
callq 0x7340
movl %eax, 0x4(%rsp)
cvtsi2ssl 0x4(%rsp), %xmm0
movss 0x4c(%rsp), %xmm2
cvtsi2ssl 0x28(%rsp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x28(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xe9cc
movl 0x28(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)