// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdi, %r12
shrq $0x20, %r12
movq %rsi, %rax
shrq $0x20, %rax
movq %rdx, %r13
shrq $0x20, %r13
cmpl %eax, %r12d
jle 0x2741
movl %eax, %r8d
movq %rdi, %rcx
movl %r12d, %eax
movl %r8d, %r12d
jmp 0x2747
movq %rsi, %rcx
movq %rdi, %rsi
cmpl %r13d, %r12d
jle 0x275a
movl %r13d, %edi
movl %r12d, %r13d
movq %rsi, %r8
movl %edi, %r12d
jmp 0x2760
movq %rdx, %r8
movq %rsi, %rdx
cmpl %r13d, %eax
jle 0x2771
movq %r8, 0x10(%rsp)
movl %eax, %esi
movq %rcx, %r8
jmp 0x277c
movl %r13d, %esi
movq %rcx, 0x10(%rsp)
movl %eax, %r13d
movq %r8, 0x28(%rsp)
movl %r8d, %eax
subl %edx, %eax
cvtsi2ss %eax, %xmm1
movl %esi, (%rsp)
movl %esi, %eax
subl %r12d, %eax
cvtsi2ss %eax, %xmm0
cvtsi2ss %edx, %xmm2
divss %xmm0, %xmm1
movq %r13, 0x30(%rsp)
subl %r12d, %r13d
movss %xmm1, 0x8(%rsp)
movss %xmm2, 0xc(%rsp)
jl 0x2858
movq 0x10(%rsp), %rax
subl %edx, %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
leal 0x1(%r13), %r15d
xorl %ebp, %ebp
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss 0x8(%rsp), %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x2809(%rip), %xmm3     # 0x5008
addsd %xmm3, %xmm1
cvttsd2si %xmm1, %edi
mulss 0x4(%rsp), %xmm0
addss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm3, %xmm0
cvttsd2si %xmm0, %esi
leal (%r12,%rbp), %eax
shlq $0x20, %rax
orq %rax, %rsi
orq %rax, %rdi
movl (%rbx), %eax
movl %eax, 0x20(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x24(%rsp)
movq %r14, %rdx
leaq 0x20(%rsp), %rcx
callq 0x2584
movss 0xc(%rsp), %xmm2
movss 0x8(%rsp), %xmm1
incl %ebp
cmpl %ebp, %r15d
jne 0x27de
movq 0x30(%rsp), %rbp
movl (%rsp), %r15d
subl %ebp, %r15d
jl 0x292a
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rdx
subl %eax, %edx
xorps %xmm3, %xmm3
cvtsi2ss %edx, %xmm3
xorps %xmm0, %xmm0
cvtsi2ss %r15d, %xmm0
divss %xmm0, %xmm3
movss %xmm3, 0x4(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, (%rsp)
incl %r15d
xorl %r12d, %r12d
leal (%r12,%r13), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss %xmm1, %xmm0
addss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x2748(%rip), %xmm2     # 0x5008
addsd %xmm2, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r12d, %xmm1
cvttsd2si %xmm0, %edi
mulss 0x4(%rsp), %xmm1
addss (%rsp), %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %esi
leal (%r12,%rbp), %eax
shlq $0x20, %rax
orq %rax, %rsi
orq %rax, %rdi
movl (%rbx), %eax
movl %eax, 0x18(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x1c(%rsp)
movq %r14, %rdx
leaq 0x18(%rsp), %rcx
callq 0x2584
movss 0xc(%rsp), %xmm2
movss 0x8(%rsp), %xmm1
incl %r12d
cmpl %r12d, %r15d
jne 0x28a1
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq