// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/solid_dynamics.c
// Function: ApplyKinematics
static void ApplyKinematics(const Real now, const Real dt, Space *space)
{
    Geometry *const geo = &(space->geo);
    Polyhedron *poly = NULL;
    Real A[DIMS][DIMS] = {{0.0}};
    Real B[DIMS][1] = {{0.0}};
    for (int n = 0; n < geo->totN; ++n) {
        poly = geo->poly + n;
        if (1 == poly->state) { /* stationary object */
            continue;
        }
        if (now > poly->to) { /* end power supply */
            memset(poly->at[TN], 0, DIMS * sizeof(*poly->at[TN]));
            memset(poly->ar[TN], 0, DIMS * sizeof(*poly->ar[TN]));
            poly->to = FLT_MAX; /* avoid repeating */
        }
        /* translation and rotational acceleration */
        for (int s = 0; s < DIMS; ++s) {
            for (int m = 0; m < DIMS; ++m) {
                A[s][m] = poly->I[s][m];
            }
            B[s][0] = poly->Tt[s] / poly->rho;
        }
        SolveLinearSystem(DIMS, A, 1, B, B);
        for (int s = 0; s < DIMS; ++s) {
            /* acceleration from surface force and body force */
            poly->at[TO][s] = (poly->Fp[s] + poly->Fv[s]) / (poly->rho * poly->volume) + poly->at[TN][s] + poly->g[s];
            poly->ar[TO][s] = B[s][0] + poly->ar[TN][s];
        }
        /* velocity integration */
        for (int s = 0; s < DIMS; ++s) {
            /* averaged velocity during time level n and n+1 */
            poly->V[TN][s] = 0.5 * (poly->V[TO][s] + poly->V[TO][s] + poly->at[TO][s] * dt);
            poly->W[TN][s] = 0.5 * (poly->W[TO][s] + poly->W[TO][s] + poly->ar[TO][s] * dt);
            /* velocity at the next time level */
            poly->V[TO][s] = poly->V[TO][s] + poly->at[TO][s] * dt;
            poly->W[TO][s] = poly->W[TO][s] + poly->ar[TO][s] * dt;
        }
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x20d0
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x20ff1
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x94(%rbp), %rcx
imulq $0x238, %rcx, %rcx      # imm = 0x238
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movl $0x1, %eax
cmpl 0xc(%rcx), %eax
jne 0x20c2c
jmp 0x20fdd
movsd -0x8(%rbp), %xmm0
movq -0x28(%rbp), %rax
ucomisd 0x1a0(%rax), %xmm0
jbe 0x20c89
movq -0x28(%rbp), %rdi
addq $0xe0, %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movq -0x28(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
addq $0x18, %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movq -0x28(%rbp), %rax
movsd 0x6c47(%rip), %xmm0     # 0x278c8
movsd %xmm0, 0x1a0(%rax)
movl $0x0, -0x98(%rbp)
cmpl $0x3, -0x98(%rbp)
jge 0x20d48
movl $0x0, -0x9c(%rbp)
cmpl $0x3, -0x9c(%rbp)
jge 0x20d04
movq -0x28(%rbp), %rax
addq $0x38, %rax
movslq -0x98(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x9c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movslq -0x98(%rbp), %rcx
leaq -0x70(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x9c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x20caa
movq -0x28(%rbp), %rax
movslq -0x98(%rbp), %rcx
movsd 0x188(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
divsd 0x1a8(%rax), %xmm0
movslq -0x98(%rbp), %rax
movsd %xmm0, -0x90(%rbp,%rax,8)
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x20c93
leaq -0x70(%rbp), %rsi
leaq -0x90(%rbp), %rcx
leaq -0x90(%rbp), %r8
movl $0x3, %edi
movl $0x1, %edx
callq 0x1bcf0
movl $0x0, -0xa0(%rbp)
cmpl $0x3, -0xa0(%rbp)
jge 0x20e4c
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movsd 0x158(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
addsd 0x170(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movsd 0x1a8(%rax), %xmm1
movq -0x28(%rbp), %rax
mulsd 0x1c8(%rax), %xmm1
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
addsd 0xf8(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
addsd 0x110(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movsd %xmm0, 0xe0(%rax,%rcx,8)
movslq -0xa0(%rbp), %rax
movsd -0x90(%rbp,%rax,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
addsd 0x140(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa0(%rbp), %rcx
movsd %xmm0, 0x128(%rax,%rcx,8)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x20d73
movl $0x0, -0xa4(%rbp)
cmpl $0x3, -0xa4(%rbp)
jge 0x20fdb
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0x80(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
addsd 0x80(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0xe0(%rax,%rcx,8), %xmm1
movsd -0x10(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x6854(%rip), %xmm0     # 0x27708
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd %xmm0, 0x98(%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0xb0(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
addsd 0xb0(%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0x128(%rax,%rcx,8), %xmm1
movsd -0x10(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x67eb(%rip), %xmm0     # 0x27708
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd %xmm0, 0xc8(%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0x80(%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0xe0(%rax,%rcx,8), %xmm0
movsd -0x10(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd %xmm0, 0x80(%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0xb0(%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd 0x128(%rax,%rcx,8), %xmm0
movsd -0x10(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd %xmm0, 0xb0(%rax,%rcx,8)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x20e56
jmp 0x20fdd
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x20bea
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)