// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %rsi, %rbx
movl %edi, %ebp
pushq $0x30
popq %rdi
callq 0x21b0
movq %rax, %r14
cmpl $0x2, %ebp
jne 0x281e
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2a40
jmp 0x282d
leaq 0x280b(%rip), %rsi      # 0x5030
movq %r14, %rdi
callq 0x2a40
movq %r14, 0x5984(%rip)      # 0x81b8
leaq 0x38(%rsp), %rdi
pushq $0x3
popq %rcx
movl $0xc8, %esi
movl $0xc8, %edx
callq 0x33e0
xorl %r14d, %r14d
leaq 0x50(%rsp), %r15
movl $0xff, %ebp
movq 0x5959(%rip), %rdi      # 0x81b8
callq 0x2d92
cmpl %eax, %r14d
jge 0x2982
movq 0x5944(%rip), %rsi      # 0x81b8
movq %r15, %rdi
movl %r14d, %edx
callq 0x2da4
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0x28fe
movq 0x591c(%rip), %rdi      # 0x81b8
movq 0x50(%rsp), %rax
movl (%rax,%rbx,4), %esi
callq 0x2dc0
cvtss2sd %xmm0, %xmm1
movsd 0x275b(%rip), %xmm2     # 0x5010
addsd %xmm2, %xmm1
movsd 0x2757(%rip), %xmm3     # 0x5018
mulsd %xmm3, %xmm1
movsd 0x273b(%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
jmp 0x288f
movq %r14, %rbx
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
callq 0x20a0
cltd
idivl %ebp
movl %edx, %r12d
callq 0x20a0
cltd
idivl %ebp
movl %edx, %r14d
callq 0x20a0
cltd
idivl %ebp
movb %dl, 0x8(%rsp)
movb %r14b, 0x9(%rsp)
movb %r12b, 0xa(%rsp)
movb $-0x1, 0xb(%rsp)
movl $0x4, 0xc(%rsp)
movq %r13, %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x38(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x267f
movq %r15, %rdi
callq 0x2a30
movq %rbx, %r14
incl %r14d
jmp 0x2858
leaq 0x38(%rsp), %rdi
callq 0x38d6
leaq 0x26b2(%rip), %rsi      # 0x5045
leaq 0x38(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x3a88
movq 0x5811(%rip), %r14      # 0x81b8
testq %r14, %r14
je 0x29b4
movq %r14, %rdi
callq 0x2d48
movq %r14, %rdi
callq 0x2190
leaq 0x38(%rsp), %rdi
callq 0x3460
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29d9
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x2a15
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x2a0b
jmp 0x29f9
jmp 0x29fe
jmp 0x29f9
movq %rax, %rbx
jmp 0x2a0b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2a30
leaq 0x38(%rsp), %rdi
callq 0x3460
movq %rbx, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x2a25