// File: /workspace/github_c_makefile_star2_O2/stetre[P]moonassimp/src/material.c
// Function: PushTexture
static int PushTexture(lua_State *L, material_t *material, unsigned int type, unsigned int index)
/* Pushes a table with all the texture properties */
    {
    int val;
    float floatval;
    vector3_t vec;
    struct aiUVTransform trafo;
    unsigned int max = sizeof(vector3_t);

    lua_newtable(L);
    pushtexturetype(L, type);
    lua_setfield(L, -2, "type");

    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_TEXFLAGS_BASE, type, index, &val, NULL)
        != AI_SUCCESS) val = 0;
    pushtextureflags(L, val, 1);
    lua_setfield(L, -2, "flags");

    if(GetString(L, material, _AI_MATKEY_TEXTURE_BASE, type, index)==1)
        lua_setfield(L, -2, "path");

    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_UVWSRC_BASE, type, index, &val, NULL)
        == AI_SUCCESS)
        {
        pushindex(L, val);
        lua_setfield(L, -2, "channel");
        }

    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_TEXOP_BASE, type, index, &val, NULL)
        == AI_SUCCESS)
        {
        pushtextureop(L, val);
        lua_setfield(L, -2, "op");
        }

    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_MAPPING_BASE, type, index, &val, NULL)
        == AI_SUCCESS)
        {
        pushtexturemapping(L, val);
        lua_setfield(L, -2, "mapping");
        }

    if(aiGetMaterialFloatArray(material, _AI_MATKEY_TEXBLEND_BASE, type, index, &floatval, NULL)
        == AI_SUCCESS)
        {
        lua_pushnumber(L, floatval);
        lua_setfield(L, -2, "blend");
        }

    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_MAPPINGMODE_U_BASE, type, index, &val, NULL)
        == AI_SUCCESS)
        {
        pushtexturemapmode(L, val);
        lua_setfield(L, -2, "mapmode_u");
        }
    if(aiGetMaterialIntegerArray(material, _AI_MATKEY_MAPPINGMODE_V_BASE, type, index, &val, NULL)
        == AI_SUCCESS)
        {
        pushtexturemapmode(L, val);
        lua_setfield(L, -2, "mapmode_v");
        }

    max = sizeof(vector3_t);
    if(AI_SUCCESS == aiGetMaterialFloatArray(material, _AI_MATKEY_TEXMAP_AXIS_BASE, type, index,
        (float*)&vec, &max) && sizeof(vector3_t) == max)
        {
        pushvector3(L, &vec, 1);
        lua_setfield(L, -2, "axis");
        }

    max = sizeof(struct aiUVTransform);
    if(AI_SUCCESS ==
        aiGetMaterialFloatArray(material, _AI_MATKEY_UVTRANSFORM_BASE, type, index,
        (float*)&trafo, &max) && sizeof(struct aiUVTransform) == max)
        {
        pushvector2(L, &(trafo.mTranslation), 1);
        lua_setfield(L, -2, "translation");
        pushvector2(L, &(trafo.mScaling), 1);
        lua_setfield(L, -2, "scaling");
        lua_pushnumber(L, trafo.mRotation);
        lua_setfield(L, -2, "rotation");
        }

    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl $0xc, 0x8(%rsp)
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
callq 0x6250
movq %rbx, %rdi
movl %r14d, %esi
callq 0x64c0
leaq 0x5263(%rip), %rdx      # 0x103c1
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5fd7(%rip), %rsi      # 0x11147
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
je 0xb190
andl $0x0, 0x4(%rsp)
jmp 0xb195
movl 0x4(%rsp), %r12d
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %r12d, %esi
callq 0x6200
leaq 0x50f3(%rip), %rdx      # 0x1029d
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5f1f(%rip), %rdx      # 0x110db
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %ecx
movl %ebp, %r8d
callq 0xaf8a
testl %eax, %eax
je 0xb1e3
leaq 0x5d45(%rip), %rdx      # 0x10f1d
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5efb(%rip), %rsi      # 0x110e5
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb221
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x64e0
leaq 0x5d14(%rip), %rdx      # 0x10f2a
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5ec9(%rip), %rsi      # 0x110f1
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb25f
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x6360
leaq 0x5ea2(%rip), %rdx      # 0x110f6
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5e93(%rip), %rsi      # 0x110f9
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb29d
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x6930
leaq 0x5e6c(%rip), %rdx      # 0x110fe
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5e62(%rip), %rsi      # 0x11106
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x67c0
testl %eax, %eax
jne 0xb2dd
cvtss2sd 0xc(%rsp), %xmm0
movq %rbx, %rdi
callq 0x6500
leaq 0x5d43(%rip), %rdx      # 0x11015
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5e2d(%rip), %rsi      # 0x11111
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb31b
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x66b0
leaq 0x5e42(%rip), %rdx      # 0x11152
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x5dfd(%rip), %rsi      # 0x1111f
leaq 0x4(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb359
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x66b0
leaq 0x5e0e(%rip), %rdx      # 0x1115c
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x8(%rsp), %r9
movl $0xc, (%r9)
leaq 0x5dc1(%rip), %rsi      # 0x1112d
leaq 0x10(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x67c0
testl %eax, %eax
jne 0xb3ab
cmpl $0xc, 0x8(%rsp)
jne 0xb3ab
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x6600
leaq 0x5bd3(%rip), %rdx      # 0x10f73
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x62e0
leaq 0x8(%rsp), %r9
movl $0x14, (%r9)
leaq 0x5d7c(%rip), %rsi      # 0x1113a
leaq 0x1c(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x67c0
testl %eax, %eax
jne 0xb447
cmpl $0x14, 0x8(%rsp)
jne 0xb447
leaq 0x1c(%rsp), %rsi
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6170
leaq 0x5b8c(%rip), %rdx      # 0x10f80
pushq $-0x2
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
callq 0x62e0
leaq 0x24(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x6170
leaq 0x5b78(%rip), %rdx      # 0x10f94
movq %rbx, %rdi
movl %r14d, %esi
callq 0x62e0
cvtss2sd 0x8(%r15), %xmm0
movq %rbx, %rdi
callq 0x6500
leaq 0x5b68(%rip), %rdx      # 0x10fa4
movq %rbx, %rdi
movl %r14d, %esi
callq 0x62e0
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq