// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/engine/logic/block_physics.cpp
// Function: Physics::debug_draw_body(Physics::Body*)
void debug_draw_body(Body *body) {
    Shape shape = find_shape(body->shape);
    for (u32 i = 0; i < shape.points.length; i++)
    {
        u32 v_i = i;
        u32 u_i = (i + 1) % shape.points.length;
        Vec2 v = rotate(
                hadamard(shape.points[v_i], body->scale) + body->offset,
                body->rotation);
        v += body->position;
        Vec2 u = rotate(
                hadamard(shape.points[u_i], body->scale) + body->offset,
                body->rotation);
        u += body->position;

        Renderer::push_point(MAX_LAYER, v, V4(0.1f, 0.2f, 0.7f, 1.0f));
        Renderer::push_line(MAX_LAYER, u, v, V4(0.7f, 0.2f, 0.1f, 1.0f));
    }

    Vec2 middle = body->position + body->offset;
    for (u32 i = 0; i < shape.normals.length; i++)
    {
        Vec2 normal = normalize(rotate(hadamard(shape.normals[i],
                                                inverse(body->scale)),
                            body->rotation)) * 0.5;
        Renderer::push_line(MAX_LAYER, middle - normal, middle + normal,
                            V4(0.2f, 0.7f, 0.1f, 1.0f));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl (%rdi), %esi
leaq -0x90(%rbp), %rdi
callq 0x2288a
leaq -0x68(%rbp), %r14
pushq $0xe
popq %r15
xorl %esi, %esi
movl -0x64(%rbp), %eax
cmpl %eax, %esi
jae 0x22b93
leal 0x1(%rsi), %r13d
cmpl %eax, %r13d
movl %r13d, %r12d
movl $0x0, %eax
cmovel %eax, %r12d
movq %r14, %rdi
callq 0x2a6a8
movsd (%rax), %xmm0
movsd 0x1c(%rbx), %xmm1
mulps %xmm0, %xmm1
movsd 0x8(%rbx), %xmm0
addps %xmm1, %xmm0
movss 0x10(%rbx), %xmm1
callq 0x6aaa
movsd 0x14(%rbx), %xmm1
addps %xmm0, %xmm1
movaps %xmm1, -0x40(%rbp)
movq %r14, %rdi
movl %r12d, %esi
callq 0x2a6a8
movsd (%rax), %xmm0
movsd 0x1c(%rbx), %xmm1
mulps %xmm0, %xmm1
movsd 0x8(%rbx), %xmm0
addps %xmm1, %xmm0
movss 0x10(%rbx), %xmm1
callq 0x6aaa
movsd 0x14(%rbx), %xmm1
addps %xmm1, %xmm0
movaps %xmm0, -0x50(%rbp)
movl %r15d, %edi
movaps -0x40(%rbp), %xmm0
movsd 0x87d2(%rip), %xmm1     # 0x2b320
movsd 0x87da(%rip), %xmm2     # 0x2b330
movss 0x86f6(%rip), %xmm3     # 0x2b254
callq 0x1f571
movl %r15d, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
movsd 0x87ca(%rip), %xmm2     # 0x2b340
movsd 0x8792(%rip), %xmm3     # 0x2b310
movss 0x86ca(%rip), %xmm4     # 0x2b250
callq 0x1fd26
movl %r13d, %esi
jmp 0x22aba
movsd 0x8(%rbx), %xmm0
movss 0x14(%rbx), %xmm1
addss %xmm0, %xmm1
movss %xmm1, -0x50(%rbp)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
addss 0x18(%rbx), %xmm0
movaps %xmm0, -0x40(%rbp)
xorl %r14d, %r14d
leaq -0x80(%rbp), %r15
pushq $0xe
popq %r12
cmpl -0x7c(%rbp), %r14d
jae 0x22c78
movq %r15, %rdi
movl %r14d, %esi
callq 0x2a6a8
movsd (%rax), %xmm1
movsd 0x1c(%rbx), %xmm2
movss 0x8420(%rip), %xmm3     # 0x2b004
movaps %xmm3, %xmm0
divss %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
divss %xmm2, %xmm3
mulss %xmm1, %xmm0
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
mulss %xmm3, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0x10(%rbx), %xmm1
callq 0x6aaa
callq 0x6a2a
movaps %xmm0, %xmm1
movss 0x83ec(%rip), %xmm2     # 0x2b008
mulss %xmm2, %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm2, %xmm0
movss -0x50(%rbp), %xmm5
movaps %xmm5, %xmm2
subss %xmm1, %xmm2
movaps -0x40(%rbp), %xmm4
movaps %xmm4, %xmm3
subss %xmm0, %xmm3
unpcklps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
addss %xmm5, %xmm1
addss %xmm4, %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movl %r12d, %edi
movaps %xmm2, %xmm0
movsd 0x86a5(%rip), %xmm2     # 0x2b300
movsd 0x86ad(%rip), %xmm3     # 0x2b310
movss 0x85e5(%rip), %xmm4     # 0x2b250
callq 0x1fd26
incl %r14d
jmp 0x22bbe
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq