// File: donqustix[P]SoftwareRenderer/src/main.cpp
// Function: (anonymous namespace)::render_triangle(SDL_Surface*, (anonymous namespace)::Vertex const&, (anonymous namespace)::Vertex const&, (anonymous namespace)::Vertex const&, (anonymous namespace)::Matrix<float> const&)
void render_triangle(SDL_Surface* surface, const Vertex& vert1, const Vertex& vert2,
                                                                    const Vertex& vert3, const mat4f& matrix) noexcept
    {
        const vec4f virtual_pos1 = matrix * vert1.position, virtual_pos2 = matrix * vert2.position,
                    virtual_pos3 = matrix * vert3.position;

        if (::check_virtual_position(virtual_pos1) ||
            ::check_virtual_position(virtual_pos2) || ::check_virtual_position(virtual_pos3)) return;

        const auto screenspace_matrix = mat4f::create_screenspace(surface->w, surface->h);

        const auto screenspace_pos1 = screenspace_matrix * virtual_pos1,
                   screenspace_pos2 = screenspace_matrix * virtual_pos2,
                   screenspace_pos3 = screenspace_matrix * virtual_pos3;

        ::rasterize_triangle(surface, {screenspace_pos1 / screenspace_pos1.get_w(), vert1.color},
                                      {screenspace_pos2 / screenspace_pos2.get_w(), vert2.color},
                                      {screenspace_pos3 / screenspace_pos3.get_w(), vert3.color});
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5700
movlpd %xmm0, -0x38(%rbp)
movlpd %xmm1, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5700
movlpd %xmm0, -0x48(%rbp)
movlpd %xmm1, -0x40(%rbp)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x5700
movlpd %xmm0, -0x58(%rbp)
movlpd %xmm1, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5800
testb $0x1, %al
jne 0x37fd
leaq -0x48(%rbp), %rdi
callq 0x5800
testb $0x1, %al
jne 0x37fd
leaq -0x58(%rbp), %rdi
callq 0x5800
testb $0x1, %al
jne 0x37fd
jmp 0x3802
jmp 0x39dc
movq -0x8(%rbp), %rax
cvtsi2ssl 0x10(%rax), %xmm0
cvtsi2ssl 0x14(%rax), %xmm1
leaq -0x98(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x5940
movq -0x150(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x5700
movq -0x150(%rbp), %rdi
movlpd %xmm0, -0xa8(%rbp)
movlpd %xmm1, -0xa0(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x5700
movq -0x150(%rbp), %rdi
movlpd %xmm0, -0xb8(%rbp)
movlpd %xmm1, -0xb0(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x5700
movlpd %xmm0, -0xc8(%rbp)
movlpd %xmm1, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x5d20
movq -0x148(%rbp), %rdi
callq 0x5cc0
movlpd %xmm0, -0xe8(%rbp)
movlpd %xmm1, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movups 0x10(%rax), %xmm0
movups %xmm0, -0xd8(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x5d20
movq -0x140(%rbp), %rdi
callq 0x5cc0
movlpd %xmm0, -0x108(%rbp)
movlpd %xmm1, -0x100(%rbp)
movq -0x18(%rbp), %rax
movups 0x10(%rax), %xmm0
movups %xmm0, -0xf8(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x5d20
movq -0x138(%rbp), %rdi
callq 0x5cc0
movq -0x130(%rbp), %rdi
movlpd %xmm0, -0x128(%rbp)
movlpd %xmm1, -0x120(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x118(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x110(%rbp)
leaq -0xe8(%rbp), %rdx
leaq -0x108(%rbp), %rcx
leaq -0x128(%rbp), %rax
movq (%rdx), %rsi
movq %rsi, (%rsp)
movq 0x8(%rdx), %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rdx), %rsi
movq %rsi, 0x10(%rsp)
movq 0x18(%rdx), %rdx
movq %rdx, 0x18(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x28(%rsp)
movq 0x10(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movq 0x18(%rcx), %rcx
movq %rcx, 0x38(%rsp)
movq (%rax), %rcx
movq %rcx, 0x40(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x50(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x58(%rsp)
callq 0x5a40
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)