// File: Olverine[P]TerminalGraphics/Main.cpp
// Function: main
int main(int argc, char* argv[]) {
    vec4* shape = loadShape(argv[1]);
    initViewPort();

    mat4 model = mat4(1.0);
    mat4 view = getView(vec3(0, 0, 1), vec3(0, 0, 0), vec3(0, 1, 0)); 
    mat4 projection = getPerspective(radians(90.0f), 0.1, 500);

    float rotX = 0;
    float rotY = 0;

    system("clear");

    while (true) {
        clearViewPort();		

        // Rotate the object
        rotX += 0.0001f;
        rotY += 0.0002f;

        model = eulerAngleYXZ(rotY, rotX, 0.0f);

        mat4 mp =  projection * view * model;
        DrawShape(shape, mp);

        cout << out.c_str() << "\033[1;1H";
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x288(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x2320
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x4320
jmp 0x3ce1
leaq -0x38(%rbp), %rdi
callq 0x36d0
movq %rax, -0x290(%rbp)
jmp 0x3cf3
leaq -0x38(%rbp), %rdi
callq 0x2398
leaq -0x39(%rbp), %rdi
callq 0x2200
movq -0x290(%rbp), %rax
movq %rax, -0x18(%rbp)
callq 0x3bc0
movl $0x3f800000, -0x90(%rbp) # imm = 0x3F800000
leaq -0x8c(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x4750
leaq -0xdc(%rbp), %rdi
xorl %edx, %edx
movl %edx, -0x294(%rbp)
movl $0x1, %ecx
movl %ecx, -0x298(%rbp)
movl %edx, %esi
callq 0x4450
movl -0x294(%rbp), %ecx
leaq -0xe8(%rbp), %rdi
movl %ecx, %esi
movl %ecx, %edx
callq 0x4450
movl -0x298(%rbp), %edx
movl -0x294(%rbp), %ecx
leaq -0xf4(%rbp), %rdi
movl %ecx, %esi
callq 0x4450
movl -0xd4(%rbp), %eax
movl %eax, -0x100(%rbp)
movq -0xdc(%rbp), %rax
movq %rax, -0x108(%rbp)
movsd -0x108(%rbp), %xmm0
movss -0x100(%rbp), %xmm1
movl -0xe0(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x118(%rbp)
movsd -0x118(%rbp), %xmm2
movss -0x110(%rbp), %xmm3
movl -0xec(%rbp), %eax
movl %eax, -0x120(%rbp)
movq -0xf4(%rbp), %rax
movq %rax, -0x128(%rbp)
movsd -0x128(%rbp), %xmm4
movss -0x120(%rbp), %xmm5
leaq -0xd0(%rbp), %rdi
callq 0x2a40
movss 0x2217(%rip), %xmm0     # 0x602c
callq 0x4850
leaq -0x168(%rbp), %rdi
movss 0x21fb(%rip), %xmm1     # 0x6024
movss 0x21f7(%rip), %xmm2     # 0x6028
callq 0x28f0
xorps %xmm0, %xmm0
movss %xmm0, -0x16c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x170(%rbp)
leaq 0x21ee(%rip), %rdi      # 0x6041
callq 0x2190
callq 0x3c30
movss 0x21cf(%rip), %xmm0     # 0x6034
addss -0x16c(%rbp), %xmm0
movss %xmm0, -0x16c(%rbp)
movss 0x21b3(%rip), %xmm0     # 0x6030
addss -0x170(%rbp), %xmm0
movss %xmm0, -0x170(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1b4(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
leaq -0x16c(%rbp), %rdx
leaq -0x1b4(%rbp), %rcx
callq 0x4870
leaq -0x8c(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
movl $0x40, %edx
callq 0x2160
leaq -0x234(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x4c40
leaq -0x1f4(%rbp), %rdi
leaq -0x234(%rbp), %rsi
leaq -0x8c(%rbp), %rdx
callq 0x4c40
movq -0x18(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x1f4(%rbp), %rsi
movl $0x40, %edx
callq 0x2160
movq -0x2a0(%rbp), %rdi
movups -0x278(%rbp), %xmm0
movups -0x268(%rbp), %xmm1
movups -0x258(%rbp), %xmm2
movups -0x248(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3630
leaq 0x52bf(%rip), %rdi      # 0x9228
callq 0x20c0
movq %rax, %rsi
movq 0x5058(%rip), %rdi      # 0x8fd0
callq 0x21d0
movq %rax, %rdi
leaq 0x20c0(%rip), %rsi      # 0x6047
callq 0x21d0
jmp 0x3e58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3fb4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2398
leaq -0x39(%rbp), %rdi
callq 0x2200
movq -0x48(%rbp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)