// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonassimp/src/material.c
// Function: AllTextures
static int AllTextures(lua_State *L)
    {
    unsigned int count, i, tot;
    unsigned int type;
    material_t *material = checkmaterial(L, 1);
#define ADD(t) do {                                     \
    count = aiGetMaterialTextureCount(material, t);     \
    for(i=0; i < count; i++)                            \
        {                                               \
        PushTexture(L, material, t, i);                 \
        lua_rawseti(L, -2, ++tot);                      \
        }                                               \
} while(0)

    tot = 0;
    if(!lua_isnoneornil(L, 2))
        {
        lua_newtable(L);
        type = checktexturetype(L, 2);
        ADD((enum aiTextureType)type);
        }
    else
        {
        lua_newtable(L);
//      ADD(aiTextureType_NONE);
        ADD(aiTextureType_DIFFUSE);
        ADD(aiTextureType_SPECULAR);
        ADD(aiTextureType_AMBIENT);
        ADD(aiTextureType_EMISSIVE);
        ADD(aiTextureType_HEIGHT);
        ADD(aiTextureType_NORMALS);
        ADD(aiTextureType_SHININESS);
        ADD(aiTextureType_OPACITY);
        ADD(aiTextureType_DISPLACEMENT);
        ADD(aiTextureType_LIGHTMAP);
        ADD(aiTextureType_REFLECTION);
        ADD(aiTextureType_UNKNOWN);
        }
#undef ADD
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x607a(%rip), %rdx      # 0x10e90
movl $0x1, %esi
callq 0x66f0
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x68d0
movl %eax, %ebp
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6250
testl %ebp, %ebp
jle 0xae96
movq %rbx, %rdi
movl $0x2, %esi
callq 0x6750
movl %eax, %ebp
movq %r14, %rdi
movl %eax, %esi
callq 0x67b0
testl %eax, %eax
je 0xb1e6
movl %eax, %r12d
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %r15d, %ecx
callq 0xb3a0
incq %r15
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r15, %rdx
callq 0x6470
cmpq %r15, %r12
jne 0xae69
jmp 0xb1e6
movq %r14, %rdi
movl $0x1, %esi
callq 0x67b0
movl %eax, %r15d
testl %eax, %eax
je 0xaedb
movl %r15d, %r13d
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl %r12d, %ecx
callq 0xb3a0
incq %r12
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movq %r12, %rdx
callq 0x6470
cmpq %r12, %r13
jne 0xaeb0
movq %r14, %rdi
movl $0x2, %esi
callq 0x67b0
testl %eax, %eax
je 0xaf22
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xaef1
addl %r12d, %r15d
movq %r14, %rdi
movl $0x3, %esi
callq 0x67b0
testl %eax, %eax
je 0xaf69
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xaf38
addl %r12d, %r15d
movq %r14, %rdi
movl $0x4, %esi
callq 0x67b0
testl %eax, %eax
je 0xafb0
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xaf7f
addl %r12d, %r15d
movq %r14, %rdi
movl $0x5, %esi
callq 0x67b0
testl %eax, %eax
je 0xaff7
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x5, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xafc6
addl %r12d, %r15d
movq %r14, %rdi
movl $0x6, %esi
callq 0x67b0
testl %eax, %eax
je 0xb03e
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x6, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb00d
addl %r12d, %r15d
movq %r14, %rdi
movl $0x7, %esi
callq 0x67b0
testl %eax, %eax
je 0xb085
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x7, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb054
addl %r12d, %r15d
movq %r14, %rdi
movl $0x8, %esi
callq 0x67b0
testl %eax, %eax
je 0xb0cc
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x8, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb09b
addl %r12d, %r15d
movq %r14, %rdi
movl $0x9, %esi
callq 0x67b0
testl %eax, %eax
je 0xb113
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x9, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb0e2
addl %r12d, %r15d
movq %r14, %rdi
movl $0xa, %esi
callq 0x67b0
testl %eax, %eax
je 0xb15a
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0xa, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb129
addl %r12d, %r15d
movq %r14, %rdi
movl $0xb, %esi
callq 0x67b0
testl %eax, %eax
je 0xb1a1
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0xb, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r12,%r15), %edx
incl %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb170
addl %r12d, %r15d
movq %r14, %rdi
movl $0x12, %esi
callq 0x67b0
testl %eax, %eax
je 0xb1e6
movl %eax, %ebp
incl %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x12, %edx
movl %r12d, %ecx
callq 0xb3a0
leal (%r15,%r12), %edx
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6470
incl %r12d
cmpl %r12d, %ebp
jne 0xb1ba
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq