// File: shinerd[P]BriefRenderer/main.cpp
// Function: triangle(Vec2<int>, Vec2<int>, Vec2<int>, TGAImage&, TGAColor)
void triangle(Vec2i t0, Vec2i t1, Vec2i t2, TGAImage &image, TGAColor color) {
    if (t0.y > t1.y) std::swap(t0, t1);
    if (t0.y > t2.y) std::swap(t0, t2);
    if (t1.y > t2.y) std::swap(t1, t2);
    
    Vec2i abp = Vec2i(boundary_x(t0, t2, t1.y), t1.y);  // (the boundary) A boundary point
    Vec2i bbp;
    
    for (abp.y = t0.y; abp.y <= t1.y; abp.y++) {
        abp.x = boundary_x(t0, t2, abp.y);
        bbp = Vec2i(boundary_x(t0, t1, abp.y), abp.y);
        line(abp, bbp, image, color);
    }
        
    for (abp.y = t1.y; abp.y <= t2.y; abp.y++) {
        abp.x = boundary_x(t0, t2, abp.y);
        bbp = Vec2i(boundary_x(t1, t2, abp.y), abp.y);
        line(abp, bbp, image, color);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %r8, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl -0x4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x28bb
leaq -0x8(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x2fa0
movl -0x4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x28d0
leaq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2fa0
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x28e5
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2fa0
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0xc(%rbp), %edx
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x25c0
movl %eax, %esi
movl -0xc(%rbp), %edx
leaq -0x30(%rbp), %rdi
callq 0x3010
leaq -0x48(%rbp), %rdi
callq 0x3030
movl -0x4(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x29de
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x2c(%rbp), %edx
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x25c0
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x2c(%rbp), %edx
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x25c0
movl %eax, %esi
movl -0x2c(%rbp), %edx
leaq -0x60(%rbp), %rdi
callq 0x3010
movq -0xd0(%rbp), %rsi
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2fe0
movq -0xd8(%rbp), %rdx
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
leaq -0x88(%rbp), %rcx
callq 0x26a0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2922
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x2aca
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x2c(%rbp), %edx
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x25c0
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x2c(%rbp), %edx
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x25c0
movl %eax, %esi
movl -0x2c(%rbp), %edx
leaq -0xa0(%rbp), %rdi
callq 0x3010
movq -0xd0(%rbp), %rsi
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x2fe0
movq -0xe0(%rbp), %rdx
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
leaq -0xc8(%rbp), %rcx
callq 0x26a0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x29e4
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)