// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, %rbx
xorl %r15d, %r15d
movl $0x1, %esi
xorl %edx, %edx
callq 0x10e0
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x11e0
movl %eax, %ebp
movq %r14, %rdi
callq 0xed7a
testq %rax, %rax
je 0xf352
movq %rax, %r14
movslq 0x30(%rax), %r12
xorl %eax, %eax
testl %ebp, %ebp
setne %al
movl 0x34(%r14,%rax,4), %eax
movslq %eax, %r15
movq %r15, %r13
imulq %r12, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1070
movq %rax, %rbp
movl 0x44(%r14), %esi
shlq $0x6, %rsi
movq %rbx, %rdi
callq 0x1070
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq *0x48(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0x11d0
leaq 0x1914145(%rip), %rdx   # 0x1923090
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %rbp, 0x10(%rsp)
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1160
leaq 0x100180(%rip), %rdx    # 0x10f0f2
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10c0
leaq 0x100168(%rip), %rdx    # 0x10f0f9
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10c0
leaq 0x10014f(%rip), %rdx    # 0x10f0ff
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movl 0x3c(%r14), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x100136(%rip), %rdx    # 0x10f106
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movl 0x44(%r14), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x100123(%rip), %rdx    # 0x10f113
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
cmpl $0x0, 0x44(%r14)
je 0xf31e
movq 0x8(%rsp), %r13
addq $0x3c, %r13
xorl %ebp, %ebp
leaq 0x10014a(%rip), %r12    # 0x10f170
movl 0x40(%r14), %r15d
addl %ebp, %r15d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10c0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1000d3(%rip), %rdx    # 0x10f126
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x3c(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1000b8(%rip), %rdx    # 0x10f130
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x38(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x100096(%rip), %rdx    # 0x10f133
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x34(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x100074(%rip), %rdx    # 0x10f136
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x30(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x100052(%rip), %rdx    # 0x10f139
callq 0x10a0
movswl -0x2c(%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x10002d(%rip), %rdx    # 0x10f13c
callq 0x10a0
movswl -0x2a(%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x100008(%rip), %rdx    # 0x10f13f
callq 0x10a0
movswl -0x28(%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfffe3(%rip), %rdx     # 0x10f142
callq 0x10a0
movswl -0x26(%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfffbe(%rip), %rdx     # 0x10f145
callq 0x10a0
xorps %xmm0, %xmm0
cvtsi2sdl -0x24(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfff9c(%rip), %rdx     # 0x10f148
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x20(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfff7f(%rip), %rdx     # 0x10f150
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfff5e(%rip), %rdx     # 0x10f154
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x18(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfff3d(%rip), %rdx     # 0x10f158
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x14(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xfff1c(%rip), %rdx     # 0x10f15c
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x10(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xffefb(%rip), %rdx     # 0x10f160
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0xc(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xffeda(%rip), %rdx     # 0x10f164
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x8(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xffeb9(%rip), %rdx     # 0x10f168
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x4(%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xffe98(%rip), %rdx     # 0x10f16c
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd (%r13), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r12, %rdx
callq 0x10a0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r15, %rdx
callq 0x10f0
incq %rbp
movl 0x44(%r14), %eax
addq $0x40, %r13
cmpq %rax, %rbp
jb 0xf026
leaq 0xffdf8(%rip), %rdx     # 0x10f11d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
callq 0x1190
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x1190
movl $0x1, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq