// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/computational_geometry.c
// Function: ComputeIntersection
Real ComputeIntersection(const Real p[restrict], const int fid,
        const Polyhedron *poly, Real pi[restrict], Real N[restrict])
{
    const Real zero = 0.0;
    const Real one = 1.0;
    RealVec v0 = {zero}; /* vertices */
    RealVec v1 = {zero};
    RealVec v2 = {zero};
    RealVec e01 = {zero}; /* edges */
    RealVec e02 = {zero};
    RealVec para = {zero}; /* parametric coordinates */
    const IntVec v = {poly->f[fid][0], poly->f[fid][1], poly->f[fid][2]}; /* vertex index in vertex list */
    int e = 0; /* edge index in edge list */
    BuildTriangle(fid, poly, v0, v1, v2, e01, e02);
    const Real distSquare = PointTriangleDistance(p, v0, e01, e02, para);
    if (zero == para[1]) {
        if (zero == para[2]) {
            /* vertex 0 */
            for (int s = 0; s < DIMS; ++s) {
                pi[s] = v0[s];
                N[s] = poly->Nv[v[0]][s];
            }
        } else {
            if (one == para[2]) {
                /* vertex 2 */
                for (int s = 0; s < DIMS; ++s) {
                    pi[s] = v2[s];
                    N[s] = poly->Nv[v[2]][s];
                }
            } else {
                /* edge e02 */
                e = FindEdge(v[0], v[2], poly->edgeN, poly->e);
                for (int s = 0; s < DIMS; ++s) {
                    pi[s] = v0[s] + para[2] * e02[s];
                    N[s] = poly->Ne[e][s];
                }
            }
        }
    } else {
        if (one == para[1]) {
            /* vertex 1 */
            for (int s = 0; s < DIMS; ++s) {
                pi[s] = v1[s];
                N[s] = poly->Nv[v[1]][s];
            }
        } else {
            if (zero == para[2]) {
                /* edge e01 */
                e = FindEdge(v[0], v[1], poly->edgeN, poly->e);
                for (int s = 0; s < DIMS; ++s) {
                    pi[s] = v0[s] + para[1] * e01[s];
                    N[s] = poly->Ne[e][s];
                }
            } else {
                if (zero == para[0]) {
                    /* edge e12 */
                    e = FindEdge(v[1], v[2], poly->edgeN, poly->e);
                    for (int s = 0; s < DIMS; ++s) {
                        pi[s] = v0[s] + para[1] * e01[s] + para[2] * e02[s];
                        N[s] = poly->Ne[e][s];
                    }
                } else {
                    /* complete in the triangle */
                    for (int s = 0; s < DIMS; ++s) {
                        pi[s] = v0[s] + para[1] * e01[s] + para[2] * e02[s];
                        N[s] = poly->Nf[fid][s];
                    }
                }
            }
        }
    }
    return distSquare;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x179f2(%rip), %xmm0    # 0x27710
movsd %xmm0, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xd0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movq -0x18(%rbp), %rax
movq 0x200(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
movq -0x18(%rbp), %rax
movq 0x200(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movq 0x200(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xf4(%rbp)
movl $0x0, -0x100(%rbp)
movl -0xc(%rbp), %edi
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x70(%rbp), %rcx
leaq -0x90(%rbp), %r8
leaq -0xb0(%rbp), %r9
leaq -0xd0(%rbp), %rax
movq %rax, (%rsp)
callq 0xeca0
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
leaq -0xf0(%rbp), %r8
callq 0xf040
movsd %xmm0, -0x108(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xe8(%rbp), %xmm0
jne 0x10052
jp 0x10052
xorps %xmm0, %xmm0
ucomisd -0xe0(%rbp), %xmm0
jne 0xfeed
jp 0xfeed
movl $0x0, -0x10c(%rbp)
cmpl $0x3, -0x10c(%rbp)
jge 0xfee8
movslq -0x10c(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x10c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x228(%rax), %rax
movslq -0xfc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x10c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x10c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0xfe7c
jmp 0x1004d
movsd 0x1781b(%rip), %xmm0    # 0x27710
ucomisd -0xe0(%rbp), %xmm0
jne 0xff83
jp 0xff83
movl $0x0, -0x110(%rbp)
cmpl $0x3, -0x110(%rbp)
jge 0xff7e
movslq -0x110(%rbp), %rax
movsd -0x90(%rbp,%rax,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x110(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x228(%rax), %rax
movslq -0xf4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x110(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x110(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0xff0f
jmp 0x1004b
movl -0xfc(%rbp), %edi
movl -0xf4(%rbp), %esi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x210(%rax), %rcx
callq 0x103a0
movl %eax, -0x100(%rbp)
movl $0x0, -0x114(%rbp)
cmpl $0x3, -0x114(%rbp)
jge 0x10049
movslq -0x114(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm1
movsd -0xe0(%rbp), %xmm0
movslq -0x114(%rbp), %rax
movsd -0xd0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x114(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x100(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x114(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x114(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0xffb6
jmp 0x1004b
jmp 0x1004d
jmp 0x10387
movsd 0x176b6(%rip), %xmm0    # 0x27710
ucomisd -0xe8(%rbp), %xmm0
jne 0x100e1
jp 0x100e1
movl $0x0, -0x118(%rbp)
cmpl $0x3, -0x118(%rbp)
jge 0x100dc
movslq -0x118(%rbp), %rax
movsd -0x70(%rbp,%rax,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x118(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x228(%rax), %rax
movslq -0xf8(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x118(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x118(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x10070
jmp 0x10385
xorps %xmm0, %xmm0
ucomisd -0xe0(%rbp), %xmm0
jne 0x101c3
jp 0x101c3
movl -0xfc(%rbp), %edi
movl -0xf8(%rbp), %esi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x210(%rax), %rcx
callq 0x103a0
movl %eax, -0x100(%rbp)
movl $0x0, -0x11c(%rbp)
cmpl $0x3, -0x11c(%rbp)
jge 0x101be
movslq -0x11c(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm1
movsd -0xe8(%rbp), %xmm0
movslq -0x11c(%rbp), %rax
movsd -0xb0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x11c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x100(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x11c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x11c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x1012b
jmp 0x10383
xorps %xmm0, %xmm0
ucomisd -0xf0(%rbp), %xmm0
jne 0x102c5
jp 0x102c5
movl -0xf8(%rbp), %edi
movl -0xf4(%rbp), %esi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x18(%rbp), %rax
movq 0x210(%rax), %rcx
callq 0x103a0
movl %eax, -0x100(%rbp)
movl $0x0, -0x120(%rbp)
cmpl $0x3, -0x120(%rbp)
jge 0x102c0
movslq -0x120(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm0
movsd -0xe8(%rbp), %xmm1
movslq -0x120(%rbp), %rax
movsd -0xb0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
movslq -0x120(%rbp), %rax
movsd -0xd0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x120(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x100(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x120(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x120(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x1020d
jmp 0x10381
movl $0x0, -0x124(%rbp)
cmpl $0x3, -0x124(%rbp)
jge 0x1037f
movslq -0x124(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm0
movsd -0xe8(%rbp), %xmm1
movslq -0x124(%rbp), %rax
movsd -0xb0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
movslq -0x124(%rbp), %rax
movsd -0xd0(%rbp,%rax,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x124(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x208(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x124(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x124(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x102cf
jmp 0x10381
jmp 0x10383
jmp 0x10385
jmp 0x10387
movsd -0x108(%rbp), %xmm0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax,%rax)