// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/engine/renderer/command.cpp
// Function: Renderer::push_sprite_rect(unsigned int, int, Vec2, Vec2, float, Vec2, Vec2, Vec4)
void push_sprite_rect(u32 layer, s32 slot, Vec2 position, Vec2 dimension, f32 angle,
                 Vec2 uv_min, Vec2 uv_dimension, Vec4 color) {
    Vec2 inv_dimension = {1.0f / (f32) OPENGL_TEXTURE_WIDTH,
                          1.0f / (f32) OPENGL_TEXTURE_HEIGHT};
    uv_min = hadamard(uv_min, inv_dimension);
    Vec2 uv_max = uv_min + hadamard(uv_dimension, inv_dimension);

    Vec2 right = angle ? rotate(V2(1, 0), angle) : V2(1, 0);
    Vec2 up = rotate_ccw(right);
    right *= dimension.x * 0.5;
    up *= dimension.y * 0.5;

    struct {
        Vec2 p;
        Vec2 uv;
    } coords[] = {
        {position - right - up, uv_min},
        {position + right - up, V2(uv_max.x, uv_min.y)},
        {position + right + up, uv_max},
        {position - right + up, V2(uv_min.x, uv_max.y)},
    };

    Impl::push_triangle(layer,
                        coords[0].p, coords[1].p, coords[2].p,
                        coords[0].uv, coords[1].uv, coords[2].uv, color, color,
                        color, slot);
    Impl::push_triangle(layer,
                        coords[0].p, coords[2].p, coords[3].p,
                        coords[0].uv, coords[2].uv, coords[3].uv, color, color,
                        color, slot);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movaps %xmm6, -0x70(%rbp)
movaps %xmm5, -0x60(%rbp)
movaps %xmm4, -0x50(%rbp)
movaps %xmm1, %xmm9
movaps %xmm0, %xmm11
movl %esi, %r14d
movl %edi, %ebx
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jne 0x1ff42
jnp 0x1ff70
movss 0xb0ba(%rip), %xmm0     # 0x2b004
movaps %xmm2, %xmm1
movaps %xmm3, -0x40(%rbp)
movaps %xmm9, -0x30(%rbp)
movaps %xmm11, -0x20(%rbp)
callq 0x6aaa
movaps -0x20(%rbp), %xmm11
movaps -0x30(%rbp), %xmm9
movaps -0x40(%rbp), %xmm3
jmp 0x1ff78
movss 0xb08c(%rip), %xmm0     # 0x2b004
movss 0xb2c0(%rip), %xmm1     # 0x2b240
movaps -0x50(%rbp), %xmm5
movaps %xmm5, %xmm4
mulss %xmm1, %xmm4
movaps %xmm3, %xmm8
mulss %xmm1, %xmm8
addss %xmm8, %xmm4
movaps %xmm8, -0xc0(%rbp)
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
mulss %xmm1, %xmm5
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
mulss %xmm1, %xmm3
addss %xmm3, %xmm5
movaps %xmm5, %xmm10
movaps %xmm5, -0x50(%rbp)
movaps %xmm0, %xmm7
shufps $0x55, %xmm0, %xmm7     # xmm7 = xmm7[1,1],xmm0[1,1]
movaps 0xb074(%rip), %xmm14    # 0x2b040
xorps %xmm7, %xmm14
movss 0xb030(%rip), %xmm5     # 0x2b008
movaps %xmm9, %xmm6
mulss %xmm5, %xmm6
movaps %xmm6, %xmm1
mulss %xmm0, %xmm1
mulss %xmm7, %xmm6
shufps $0x55, %xmm9, %xmm9     # xmm9 = xmm9[1,1,1,1]
mulss %xmm5, %xmm9
mulss %xmm9, %xmm14
mulss %xmm0, %xmm9
movaps %xmm11, %xmm12
subss %xmm1, %xmm12
movaps %xmm11, %xmm0
shufps $0x55, %xmm11, %xmm0    # xmm0 = xmm0[1,1],xmm11[1,1]
movaps %xmm0, %xmm7
subss %xmm6, %xmm7
movaps %xmm12, %xmm13
subss %xmm14, %xmm13
movaps %xmm7, %xmm5
subss %xmm9, %xmm5
unpcklps %xmm5, %xmm13           # xmm13 = xmm13[0],xmm5[0],xmm13[1],xmm5[1]
movaps %xmm13, -0xb0(%rbp)
addss %xmm11, %xmm1
addss %xmm6, %xmm0
movaps %xmm14, %xmm5
addss %xmm1, %xmm5
movaps %xmm5, %xmm6
subss %xmm14, %xmm1
movaps %xmm9, %xmm5
addss %xmm0, %xmm5
subss %xmm9, %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
unpcklps %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1]
movaps %xmm6, %xmm2
movaps %xmm6, -0x90(%rbp)
addss %xmm14, %xmm12
addss %xmm9, %xmm7
unpcklps %xmm7, %xmm12           # xmm12 = xmm12[0],xmm7[0],xmm12[1],xmm7[1]
movaps %xmm12, -0x40(%rbp)
movaps -0x60(%rbp), %xmm0
movaps %xmm0, %xmm5
movaps %xmm0, %xmm6
movaps -0x70(%rbp), %xmm0
movlhps %xmm0, %xmm5            # xmm5 = xmm5[0],xmm0[0]
movaps %xmm5, -0x20(%rbp)
movaps %xmm0, %xmm7
movups %xmm5, -0x100(%rbp)
movups %xmm5, -0xf0(%rbp)
cvtsi2ss %r14d, %xmm5
movss %xmm5, -0x30(%rbp)
movups -0xf0(%rbp), %xmm0
movups %xmm0, 0x10(%rsp)
movups -0x100(%rbp), %xmm0
movups %xmm0, (%rsp)
movss %xmm5, 0x20(%rsp)
movaps %xmm4, %xmm0
unpcklps %xmm10, %xmm0           # xmm0 = xmm0[0],xmm10[0],xmm0[1],xmm10[1]
movaps %xmm0, %xmm5
movaps %xmm0, -0x80(%rbp)
unpcklps %xmm3, %xmm8            # xmm8 = xmm8[0],xmm3[0],xmm8[1],xmm3[1]
movaps %xmm8, -0xa0(%rbp)
unpcklps %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
movl %ebx, %edi
movaps %xmm13, %xmm0
movaps %xmm8, %xmm3
callq 0x1f2f7
movaps -0x20(%rbp), %xmm0
movups %xmm0, -0xe0(%rbp)
movups %xmm0, -0xd0(%rbp)
movups -0xd0(%rbp), %xmm0
movups %xmm0, 0x10(%rsp)
movups -0xe0(%rbp), %xmm0
movups %xmm0, (%rsp)
movss -0x30(%rbp), %xmm0
movss %xmm0, 0x20(%rsp)
movaps -0xc0(%rbp), %xmm5
unpcklps -0x50(%rbp), %xmm5      # xmm5 = xmm5[0],mem[0],xmm5[1],mem[1]
movl %ebx, %edi
movaps -0xb0(%rbp), %xmm0
movaps -0x90(%rbp), %xmm1
movaps -0x40(%rbp), %xmm2
movaps -0xa0(%rbp), %xmm3
movaps -0x80(%rbp), %xmm4
movaps -0x60(%rbp), %xmm6
movaps -0x70(%rbp), %xmm7
callq 0x1f2f7
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r14
popq %rbp
retq