// File: /workspace/github_cpp_makefile_star2_O1/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 %r14d, %r14d
movl $0x1, %esi
xorl %edx, %edx
callq 0x10e0
movq %rax, %r15
movq %rbx, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x11e0
movl %eax, %ebp
movq %r15, %rdi
callq 0xed64
leaq 0x28(%rax), %r13
testq %rax, %rax
cmoveq %rax, %r13
je 0xf352
movslq 0x8(%r13), %r15
xorl %eax, %eax
testl %ebp, %ebp
setne %al
movl 0xc(%r13,%rax,4), %eax
movslq %eax, %r14
movq %r14, %r12
imulq %r15, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1070
movq %rax, %rbp
movl 0x1c(%r13), %esi
shlq $0x6, %rsi
movq %rbx, %rdi
callq 0x1070
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
movl %r14d, %edx
callq *0x20(%r13)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq (%r13), %rsi
movq %rbx, %rdi
callq 0x11d0
leaq 0x193e776(%rip), %rdx   # 0x194d6b0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %rbp, 0x10(%rsp)
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1160
leaq 0x105193(%rip), %rdx    # 0x1140f4
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10c0
leaq 0x10517b(%rip), %rdx    # 0x1140fb
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10c0
leaq 0x105162(%rip), %rdx    # 0x114101
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movl 0x14(%r13), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x105149(%rip), %rdx    # 0x114108
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movl 0x1c(%r13), %esi
movq %rbx, %rdi
callq 0x10c0
leaq 0x105136(%rip), %rdx    # 0x114115
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10a0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
cmpl $0x0, 0x1c(%r13)
je 0xf31e
movq 0x8(%rsp), %r12
addq $0x3c, %r12
xorl %ebp, %ebp
leaq 0x10515d(%rip), %r15    # 0x114172
movl 0x18(%r13), %r14d
addl %ebp, %r14d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1090
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10c0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1050e6(%rip), %rdx    # 0x114128
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x3c(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1050ca(%rip), %rdx    # 0x114132
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x38(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1050a7(%rip), %rdx    # 0x114135
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x34(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x105084(%rip), %rdx    # 0x114138
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x30(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x105061(%rip), %rdx    # 0x11413b
callq 0x10a0
movswl -0x2c(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x10503b(%rip), %rdx    # 0x11413e
callq 0x10a0
movswl -0x2a(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x105015(%rip), %rdx    # 0x114141
callq 0x10a0
movswl -0x28(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104fef(%rip), %rdx    # 0x114144
callq 0x10a0
movswl -0x26(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104fc9(%rip), %rdx    # 0x114147
callq 0x10a0
xorps %xmm0, %xmm0
cvtsi2sdl -0x24(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104fa6(%rip), %rdx    # 0x11414a
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x20(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104f88(%rip), %rdx    # 0x114152
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104f66(%rip), %rdx    # 0x114156
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x18(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104f44(%rip), %rdx    # 0x11415a
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x14(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104f22(%rip), %rdx    # 0x11415e
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x10(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104f00(%rip), %rdx    # 0x114162
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0xc(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104ede(%rip), %rdx    # 0x114166
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x8(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104ebc(%rip), %rdx    # 0x11416a
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd -0x4(%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104e9a(%rip), %rdx    # 0x11416e
callq 0x10a0
xorps %xmm0, %xmm0
cvtss2sd (%r12), %xmm0
movq %rbx, %rdi
callq 0x1130
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r15, %rdx
callq 0x10a0
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r14, %rdx
callq 0x10f0
incq %rbp
movl 0x1c(%r13), %eax
addq $0x40, %r12
cmpq %rax, %rbp
jb 0xf015
leaq 0x104dfa(%rip), %rdx    # 0x11411f
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, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq