// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl $0xc, 0x10(%rsp)
xorl %esi, %esi
xorl %edx, %edx
callq 0x6250
movq %rbx, %rdi
movl %r14d, %esi
callq 0x64b0
leaq 0x4f5c(%rip), %rdx      # 0x103c1
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5cce(%rip), %rsi      # 0x11147
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
je 0xb49a
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x6200
leaq 0x4deb(%rip), %rdx      # 0x1029d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5c15(%rip), %rdx      # 0x110db
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %ecx
movl %ebp, %r8d
callq 0xb287
testl %eax, %eax
je 0xb4ef
leaq 0x5a3b(%rip), %rdx      # 0x10f1d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5bef(%rip), %rsi      # 0x110e5
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb52f
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x64d0
leaq 0x5a08(%rip), %rdx      # 0x10f2a
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5bbb(%rip), %rsi      # 0x110f1
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb56f
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6360
leaq 0x5b94(%rip), %rdx      # 0x110f6
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5b83(%rip), %rsi      # 0x110f9
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb5af
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6930
leaq 0x5b5c(%rip), %rdx      # 0x110fe
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5b50(%rip), %rsi      # 0x11106
leaq 0x14(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x67c0
testl %eax, %eax
jne 0xb5f1
cvtss2sd 0x14(%rsp), %xmm0
movq %rbx, %rdi
callq 0x64f0
leaq 0x5a31(%rip), %rdx      # 0x11015
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5b19(%rip), %rsi      # 0x11111
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb631
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x66b0
leaq 0x5b2e(%rip), %rdx      # 0x11152
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x5ae7(%rip), %rsi      # 0x1111f
leaq 0xc(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x6290
testl %eax, %eax
jne 0xb671
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x66b0
leaq 0x5af8(%rip), %rdx      # 0x1115c
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x10(%rsp), %r9
movl $0xc, (%r9)
leaq 0x5aa9(%rip), %rsi      # 0x1112d
leaq 0x18(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x67c0
testl %eax, %eax
jne 0xb6c7
cmpl $0xc, 0x10(%rsp)
jne 0xb6c7
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x6600
leaq 0x58b9(%rip), %rdx      # 0x10f73
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x10(%rsp), %r9
movl $0x14, (%r9)
leaq 0x5a60(%rip), %rsi      # 0x1113a
leaq 0x24(%rsp), %r8
movq %r15, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x67c0
testl %eax, %eax
jne 0xb768
cmpl $0x14, 0x10(%rsp)
jne 0xb768
leaq 0x24(%rsp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x6170
leaq 0x5870(%rip), %rdx      # 0x10f80
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
leaq 0x2c(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x6170
leaq 0x585b(%rip), %rdx      # 0x10f94
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
cvtss2sd 0x8(%r14), %xmm0
movq %rbx, %rdi
callq 0x64f0
leaq 0x5849(%rip), %rdx      # 0x10fa4
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x62e0
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop