// File: /workspace/github_cpp_makefile_star2_O3/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, %r9
shrq $0x20, %r9
movq %rsi, %r8
shrq $0x20, %r8
movq %rdx, %r12
shrq $0x20, %r12
cmpl %r8d, %r9d
jle 0x2736
movq %rdi, %rax
movl %r9d, %ecx
jmp 0x2742
movq %rsi, %rax
movl %r8d, %ecx
movq %rdi, %rsi
movl %r9d, %r8d
cmpl %r12d, %r8d
jle 0x274f
movl %r8d, %r13d
movq %rsi, %rdi
jmp 0x275b
movl %r12d, %r13d
movq %rdx, %rdi
movq %rsi, %rdx
movl %r8d, %r12d
cmpl %r13d, %ecx
jle 0x276c
movq %rdi, 0x10(%rsp)
movl %ecx, %esi
movq %rax, %rdi
jmp 0x2777
movl %r13d, %esi
movq %rax, 0x10(%rsp)
movl %ecx, %r13d
movq %rdi, 0x18(%rsp)
movl %edi, %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, 0x20(%rsp)
subl %r12d, %r13d
movss %xmm1, 0x8(%rsp)
movss %xmm2, 0xc(%rsp)
jl 0x284d
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 0x280f(%rip), %xmm3     # 0x5008
addsd %xmm3, %xmm1
cvttsd2si %xmm1, %edi
leal (%r12,%rbp), %eax
mulss 0x4(%rsp), %xmm0
addss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm3, %xmm0
cvttsd2si %xmm0, %esi
shlq $0x20, %rax
orq %rax, %rsi
orq %rax, %rdi
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdx
leaq 0x30(%rsp), %rcx
callq 0x2584
movss 0xc(%rsp), %xmm2
movss 0x8(%rsp), %xmm1
incl %ebp
cmpl %ebp, %r15d
jne 0x27d8
movq 0x20(%rsp), %rbp
movl (%rsp), %r15d
subl %ebp, %r15d
jl 0x2914
movq 0x10(%rsp), %rax
movq 0x18(%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 0x2753(%rip), %xmm1     # 0x5008
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %edi
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
leal (%rbp,%r12), %eax
mulss 0x4(%rsp), %xmm0
addss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %esi
shlq $0x20, %rax
orq %rax, %rsi
orq %rax, %rdi
movq (%rbx), %rax
movq %rax, 0x28(%rsp)
movq %r14, %rdx
leaq 0x28(%rsp), %rcx
callq 0x2584
movss 0xc(%rsp), %xmm2
movss 0x8(%rsp), %xmm1
incl %r12d
cmpl %r12d, %r15d
jne 0x2896
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq