// File: /workspace/github_c_makefile_star2_O1/stetre[P]moonnuklear/src/./nuklear/nuklear.h
// Function: nk_font_atlas_bake
NK_API const void*
nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,
    enum nk_font_atlas_format fmt)
{
    int i = 0;
    void *tmp = 0;
    nk_size tmp_size, img_size;
    struct nk_font *font_iter;
    struct nk_font_baker *baker;

    NK_ASSERT(atlas);
    NK_ASSERT(atlas->temporary.alloc);
    NK_ASSERT(atlas->temporary.free);
    NK_ASSERT(atlas->permanent.alloc);
    NK_ASSERT(atlas->permanent.free);

    NK_ASSERT(width);
    NK_ASSERT(height);
    if (!atlas || !width || !height ||
        !atlas->temporary.alloc || !atlas->temporary.free ||
        !atlas->permanent.alloc || !atlas->permanent.free)
        return 0;

#ifdef NK_INCLUDE_DEFAULT_FONT
    /* no font added so just use default font */
    if (!atlas->font_num)
        atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
#endif
    NK_ASSERT(atlas->font_num);
    if (!atlas->font_num) return 0;

    /* allocate temporary baker memory required for the baking process */
    nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
    tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
    NK_ASSERT(tmp);
    if (!tmp) goto failed;
    NK_MEMSET(tmp,0,tmp_size);

    /* allocate glyph memory for all fonts */
    baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
    atlas->glyphs = (struct nk_font_glyph*)atlas->permanent.alloc(
        atlas->permanent.userdata,0, sizeof(struct nk_font_glyph)*(nk_size)atlas->glyph_count);
    NK_ASSERT(atlas->glyphs);
    if (!atlas->glyphs)
        goto failed;

    /* pack all glyphs into a tight fit space */
    atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
    atlas->custom.h = NK_CURSOR_DATA_H + 1;
    if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
        atlas->config, atlas->font_num, &atlas->temporary))
        goto failed;

    /* allocate memory for the baked image font atlas */
    atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
    NK_ASSERT(atlas->pixel);
    if (!atlas->pixel)
        goto failed;

    /* bake glyphs and custom white pixel into image */
    nk_font_bake(baker, atlas->pixel, *width, *height,
        atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
    nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
            nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H, '.', 'X');

    if (fmt == NK_FONT_ATLAS_RGBA32) {
        /* convert alpha8 image into rgba32 image */
        void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
                            (nk_size)(*width * *height * 4));
        NK_ASSERT(img_rgba);
        if (!img_rgba) goto failed;
        nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
        atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
        atlas->pixel = img_rgba;
    }
    atlas->tex_width = *width;
    atlas->tex_height = *height;

    /* initialize each font */
    for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
        struct nk_font *font = font_iter;
        struct nk_font_config *config = font->config;
        nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
            config->font, nk_handle_ptr(0));
    }

    /* initialize each cursor */
    {NK_STORAGE const struct nk_vec2 nk_cursor_data[NK_CURSOR_COUNT][3] = {
        /* Pos      Size        Offset */
        {{ 0, 3},   {12,19},    { 0, 0}},
        {{13, 0},   { 7,16},    { 4, 8}},
        {{31, 0},   {23,23},    {11,11}},
        {{21, 0},   { 9, 23},   { 5,11}},
        {{55,18},   {23, 9},    {11, 5}},
        {{73, 0},   {17,17},    { 9, 9}},
        {{55, 0},   {17,17},    { 9, 9}}
    };
    for (i = 0; i < NK_CURSOR_COUNT; ++i) {
        struct nk_cursor *cursor = &atlas->cursors[i];
        cursor->img.w = (unsigned short)*width;
        cursor->img.h = (unsigned short)*height;
        cursor->img.region[0] = (unsigned short)(atlas->custom.x + nk_cursor_data[i][0].x);
        cursor->img.region[1] = (unsigned short)(atlas->custom.y + nk_cursor_data[i][0].y);
        cursor->img.region[2] = (unsigned short)nk_cursor_data[i][1].x;
        cursor->img.region[3] = (unsigned short)nk_cursor_data[i][1].y;
        cursor->size = nk_cursor_data[i][1];
        cursor->offset = nk_cursor_data[i][2];
    }}
    /* free temporary memory */
    atlas->temporary.free(atlas->temporary.userdata, tmp);
    return atlas->pixel;

failed:
    /* error so cleanup all memory */
    if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
    if (atlas->glyphs) {
        atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
        atlas->glyphs = 0;
    }
    if (atlas->pixel) {
        atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
        atlas->pixel = 0;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r12d
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x3512f
movq 0x52ee6(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cc78(%rip), %rsi     # 0x71d8c
leaq 0x3cc8f(%rip), %rdx     # 0x71daa
movl $0x4520, %ecx           # imm = 0x4520
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x30(%rbx)
jne 0x35162
movq 0x52eb3(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cc45(%rip), %rsi     # 0x71d8c
leaq 0x3cc5c(%rip), %rdx     # 0x71daa
movl $0x4521, %ecx           # imm = 0x4521
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x38(%rbx)
jne 0x35195
movq 0x52e80(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cc12(%rip), %rsi     # 0x71d8c
leaq 0x3cc29(%rip), %rdx     # 0x71daa
movl $0x4522, %ecx           # imm = 0x4522
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x18(%rbx)
jne 0x351c8
movq 0x52e4d(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cbdf(%rip), %rsi     # 0x71d8c
leaq 0x3cbf6(%rip), %rdx     # 0x71daa
movl $0x4523, %ecx           # imm = 0x4523
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x20(%rbx)
jne 0x351fb
movq 0x52e1a(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cbac(%rip), %rsi     # 0x71d8c
leaq 0x3cbc3(%rip), %rdx     # 0x71daa
movl $0x4524, %ecx           # imm = 0x4524
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r15, %r15
jne 0x3522c
movq 0x52de9(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cb7b(%rip), %rsi     # 0x71d8c
leaq 0x3cb92(%rip), %rdx     # 0x71daa
movl $0x4526, %ecx           # imm = 0x4526
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %rbp, %rbp
jne 0x3525d
movq 0x52db8(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3cb4a(%rip), %rsi     # 0x71d8c
leaq 0x3cb61(%rip), %rdx     # 0x71daa
movl $0x4527, %ecx           # imm = 0x4527
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %rbp, %rbp
sete %al
testq %r15, %r15
sete %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
orb %al, %dl
jne 0x3589f
cmpq $0x0, 0x30(%rbx)
je 0x3589f
cmpq $0x0, 0x38(%rbx)
je 0x3589f
cmpq $0x0, 0x18(%rbx)
je 0x3589f
cmpq $0x0, 0x20(%rbx)
je 0x3589f
cmpl $0x0, 0x188(%rbx)
jne 0x352c7
movss 0x3968a(%rip), %xmm0    # 0x6e940
movq %rbx, %rdi
xorl %esi, %esi
callq 0x12e70
movq %rax, 0x170(%rbx)
cmpl $0x0, 0x188(%rbx)
jne 0x352fc
movq 0x52d19(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3caab(%rip), %rsi     # 0x71d8c
leaq 0x3cac2(%rip), %rdx     # 0x71daa
movl $0x4532, %ecx           # imm = 0x4532
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movslq 0x188(%rbx), %rax
testq %rax, %rax
je 0x3589f
movl %r12d, 0xc(%rsp)
movq 0x180(%rbx), %r14
testq %r14, %r14
je 0x353ad
movq %rax, 0x10(%rsp)
movq %rbp, (%rsp)
movl $0x0, 0x160(%rbx)
xorl %ebp, %ebp
leaq 0x398f3(%rip), %r12     # 0x6ec30
movq %r14, %r13
cmpq $0x0, 0x30(%r13)
jne 0x3534b
movq %r12, 0x30(%r14)
movq 0x30(%r13), %rdi
callq 0x33805
addl %eax, %ebp
movq 0x30(%r13), %rdi
movl %eax, %esi
callq 0x573bd
movslq 0x160(%rbx), %rcx
cltq
addq %rcx, %rax
movl %eax, 0x160(%rbx)
movq 0x48(%r13), %r13
cmpq %r14, %r13
jne 0x35340
movq (%r14), %r14
testq %r14, %r14
jne 0x3533d
movslq %ebp, %rcx
leaq (%rcx,%rcx,4), %rcx
imulq $0xb8, 0x10(%rsp), %rdx
imulq $0x34, %rax, %rax
leaq (%rdx,%rcx,8), %rcx
leaq (%rax,%rcx), %r12
addq $0x98, %r12
movq (%rsp), %rbp
jmp 0x353e6
movq 0x52c3c(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c9ce(%rip), %rsi     # 0x71d8c
leaq 0x3c9e5(%rip), %rdx     # 0x71daa
xorl %r12d, %r12d
movl $0x4113, %ecx           # imm = 0x4113
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl $0x0, 0x160(%rbx)
movq 0x28(%rbx), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq *0x30(%rbx)
testq %rax, %rax
je 0x3541a
movq %rax, %r14
leaq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
cmpq $0xb, %r12
ja 0x3544b
testq %r12, %r12
je 0x354ad
movq %r14, %rdi
jmp 0x354a3
movq 0x52bcf(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c961(%rip), %rsi     # 0x71d8c
leaq 0x3c978(%rip), %rdx     # 0x71daa
movl $0x4538, %ecx           # imm = 0x4538
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
jmp 0x3586b
movq %r14, %r13
andq $0x3, %r14
je 0x3547b
movl $0x4, %edx
subq %r14, %rdx
movq %rdx, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x12b50
subq (%rsp), %r12
negq %r14
leaq (%r14,%r13), %rdi
addq $0x4, %rdi
jmp 0x3547e
movq %r13, %rdi
movq %r13, %r14
movq %r12, %r13
andq $-0x4, %r13
movq %rdi, (%rsp)
xorl %esi, %esi
movq %r13, %rdx
callq 0x12b50
andq $0x3, %r12
je 0x354ad
movq (%rsp), %rdi
addq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x12b50
movslq 0x160(%rbx), %rax
movslq 0x188(%rbx), %rcx
movq %r14, %r12
addq $0x7, %r12
andq $-0x8, %r12
leaq 0x7f(%r12), %rdx
andq $-0x8, %rdx
movq %rdx, 0x58(%r12)
imulq $0xb8, %rcx, %rcx
addq %rdx, %rcx
movq %rcx, 0x60(%r12)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
addq %rcx, %rdx
movq %rdx, 0x68(%r12)
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0x7, %rax
andq $-0x8, %rax
movq %rax, 0x70(%r12)
movq 0x10(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, (%r12)
movq 0x10(%rax), %rax
movq %rax, 0x10(%r12)
movslq 0x160(%rbx), %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdx
movq 0x10(%rbx), %rdi
xorl %esi, %esi
callq *0x18(%rbx)
movq %rax, 0x168(%rbx)
testq %rax, %rax
jne 0x35577
movq %r14, %r13
movq 0x52aa1(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c833(%rip), %rsi     # 0x71d8c
leaq 0x3c84a(%rip), %rdx     # 0x71daa
movl $0x4540, %ecx           # imm = 0x4540
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
movq %r13, %r14
callq 0x13780
cmpq $0x0, 0x168(%rbx)
je 0x35861
leaq 0x40(%rbx), %r8
movl $0x1c00b5, 0x44(%rbx)   # imm = 0x1C00B5
movq 0x180(%rbx), %r9
movl 0x188(%rbx), %eax
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rbp, %rcx
movq %r8, 0x20(%rsp)
pushq 0x10(%rsp)
pushq %rax
callq 0x35937
addq $0x10, %rsp
testl %eax, %eax
je 0x35861
movq 0x28(%rsp), %rdx
movq 0x28(%rbx), %rdi
xorl %esi, %esi
callq *0x30(%rbx)
movq %rax, (%rbx)
testq %rax, %rax
jne 0x3560e
movq %r14, %r13
movq 0x52a0a(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c79c(%rip), %rsi     # 0x71d8c
leaq 0x3c7b3(%rip), %rdx     # 0x71daa
movl $0x454d, %ecx           # imm = 0x454D
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
movq %r13, %r14
callq 0x13780
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x35861
movl (%r15), %edx
movl (%rbp), %ecx
movq 0x168(%rbx), %r8
movl 0x160(%rbx), %r9d
movl 0x188(%rbx), %eax
movq %r12, %rdi
pushq %rax
pushq 0x180(%rbx)
callq 0x35f03
addq $0x10, %rsp
movl (%r15), %esi
movl (%rbp), %edx
movq (%rbx), %rdi
movq 0x40(%rbx), %rcx
callq 0x36491
cmpl $0x1, 0xc(%rsp)
jne 0x356f0
movl (%r15), %eax
imull (%rbp), %eax
shll $0x2, %eax
movslq %eax, %rdx
movq 0x28(%rbx), %rdi
xorl %r13d, %r13d
xorl %esi, %esi
callq *0x30(%rbx)
testq %rax, %rax
je 0x356a5
movq %rax, %r12
movl (%r15), %esi
movl (%rbp), %edx
movq (%rbx), %rcx
movq %rax, %rdi
callq 0x365bd
movq (%rbx), %rsi
movq 0x28(%rbx), %rdi
callq *0x38(%rbx)
movq %r12, (%rbx)
jmp 0x356dd
movq %r14, %r12
movq 0x52941(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c6d3(%rip), %rsi     # 0x71d8c
leaq 0x3c6ea(%rip), %rdx     # 0x71daa
movl $0x455b, %ecx           # imm = 0x455B
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
movq %r12, %r14
callq 0x13780
movl $0x14, %r13d
cmpl $0x14, %r13d
je 0x35861
testl %r13d, %r13d
jne 0x358a1
movq %r14, 0x18(%rsp)
movl (%r15), %eax
movl %eax, 0x8(%rbx)
movq %rbp, (%rsp)
movl (%rbp), %eax
movl %eax, 0xc(%rbx)
movq 0x178(%rbx), %r12
testq %r12, %r12
je 0x358b0
movq 0x78(%r12), %rax
movss 0x20(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x40(%rax), %ecx
movl %ecx, 0x10(%rsp)
movq 0x168(%rbx), %r13
movq 0x38(%rax), %rbp
testq %r13, %r13
jne 0x35768
movq 0x528ad(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c63f(%rip), %rsi     # 0x71d8c
leaq 0x3c656(%rip), %rdx     # 0x71daa
movl $0x42b4, %ecx           # imm = 0x42B4
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %rbp, %rbp
jne 0x35799
movq 0x5287c(%rip), %r14     # 0x87ff0
movq (%r14), %rdi
leaq 0x3c60e(%rip), %rsi     # 0x71d8c
leaq 0x3c625(%rip), %rdx     # 0x71daa
movl $0x42b5, %ecx           # imm = 0x42B5
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r13, %r13
je 0x35858
testq %rbp, %rbp
je 0x35858
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x60(%r12)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm0, 0x30(%r12)
movups %xmm1, 0x40(%r12)
movss 0xc(%rsp), %xmm0
divss 0x30(%r12), %xmm0
movss %xmm0, 0x50(%r12)
movl 0xc(%rbp), %eax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rax, %r13
movq %r13, 0x58(%r12)
movq %rcx, 0x70(%r12)
movl 0x10(%rsp), %esi
movl %esi, 0x68(%r12)
movq %r12, %rdi
callq 0x13fb0
movq %rax, 0x60(%r12)
movss 0x30(%r12), %xmm0
mulss 0x50(%r12), %xmm0
movss %xmm0, 0x10(%r12)
leaq 0x21c09(%rip), %rax     # 0x57441
movq %rax, 0x18(%r12)
movq %r12, 0x8(%r12)
leaq 0x21d40(%rip), %rax     # 0x57589
movq %rax, 0x20(%r12)
movq 0x70(%r12), %rax
movq %rax, 0x28(%r12)
movq (%r12), %r12
jmp 0x3570c
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq *0x38(%rbx)
movq 0x168(%rbx), %rsi
testq %rsi, %rsi
je 0x35889
movq 0x10(%rbx), %rdi
callq *0x20(%rbx)
movq $0x0, 0x168(%rbx)
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x3589f
movq 0x28(%rbx), %rdi
callq *0x38(%rbx)
movq $0x0, (%rbx)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rsp), %rax
movq (%rax), %xmm0
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
psrad $0x10, %xmm0
cvtdq2ps %xmm0, %xmm0
leaq 0x3c2cc(%rip), %rax     # 0x71b98
movl $0x60, %ecx
movq (%rsp), %r14
movzwl (%r15), %edx
movw %dx, -0x10(%rbx,%rcx)
movzwl (%r14), %edx
movw %dx, -0xe(%rbx,%rcx)
movsd -0x8(%rax), %xmm1
addps %xmm0, %xmm1
movhps (%rax), %xmm1           # xmm1 = xmm1[0,1],mem[0,1]
cvttps2dq %xmm1, %xmm1
pshuflw $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3,4,5,6,7]
pshufhw $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,1,2,3,4,6,6,7]
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
movq %xmm1, -0xc(%rbx,%rcx)
movups (%rax), %xmm1
movups %xmm1, (%rbx,%rcx)
addq $0x18, %rax
addq $0x28, %rcx
cmpq $0x178, %rcx            # imm = 0x178
jne 0x358d5
movq 0x28(%rbx), %rdi
movq 0x18(%rsp), %rsi
callq *0x38(%rbx)
movq (%rbx), %rax
jmp 0x358a1