// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %ecx, %r12d
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x34c32
movq 0x523e3(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c185(%rip), %rsi     # 0x70d9c
leaq 0x3c19c(%rip), %rdx     # 0x70dba
movl $0x4520, %ecx           # imm = 0x4520
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x30(%rbx)
jne 0x34c65
movq 0x523b0(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c152(%rip), %rsi     # 0x70d9c
leaq 0x3c169(%rip), %rdx     # 0x70dba
movl $0x4521, %ecx           # imm = 0x4521
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x38(%rbx)
jne 0x34c98
movq 0x5237d(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c11f(%rip), %rsi     # 0x70d9c
leaq 0x3c136(%rip), %rdx     # 0x70dba
movl $0x4522, %ecx           # imm = 0x4522
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x18(%rbx)
jne 0x34ccb
movq 0x5234a(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c0ec(%rip), %rsi     # 0x70d9c
leaq 0x3c103(%rip), %rdx     # 0x70dba
movl $0x4523, %ecx           # imm = 0x4523
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
cmpq $0x0, 0x20(%rbx)
jne 0x34cfe
movq 0x52317(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c0b9(%rip), %rsi     # 0x70d9c
leaq 0x3c0d0(%rip), %rdx     # 0x70dba
movl $0x4524, %ecx           # imm = 0x4524
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %r15, %r15
jne 0x34d2f
movq 0x522e6(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3c088(%rip), %rsi     # 0x70d9c
leaq 0x3c09f(%rip), %rdx     # 0x70dba
movl $0x4526, %ecx           # imm = 0x4526
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
testq %rbp, %rbp
je 0x34e8d
testq %r15, %r15
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x3540b
cmpq $0x0, 0x30(%rbx)
je 0x3540b
cmpq $0x0, 0x38(%rbx)
je 0x3540b
cmpq $0x0, 0x18(%rbx)
je 0x3540b
cmpq $0x0, 0x20(%rbx)
je 0x3540b
movl %r12d, 0x10(%rsp)
movl 0x188(%rbx), %eax
testl %eax, %eax
jne 0x34de7
movss 0x38b9d(%rip), %xmm0    # 0x6d92c
movq %rbx, %rdi
xorl %esi, %esi
callq 0x12e70
movq %rax, 0x170(%rbx)
movl 0x188(%rbx), %eax
testl %eax, %eax
jne 0x34de7
movq 0x5223f(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3bfe1(%rip), %rsi     # 0x70d9c
leaq 0x3bff8(%rip), %rdx     # 0x70dba
xorl %r12d, %r12d
movl $0x4532, %ecx           # imm = 0x4532
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
movl 0x188(%rbx), %eax
testl %eax, %eax
je 0x3540e
movq 0x180(%rbx), %r14
testq %r14, %r14
je 0x34ec1
movl %eax, (%rsp)
movq %rbp, 0x8(%rsp)
movl $0x0, 0x160(%rbx)
xorl %r13d, %r13d
leaq 0x38e31(%rip), %rbp     # 0x6dc44
movq %r14, %r12
movq 0x30(%r12), %rdi
testq %rdi, %rdi
jne 0x34e29
movq %rbp, 0x30(%r14)
movq 0x30(%r12), %rdi
callq 0x33378
addl %eax, %r13d
movq 0x30(%r12), %rdi
movl %eax, %esi
callq 0x567c7
movslq 0x160(%rbx), %rcx
cltq
addq %rcx, %rax
movl %eax, 0x160(%rbx)
movq 0x48(%r12), %r12
cmpq %r14, %r12
jne 0x34e16
movq (%r14), %r14
testq %r14, %r14
jne 0x34e13
movslq %r13d, %rcx
leaq (%rcx,%rcx,4), %rcx
movslq (%rsp), %rdx
imulq $0xb8, %rdx, %rdx
imulq $0x34, %rax, %rax
leaq (%rdx,%rcx,8), %rcx
leaq (%rax,%rcx), %r12
addq $0x98, %r12
movq 0x8(%rsp), %rbp
jmp 0x34efa
movq 0x5215c(%rip), %rbx     # 0x86ff0
movq (%rbx), %rdi
leaq 0x3befe(%rip), %rsi     # 0x70d9c
leaq 0x3bf15(%rip), %rdx     # 0x70dba
xorl %r12d, %r12d
movl $0x4527, %ecx           # imm = 0x4527
xorl %eax, %eax
callq 0x12d80
movq (%rbx), %rdi
callq 0x13780
jmp 0x3540e
movq 0x52128(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3beca(%rip), %rsi     # 0x70d9c
leaq 0x3bee1(%rip), %rdx     # 0x70dba
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 0x34f2e
movq %rax, %r14
leaq 0x28(%rbx), %rax
cmpq $0xb, %r12
movq %rax, 0x8(%rsp)
ja 0x34f5f
testq %r12, %r12
je 0x34fc1
movq %r14, %rdi
jmp 0x34fb7
movq 0x520bb(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3be5d(%rip), %rsi     # 0x70d9c
leaq 0x3be74(%rip), %rdx     # 0x70dba
movl $0x4538, %ecx           # imm = 0x4538
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
callq 0x13780
jmp 0x353d7
movq %r14, %r13
andq $0x3, %r14
je 0x34f8f
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 0x34f92
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 0x34fc1
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 0x8(%rsp), %r13
movups (%r13), %xmm0
movups %xmm0, (%r12)
movq 0x10(%r13), %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 0x3509c
movq 0x51f8e(%rip), %rax     # 0x86ff0
movq (%rax), %rdi
leaq 0x3bd30(%rip), %rsi     # 0x70d9c
leaq 0x3bd47(%rip), %rdx     # 0x70dba
movl $0x4540, %ecx           # imm = 0x4540
xorl %eax, %eax
callq 0x12d80
movq 0x51f6a(%rip), %rax     # 0x86ff0
movq (%rax), %rdi
callq 0x13780
cmpq $0x0, 0x168(%rbx)
je 0x353cd
leaq 0x40(%rbx), %r8
movl $0x1c00b5, 0x44(%rbx)   # imm = 0x1C00B5
movq 0x180(%rbx), %r9
movl 0x188(%rbx), %eax
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rbp, %rcx
movq %r8, (%rsp)
pushq %r13
pushq %rax
callq 0x35420
addq $0x10, %rsp
testl %eax, %eax
je 0x353cd
movq 0x18(%rsp), %rdx
movq 0x28(%rbx), %rdi
xorl %esi, %esi
callq *0x30(%rbx)
movq %rax, (%rbx)
testq %rax, %rax
jne 0x3512e
movq %r14, %r13
movq 0x51ef6(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3bc98(%rip), %rsi     # 0x70d9c
leaq 0x3bcaf(%rip), %rdx     # 0x70dba
movl $0x454d, %ecx           # imm = 0x454D
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
movq %r13, %r14
callq 0x13780
movq (%rbx), %rax
testq %rax, %rax
je 0x353cd
movl (%r15), %edx
movl (%rbp), %ecx
movq 0x168(%rbx), %r8
movl 0x160(%rbx), %r9d
movl 0x188(%rbx), %r10d
movq %r12, %rdi
movq %rax, %rsi
pushq %r10
pushq 0x180(%rbx)
callq 0x359eb
addq $0x10, %rsp
movl (%r15), %esi
movl (%rbp), %edx
movq (%rbx), %rdi
movq 0x40(%rbx), %rcx
callq 0x35f15
cmpl $0x1, 0x10(%rsp)
jne 0x351b9
movl (%r15), %eax
imull (%rbp), %eax
shll $0x2, %eax
movslq %eax, %rdx
movq 0x28(%rbx), %rdi
xorl %esi, %esi
callq *0x30(%rbx)
testq %rax, %rax
je 0x3539b
movq %rax, %r12
movl (%r15), %esi
movl (%rbp), %edx
movq (%rbx), %rcx
movq %rax, %rdi
callq 0x3603f
movq (%rbx), %rsi
movq 0x28(%rbx), %rdi
callq *0x38(%rbx)
movq %r12, (%rbx)
movq %r14, 0x10(%rsp)
movl (%r15), %eax
movl %eax, 0x8(%rbx)
movq %rbp, 0x8(%rsp)
movl (%rbp), %eax
movl %eax, 0xc(%rbx)
movq 0x178(%rbx), %r12
testq %r12, %r12
je 0x35318
movq 0x51e0a(%rip), %rbp     # 0x86ff0
xorl %r13d, %r13d
movq 0x78(%r12), %rcx
movq 0x168(%rbx), %rax
movq 0x38(%rcx), %r14
testq %rax, %rax
je 0x352b8
testq %r14, %r14
je 0x352e4
movss 0x20(%rcx), %xmm0
movl 0x40(%rcx), %esi
movups (%r14), %xmm1
movups 0x10(%r14), %xmm2
movaps %xmm2, 0x30(%rsp)
movaps %xmm1, 0x20(%rsp)
movq %r13, 0x60(%r12)
movaps 0x20(%rsp), %xmm1
movaps 0x30(%rsp), %xmm2
movups %xmm1, 0x30(%r12)
movups %xmm2, 0x40(%r12)
divss 0x30(%r12), %xmm0
movss %xmm0, 0x50(%r12)
movl 0xc(%r14), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x58(%r12)
movq %r13, 0x70(%r12)
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 0x215b5(%rip), %rax     # 0x5684b
movq %rax, 0x18(%r12)
movq %r12, 0x8(%r12)
leaq 0x216ee(%rip), %rax     # 0x56995
movq %rax, 0x20(%r12)
movq 0x70(%r12), %rax
movq %rax, 0x28(%r12)
jmp 0x3530b
movq (%rbp), %rdi
leaq 0x3bad9(%rip), %rsi     # 0x70d9c
leaq 0x3baf0(%rip), %rdx     # 0x70dba
movl $0x42b4, %ecx           # imm = 0x42B4
xorl %eax, %eax
callq 0x12d80
movq (%rbp), %rdi
callq 0x13780
testq %r14, %r14
jne 0x3530b
movq (%rbp), %rdi
leaq 0x3baad(%rip), %rsi     # 0x70d9c
leaq 0x3bac4(%rip), %rdx     # 0x70dba
movl $0x42b5, %ecx           # imm = 0x42B5
xorl %eax, %eax
callq 0x12d80
movq (%rbp), %rdi
callq 0x13780
movq (%r12), %r12
testq %r12, %r12
jne 0x351e9
movq (%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 0x3b875(%rip), %rax     # 0x70ba8
movl $0x60, %ecx
movq 0x8(%rsp), %rsi
movzwl (%r15), %edx
movw %dx, -0x10(%rbx,%rcx)
movzwl (%rsi), %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 0x3533d
movq 0x28(%rbx), %rdi
movq 0x10(%rsp), %rsi
callq *0x38(%rbx)
movq (%rbx), %r12
jmp 0x3540e
movq %r14, %r15
movq 0x51c4b(%rip), %r14     # 0x86ff0
movq (%r14), %rdi
leaq 0x3b9ed(%rip), %rsi     # 0x70d9c
leaq 0x3ba04(%rip), %rdx     # 0x70dba
movl $0x455b, %ecx           # imm = 0x455B
xorl %eax, %eax
callq 0x12d80
movq (%r14), %rdi
movq %r15, %r14
callq 0x13780
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq *0x38(%rbx)
movq 0x168(%rbx), %rsi
testq %rsi, %rsi
je 0x353f5
movq 0x10(%rbx), %rdi
callq *0x20(%rbx)
movq $0x0, 0x168(%rbx)
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x3540b
movq 0x28(%rbx), %rdi
callq *0x38(%rbx)
movq $0x0, (%rbx)
xorl %r12d, %r12d
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq