// File: /workspace/github_cpp_makefile_star2_O1/shinerd[P]BriefRenderer/main.cpp
// Function: main
int main(int argc, char** argv) {
    if (argc==2) {
        model = new Model(argv[1]);
    } else {
        model = new Model("obj/african_head.obj");
    }
    
    TGAImage image(width, height, TGAImage::RGB);
    
    for (int i=0; i<model->nfaces(); i++) {
        std::vector<int> face = model->face(i);
        Vec2i screen_coords[3];
        for (int j=0; j<3; j++) {
            Vec3f world_coords = model->vert(face[j]);
            screen_coords[j] = Vec2i((world_coords.x+1.)*width/2., (world_coords.y+1.)*height/2.);
        }
        triangle(screen_coords[0], screen_coords[1], screen_coords[2], image, TGAColor(rand()%255, rand()%255, rand()%255, 255));
    }
    
    image.flip_vertically();
    image.write_tga_file("output.tga");
    
    delete model;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movl $0x30, %edi
callq 0x21b0
movq %rax, %r14
cmpl $0x2, %ebp
jne 0x296c
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2bc0
jmp 0x297b
leaq 0x26bd(%rip), %rsi      # 0x5030
movq %r14, %rdi
callq 0x2bc0
movq %r14, 0x5846(%rip)      # 0x81c8
leaq 0x28(%rsp), %rdi
movl $0xc8, %esi
movl $0xc8, %edx
movl $0x3, %ecx
callq 0x367a
xorl %r14d, %r14d
movq 0x5823(%rip), %rdi      # 0x81c8
callq 0x3010
cmpl %eax, %r14d
jge 0x2b0d
movq 0x580e(%rip), %rsi      # 0x81c8
leaq 0x40(%rsp), %rdi
movl %r14d, %edx
callq 0x3024
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %ebx, %ebx
movq 0x57e7(%rip), %rdi      # 0x81c8
movq 0x40(%rsp), %rax
movl (%rax,%rbx,4), %esi
callq 0x3044
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x2613(%rip), %xmm2     # 0x5010
addsd %xmm2, %xmm1
movsd 0x260f(%rip), %xmm3     # 0x5018
mulsd %xmm3, %xmm1
movsd 0x25f3(%rip), %xmm4     # 0x5008
mulsd %xmm4, %xmm1
cvttsd2si %xmm1, %eax
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm4, %xmm0
cvttsd2si %xmm0, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp,%rbx,8)
incq %rbx
cmpq $0x3, %rbx
jne 0x29da
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rbx
callq 0x2090
cltq
imulq $-0x7f7f7f7f, %rax, %r15 # imm = 0x80808081
shrq $0x20, %r15
addl %eax, %r15d
movl %r15d, %ecx
shrl $0x1f, %ecx
shrl $0x7, %r15d
addl %ecx, %r15d
addl %eax, %r15d
callq 0x2090
cltq
imulq $-0x7f7f7f7f, %rax, %r12 # imm = 0x80808081
shrq $0x20, %r12
addl %eax, %r12d
movl %r12d, %ecx
shrl $0x1f, %ecx
shrl $0x7, %r12d
addl %ecx, %r12d
addl %eax, %r12d
callq 0x2090
cltq
imulq $-0x7f7f7f7f, %rax, %rcx # imm = 0x80808081
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
shrl $0x7, %ecx
addl %edx, %ecx
addl %eax, %ecx
movb %cl, 0x8(%rsp)
movb %r12b, 0x9(%rsp)
movb %r15b, 0xa(%rsp)
movb $-0x1, 0xb(%rsp)
movl $0x4, 0xc(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
leaq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x2705
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2b05
callq 0x2190
incl %r14d
jmp 0x299e
leaq 0x28(%rsp), %rdi
callq 0x3cfe
leaq 0x2527(%rip), %rsi      # 0x5045
leaq 0x28(%rsp), %rdi
movl $0x1, %edx
callq 0x3f14
movq 0x5694(%rip), %r14      # 0x81c8
testq %r14, %r14
je 0x2b49
movq %r14, %rdi
callq 0x2fbe
movq %r14, %rdi
callq 0x2190
leaq 0x28(%rsp), %rdi
callq 0x36fe
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b66
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x2ba2
movq %rax, %rbx
movq %r14, %rdi
jmp 0x2b93
jmp 0x2b81
jmp 0x2b86
jmp 0x2b81
movq %rax, %rbx
jmp 0x2b98
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2b98
callq 0x2190
leaq 0x28(%rsp), %rdi
callq 0x36fe
movq %rbx, %rdi
callq 0x22e0
movq %rax, %rdi
callq 0x2bb2