// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/computational_geometry.c
// Function: TransformPolyhedron
void TransformPolyhedron(const Real O[restrict], const Real scale[restrict],
        const Real angle[restrict], const Real offset[restrict], Polyhedron *poly)
{
    const RealVec Sin = {sin(angle[X]), sin(angle[Y]), sin(angle[Z])};
    const RealVec Cos = {cos(angle[X]), cos(angle[Y]), cos(angle[Z])};
    const Real rotate[DIMS][DIMS] = { /* point rotation matrix */
        {Cos[Y]*Cos[Z], -Cos[X]*Sin[Z]+Sin[X]*Sin[Y]*Cos[Z], Sin[X]*Sin[Z]+Cos[X]*Sin[Y]*Cos[Z]},
        {Cos[Y]*Sin[Z], Cos[X]*Cos[Z]+Sin[X]*Sin[Y]*Sin[Z], -Sin[X]*Cos[Z]+Cos[X]*Sin[Y]*Sin[Z]},
        {-Sin[Y], Sin[X]*Cos[Y], Cos[X]*Cos[Y]}};
    const Real invrot[DIMS][DIMS] = { /* inverse rotation matrix */
        {rotate[0][0], rotate[1][0], rotate[2][0]},
        {rotate[0][1], rotate[1][1], rotate[2][1]},
        {rotate[0][2], rotate[1][2], rotate[2][2]}};
    const Real num = 1.0 / sqrt(2.0);
    const Real axe[6][DIMS] = { /* direction vector of axis xx, yy, zz, xy, yz, zx */
        {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0},
        {num, num, 0.0}, {0.0, num, num}, {num, 0.0, num}};
    RealVec axis = {0.0}; /* direction vector of axis in rotated frame */
    Real I[6] = {0.0}; /* inertia tensor after rotation */
    /* transforming vertex and build the new bounding box */
    for (int s = 0; s < DIMS; ++s) {
        poly->box[s][MIN] = FLT_MAX;
        poly->box[s][MAX] = FLT_MIN;
    }
    TransformVertex(O, scale, rotate, offset, poly->box, poly->vertN, poly->v);
    /* transforming normal assuming pure rotation and translation */
    TransformNormal(rotate, poly->faceN, poly->Nf);
    TransformNormal(rotate, poly->edgeN, poly->Ne);
    TransformNormal(rotate, poly->vertN, poly->Nv);
    /* transform inertial tensor */
    for (int n = 0; n < 6; ++n) {
        axis[X] = Dot(invrot[X], axe[n]);
        axis[Y] = Dot(invrot[Y], axe[n]);
        axis[Z] = Dot(invrot[Z], axe[n]);
        I[n] = TransformInertia(axis, poly->I);
    }
    poly->I[X][X] = I[0];  poly->I[X][Y] = -I[3]; poly->I[X][Z] = -I[5];
    poly->I[Y][X] = -I[3]; poly->I[Y][Y] = I[1];  poly->I[Y][Z] = -I[4];
    poly->I[Z][X] = -I[5]; poly->I[Z][Y] = -I[4]; poly->I[Z][Z] = I[2];
    /* centroid should be transformed at last */
    Real Oc[1][DIMS] = {{poly->O[X], poly->O[Y], poly->O[Z]}};
    TransformVertex(O, scale, rotate, offset, poly->box, 1, Oc);
    poly->O[X] = Oc[0][X];
    poly->O[Y] = Oc[0][Y];
    poly->O[Z] = Oc[0][Z];
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x21c0
movsd %xmm0, -0x40(%rbp)
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0x21c0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x21c0
movsd %xmm0, -0x30(%rbp)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x20f0
movsd %xmm0, -0x60(%rbp)
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0x20f0
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x20f0
movsd %xmm0, -0x50(%rbp)
movsd -0x58(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x60(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x30(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
mulsd -0x50(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
mulsd -0x50(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x58(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd -0x50(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd -0x38(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x40(%rbp), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd 0x1a96d(%rip), %xmm0    # 0x27720
callq 0x2200
movaps %xmm0, %xmm1
movsd 0x1a94d(%rip), %xmm0    # 0x27710
divsd %xmm1, %xmm0
movsd %xmm0, -0x108(%rbp)
movq 0x1ab32(%rip), %rax     # 0x27908
movq %rax, -0x1a0(%rbp)
movq 0x1ab2c(%rip), %rax     # 0x27910
movq %rax, -0x198(%rbp)
movq 0x1ab26(%rip), %rax     # 0x27918
movq %rax, -0x190(%rbp)
movq 0x1ab20(%rip), %rax     # 0x27920
movq %rax, -0x188(%rbp)
movq 0x1ab1a(%rip), %rax     # 0x27928
movq %rax, -0x180(%rbp)
movq 0x1ab14(%rip), %rax     # 0x27930
movq %rax, -0x178(%rbp)
movq 0x1ab0e(%rip), %rax     # 0x27938
movq %rax, -0x170(%rbp)
movq 0x1ab08(%rip), %rax     # 0x27940
movq %rax, -0x168(%rbp)
movq 0x1ab02(%rip), %rax     # 0x27948
movq %rax, -0x160(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x148(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x140(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x120(%rbp)
movsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
leaq -0x1c0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0x1f0(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x20d0
movl $0x0, -0x1f4(%rbp)
cmpl $0x3, -0x1f4(%rbp)
jge 0xcf61
movq -0x28(%rbp), %rax
addq $0x1d0, %rax            # imm = 0x1D0
movslq -0x1f4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x1a9a1(%rip), %xmm0    # 0x278c8
movsd %xmm0, (%rax)
movq -0x28(%rbp), %rax
addq $0x1d0, %rax            # imm = 0x1D0
movslq -0x1f4(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x1a7fd(%rip), %xmm0    # 0x27748
movsd %xmm0, 0x8(%rax)
movl -0x1f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f4(%rbp)
jmp 0xcefe
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
addq $0x1d0, %r8             # imm = 0x1D0
movq -0x28(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x28(%rbp), %rax
movq 0x220(%rax), %rax
movq %rax, (%rsp)
callq 0xd290
leaq -0xb0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %esi
movq -0x28(%rbp), %rax
movq 0x208(%rax), %rdx
callq 0xd690
leaq -0xb0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x28(%rbp), %rax
movq 0x218(%rax), %rdx
callq 0xd690
leaq -0xb0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x28(%rbp), %rax
movq 0x228(%rax), %rdx
callq 0xd690
movl $0x0, -0x1f8(%rbp)
cmpl $0x6, -0x1f8(%rbp)
jge 0xd0c6
leaq -0x100(%rbp), %rdi
movslq -0x1f8(%rbp), %rax
leaq -0x1a0(%rbp), %rsi
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x9880
movsd %xmm0, -0x1c0(%rbp)
leaq -0x100(%rbp), %rdi
addq $0x18, %rdi
movslq -0x1f8(%rbp), %rax
leaq -0x1a0(%rbp), %rsi
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x9880
movsd %xmm0, -0x1b8(%rbp)
leaq -0x100(%rbp), %rdi
addq $0x30, %rdi
movslq -0x1f8(%rbp), %rax
leaq -0x1a0(%rbp), %rsi
imulq $0x18, %rax, %rax
addq %rax, %rsi
callq 0x9880
movsd %xmm0, -0x1b0(%rbp)
leaq -0x1c0(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x38, %rsi
callq 0xd790
movslq -0x1f8(%rbp), %rax
movsd %xmm0, -0x1f0(%rbp,%rax,8)
movl -0x1f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f8(%rbp)
jmp 0xcffe
movsd -0x1f0(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movsd -0x1d8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movsd -0x1c8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movsd -0x1d8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x50(%rax)
movsd -0x1e8(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x58(%rax)
movsd -0x1d0(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x60(%rax)
movsd -0x1c8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movsd -0x1d0(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movsd -0x1e0(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x78(%rax)
movq -0x28(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x210(%rbp)
movq -0x28(%rbp), %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, -0x208(%rbp)
movq -0x28(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x200(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
addq $0x1d0, %r8             # imm = 0x1D0
leaq -0x210(%rbp), %rax
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0xd290
movsd -0x210(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movsd -0x208(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movsd -0x200(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x30(%rax)
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopl (%rax)