// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movaps %xmm6, -0xa0(%rbp)
movaps %xmm5, -0x90(%rbp)
movaps %xmm0, %xmm13
movl %esi, %r14d
movl %edi, %ebx
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jne 0x21bba
jnp 0x21c1e
movaps %xmm2, %xmm0
movaps %xmm4, -0x60(%rbp)
movaps %xmm1, -0x50(%rbp)
movaps %xmm3, -0x40(%rbp)
movaps %xmm13, -0x80(%rbp)
movss %xmm2, -0x2c(%rbp)
callq 0x2050
movss %xmm0, -0x70(%rbp)
movss -0x2c(%rbp), %xmm0
callq 0x2350
movaps -0x80(%rbp), %xmm13
movaps -0x40(%rbp), %xmm3
movaps -0x50(%rbp), %xmm1
movaps -0x60(%rbp), %xmm4
movss -0x70(%rbp), %xmm6
movaps %xmm6, %xmm2
xorps %xmm5, %xmm5
mulss %xmm5, %xmm2
movaps %xmm0, %xmm9
subss %xmm2, %xmm9
mulss %xmm5, %xmm0
addss %xmm6, %xmm0
unpcklps %xmm0, %xmm9            # xmm9 = xmm9[0],xmm0[0],xmm9[1],xmm0[1]
jmp 0x21c27
movss 0xe3dd(%rip), %xmm9     # 0x30004
movss 0xe611(%rip), %xmm2     # 0x30240
movaps %xmm4, %xmm10
mulss %xmm2, %xmm10
movaps %xmm3, %xmm0
mulss %xmm2, %xmm0
addss %xmm0, %xmm10
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
mulss %xmm2, %xmm4
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
mulss %xmm2, %xmm3
addss %xmm3, %xmm4
movaps %xmm10, %xmm2
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movaps %xmm0, %xmm5
unpcklps %xmm3, %xmm5            # xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1]
movaps %xmm9, %xmm6
shufps $0x55, %xmm9, %xmm6     # xmm6 = xmm6[1,1],xmm9[1,1]
movaps 0xe3ca(%rip), %xmm11    # 0x30040
xorps %xmm6, %xmm11
movss 0xe386(%rip), %xmm7     # 0x30008
movaps %xmm1, %xmm8
mulss %xmm7, %xmm8
movaps %xmm8, %xmm15
mulss %xmm9, %xmm15
mulss %xmm6, %xmm8
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
mulss %xmm7, %xmm1
mulss %xmm1, %xmm11
mulss %xmm9, %xmm1
movaps %xmm13, %xmm12
subss %xmm15, %xmm12
movaps %xmm13, %xmm6
shufps $0x55, %xmm13, %xmm6    # xmm6 = xmm6[1,1],xmm13[1,1]
movaps %xmm6, %xmm9
subss %xmm8, %xmm9
movaps %xmm12, %xmm14
subss %xmm11, %xmm14
movaps %xmm9, %xmm7
subss %xmm1, %xmm7
unpcklps %xmm7, %xmm14           # xmm14 = xmm14[0],xmm7[0],xmm14[1],xmm7[1]
movlhps %xmm5, %xmm14           # xmm14 = xmm14[0],xmm5[0]
movaps %xmm14, -0x60(%rbp)
addss %xmm13, %xmm15
addss %xmm8, %xmm6
movaps %xmm11, %xmm7
addss %xmm15, %xmm7
subss %xmm11, %xmm15
movaps %xmm1, %xmm5
addss %xmm6, %xmm5
subss %xmm1, %xmm6
unpcklps %xmm6, %xmm15           # xmm15 = xmm15[0],xmm6[0],xmm15[1],xmm6[1]
unpcklps %xmm3, %xmm10           # xmm10 = xmm10[0],xmm3[0],xmm10[1],xmm3[1]
movlhps %xmm10, %xmm15          # xmm15 = xmm15[0],xmm10[0]
movaps %xmm15, -0x70(%rbp)
unpcklps %xmm5, %xmm7            # xmm7 = xmm7[0],xmm5[0],xmm7[1],xmm5[1]
movlhps %xmm2, %xmm7            # xmm7 = xmm7[0],xmm2[0]
movaps %xmm7, -0x50(%rbp)
addss %xmm11, %xmm12
addss %xmm1, %xmm9
unpcklps %xmm9, %xmm12           # xmm12 = xmm12[0],xmm9[0],xmm12[1],xmm9[1]
unpcklps %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
xorps %xmm1, %xmm1
cvtsi2ss %r14d, %xmm1
movss %xmm1, -0x40(%rbp)
movlhps %xmm0, %xmm12           # xmm12 = xmm12[0],xmm0[0]
movaps %xmm12, -0x80(%rbp)
xorl %r14d, %r14d
cmpl $0x10, %ebx
setb %r14b
leaq 0xf32b(%rip), %r13      # 0x31085
leaq 0xf3a6(%rip), %r12      # 0x31107
movq %r13, %rdi
movl $0x1cc, %esi            # imm = 0x1CC
movq %r12, %rdx
movl %r14d, %ecx
callq 0x722f
leaq -0x110(%rbp), %r15
movaps -0x60(%rbp), %xmm0
movaps %xmm0, (%r15)
movss -0x40(%rbp), %xmm1
movss %xmm1, 0x10(%r15)
movaps -0x90(%rbp), %xmm2
unpcklpd -0xa0(%rbp), %xmm2      # xmm2 = xmm2[0],mem[0]
movaps %xmm2, -0x90(%rbp)
movups %xmm2, 0x14(%r15)
movaps -0x70(%rbp), %xmm0
movups %xmm0, 0x24(%r15)
movss %xmm1, 0x34(%r15)
movups %xmm2, 0x38(%r15)
movaps -0x50(%rbp), %xmm0
movups %xmm0, 0x48(%r15)
movss %xmm1, 0x58(%r15)
movups %xmm2, 0x5c(%r15)
movl %ebx, %ebx
shlq $0x5, %rbx
addq 0x2d202(%rip), %rbx     # 0x4efe0
movq %rbx, %rdi
movl $0x3, %esi
movq %r15, %rdx
callq 0x2e06a
movq %r13, %rdi
movl $0x1cc, %esi            # imm = 0x1CC
movq %r12, %rdx
movl %r14d, %ecx
callq 0x722f
movaps -0x60(%rbp), %xmm0
movaps %xmm0, (%r15)
movss -0x40(%rbp), %xmm1
movss %xmm1, 0x10(%r15)
movaps -0x90(%rbp), %xmm2
movups %xmm2, 0x14(%r15)
movaps -0x50(%rbp), %xmm0
movups %xmm0, 0x24(%r15)
movss %xmm1, 0x34(%r15)
movups %xmm2, 0x38(%r15)
movaps -0x80(%rbp), %xmm0
movups %xmm0, 0x48(%r15)
movss %xmm1, 0x58(%r15)
movups %xmm2, 0x5c(%r15)
leaq -0x110(%rbp), %rdx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x2e06a
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq