// File: /workspace/github_cpp_makefile_star2_O3/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 0x2956
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2ba8
jmp 0x2965
leaq 0x26d3(%rip), %rsi      # 0x5030
movq %r14, %rdi
callq 0x2ba8
movq %r14, 0x585c(%rip)      # 0x81c8
leaq 0x28(%rsp), %rdi
movl $0xc8, %esi
movl $0xc8, %edx
movl $0x3, %ecx
callq 0x368a
xorl %r14d, %r14d
movq 0x5839(%rip), %rdi      # 0x81c8
callq 0x2ff4
cmpl %eax, %r14d
jge 0x2af7
movq 0x5824(%rip), %rsi      # 0x81c8
leaq 0x40(%rsp), %rdi
movl %r14d, %edx
callq 0x3008
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %ebx, %ebx
movq 0x57fd(%rip), %rdi      # 0x81c8
movq 0x40(%rsp), %rax
movl (%rax,%rbx,4), %esi
callq 0x3028
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x2629(%rip), %xmm2     # 0x5010
addsd %xmm2, %xmm1
movsd 0x2625(%rip), %xmm3     # 0x5018
mulsd %xmm3, %xmm1
movsd 0x2609(%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 0x29c4
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 0x2700
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2aef
callq 0x2190
incl %r14d
jmp 0x2988
leaq 0x28(%rsp), %rdi
callq 0x3c50
leaq 0x253d(%rip), %rsi      # 0x5045
leaq 0x28(%rsp), %rdi
movl $0x1, %edx
callq 0x3e8c
movq 0x56aa(%rip), %r14      # 0x81c8
testq %r14, %r14
je 0x2b2b
movq %r14, %rdi
callq 0x2fa2
movq %r14, %rdi
callq 0x2190
leaq 0x28(%rsp), %rdi
callq 0x370e
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b50
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x2b8c
movq %rax, %rbx
movq %r14, %rdi
jmp 0x2b7d
jmp 0x2b6b
jmp 0x2b70
jmp 0x2b6b
movq %rax, %rbx
jmp 0x2b82
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2b82
callq 0x2190
leaq 0x28(%rsp), %rdi
callq 0x370e
movq %rbx, %rdi
callq 0x22e0
movq %rax, %rdi
callq 0x2b9c