// File: /workspace/github_cpp_makefile_star2_O2/stetre[P]moonfonts/src/fonts.c
// Function: Load
static int Load(lua_State *L)
    {
    int width, height;
    unsigned int i, codepoint;
    unsigned char **pixels ; /* [height][width] */
    stb_fontchar *fontchar; /* [num_chars] */ 
    const char *name = luaL_checkstring(L, 1);
    int height_pow2 = optboolean(L, 2, 0);

    font_t *font = font_search(L, name);
    if(!font)
        return 0;

    width = font->width;
    height = height_pow2 ? font->height_pow2 : font->height;
    pixels = (unsigned char**)Malloc(L, sizeof(unsigned char) * width * height);
    fontchar = (stb_fontchar*)Malloc(L, sizeof(stb_fontchar) * font->num_chars);
    font->create(fontchar, (unsigned char (*)[])(pixels), height);

    lua_newtable(L);

    lua_pushstring(L, font->name);
    lua_setfield(L, -2, "name");

    lua_pushlstring(L, (const char*)pixels, sizeof(unsigned char) * width * height);
    lua_setfield(L, -2, "pixels");

    lua_pushinteger(L, width);
    lua_setfield(L, -2, "width");
    lua_pushinteger(L, height);
    lua_setfield(L, -2, "height");
    lua_pushinteger(L, font->line_spacing);
    lua_setfield(L, -2, "line_spacing");
    lua_pushinteger(L, font->num_chars);
    lua_setfield(L, -2, "num_chars");
/*
    lua_pushinteger(L, font->first_char);
    lua_setfield(L, -2, "first_char");
*/

    lua_newtable(L); /* chars data */

    for(i=0; i < font->num_chars; i++)
        {
        codepoint = i + font->first_char;
        pushfontchar(L, &fontchar[i], codepoint);
        lua_seti(L, -2, codepoint);
        }
    lua_setfield(L, -2, "fontchar");

    Free(L, (char*)pixels);
    Free(L, (char*)fontchar);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
xorl %r15d, %r15d
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x10e0
movq %rax, %r14
pushq $0x2
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11e0
movl %eax, %ebp
movq %r14, %rdi
callq 0xdaf4
testq %rax, %rax
je 0xdae2
movq %rax, %r14
movslq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
xorl %eax, %eax
testl %ebp, %ebp
setne %al
movl 0xc(%r14,%rax,4), %eax
movslq %eax, %r12
movq %r12, %rbp
movq %r12, 0x10(%rsp)
imulq %rcx, %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1070
movq %rax, %r15
movl 0x1c(%r14), %esi
shlq $0x6, %rsi
movq %rbx, %rdi
callq 0x1070
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq *0x20(%r14)
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x11d0
leaq 0x18a78e4(%rip), %rdx   # 0x18b5040
pushq $-0x2
popq %r13
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movq %rbx, %rdi
movq %r15, 0x20(%rsp)
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1160
leaq 0x9391f(%rip), %rdx     # 0xa10a4
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x10c0
leaq 0x93907(%rip), %rdx     # 0xa10ab
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x10c0
leaq 0x938ee(%rip), %rdx     # 0xa10b1
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movl 0x14(%r14), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x938d7(%rip), %rdx     # 0xa10b8
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movl 0x1c(%r14), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x938c6(%rip), %rdx     # 0xa10c5
movq %rbx, %rdi
movl %r13d, %esi
callq 0x10a0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq 0x8(%rsp), %rbp
addq $0x3c, %rbp
movl 0x1c(%r14), %eax
cmpq %rax, %r12
jae 0xdab0
movl 0x18(%r14), %r15d
addl %r12d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10c0
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93881(%rip), %rdx     # 0xa10d8
callq 0x10a0
cvtss2sd -0x3c(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x9386c(%rip), %rdx     # 0xa10e2
callq 0x10a0
cvtss2sd -0x38(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93850(%rip), %rdx     # 0xa10e5
callq 0x10a0
cvtss2sd -0x34(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93834(%rip), %rdx     # 0xa10e8
callq 0x10a0
cvtss2sd -0x30(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93818(%rip), %rdx     # 0xa10eb
callq 0x10a0
movswl -0x2c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x937f9(%rip), %rdx     # 0xa10ee
callq 0x10a0
movswl -0x2a(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x937da(%rip), %rdx     # 0xa10f1
callq 0x10a0
movswl -0x28(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x937bb(%rip), %rdx     # 0xa10f4
callq 0x10a0
movswl -0x26(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x9379c(%rip), %rdx     # 0xa10f7
callq 0x10a0
cvtsi2sdl -0x24(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93780(%rip), %rdx     # 0xa10fa
callq 0x10a0
cvtss2sd -0x20(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93769(%rip), %rdx     # 0xa1102
callq 0x10a0
cvtss2sd -0x1c(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x9374e(%rip), %rdx     # 0xa1106
callq 0x10a0
cvtss2sd -0x18(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93733(%rip), %rdx     # 0xa110a
callq 0x10a0
cvtss2sd -0x14(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93718(%rip), %rdx     # 0xa110e
callq 0x10a0
cvtss2sd -0x10(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x936fd(%rip), %rdx     # 0xa1112
callq 0x10a0
cvtss2sd -0xc(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x936e2(%rip), %rdx     # 0xa1116
callq 0x10a0
cvtss2sd -0x8(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x936c7(%rip), %rdx     # 0xa111a
callq 0x10a0
cvtss2sd -0x4(%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x936ac(%rip), %rdx     # 0xa111e
callq 0x10a0
cvtss2sd (%rbp), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x93691(%rip), %rdx     # 0xa1122
callq 0x10a0
movq %rbx, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x10f0
incq %r12
addq $0x40, %rbp
jmp 0xd81f
leaq 0x93618(%rip), %rdx     # 0xa10cf
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x10a0
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x1190
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x1190
pushq $0x1
popq %rax
movl %eax, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq