// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/immersed_boundary.c
// Function: SetDomainField
static void SetDomainField(Space *space)
{
    const Partition *const part = &(space->part);
    Node *const node = space->node;
    const Geometry *const geo = &(space->geo);
    const IntVec nMin = {part->ns[PIN][X][MIN], part->ns[PIN][Y][MIN], part->ns[PIN][Z][MIN]};
    const IntVec nMax = {part->ns[PIN][X][MAX], part->ns[PIN][Y][MAX], part->ns[PIN][Z][MAX]};
    const RealVec sMin = {part->domain[X][MIN], part->domain[Y][MIN], part->domain[Z][MIN]};
    const RealVec d = {part->d[X], part->d[Y], part->d[Z]};
    const RealVec dd = {part->dd[X], part->dd[Y], part->dd[Z]};
    const IntVec ng = {part->ng[X], part->ng[Y], part->ng[Z]};
    const Polyhedron *poly = NULL;
    int box[DIMS][LIMIT] = {{0}}; /* bounding box in node space */
    int fid = 0; /* store face link */
    int idx = 0; /* linear array index math variable */
    RealVec p = {0.0}; /* node point */
    /* overlapping geometries introduce loop-carried dependence for node mapping */
    for (int n = 0; n < geo->totN; ++n) {
        poly = geo->poly + n;
        if (1 == poly->state) {
            continue;
        }
        /* determine search range according to bounding box of polyhedron and valid node space */
        for (int s = 0; s < DIMS; ++s) {
            box[s][MIN] = ConfineSpace(MapNode(poly->box[s][MIN], sMin[s], dd[s], ng[s]), nMin[s], nMax[s]);
            box[s][MAX] = ConfineSpace(MapNode(poly->box[s][MAX], sMin[s], dd[s], ng[s]), nMin[s], nMax[s]) + 1;
        }
        /* find nodes in geometry, then flag and link to geometry */
        for (int k = box[Z][MIN]; k < box[Z][MAX]; ++k) {
            for (int j = box[Y][MIN]; j < box[Y][MAX]; ++j) {
                for (int i = box[X][MIN]; i < box[X][MAX]; ++i) {
                    idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                    if (0 != node[idx].did) { /* already classified */
                        continue;
                    }
                    p[X] = MapPoint(i, sMin[X], d[X], ng[X]);
                    p[Y] = MapPoint(j, sMin[Y], d[Y], ng[Y]);
                    p[Z] = MapPoint(k, sMin[Z], d[Z], ng[Z]);
                    if (0 >= poly->faceN) { /* analytical polyhedron */
                        if (poly->r * poly->r >= Dist2(poly->O, p)) {
                            node[idx].did = n + 1;
                            node[idx].fid = 0;
                        }
                    } else { /* triangulated polyhedron */
                        if (PointInPolyhedron(p, poly, &fid)) {
                            node[idx].did = n + 1;
                            node[idx].fid = fid;
                        }
                    }
                }
            }
        }
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x74(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x7c(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsd 0x3c8(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movsd 0x3d8(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movsd 0x3e8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x10(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x10(%rbp), %rax
movsd 0x50(%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x10(%rbp), %rax
movsd 0x58(%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x94(%rbp)
movq $0x0, -0xa8(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movl $0x0, -0xc4(%rbp)
movl $0x0, -0xc8(%rbp)
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x20d0
movl $0x0, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1934d
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0xe4(%rbp), %rcx
imulq $0x238, %rcx, %rcx      # imm = 0x238
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rcx
movl $0x1, %eax
cmpl 0xc(%rcx), %eax
jne 0x18fc9
jmp 0x19339
movl $0x0, -0xe8(%rbp)
cmpl $0x3, -0xe8(%rbp)
jge 0x190f0
movq -0xa8(%rbp), %rax
addq $0x1d0, %rax            # imm = 0x1D0
movslq -0xe8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movslq -0xe8(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm1
movslq -0xe8(%rbp), %rax
movsd -0x90(%rbp,%rax,8), %xmm2
movslq -0xe8(%rbp), %rax
movl -0x9c(%rbp,%rax,4), %edi
callq 0x95b0
movl %eax, %edi
movslq -0xe8(%rbp), %rax
movl -0x2c(%rbp,%rax,4), %esi
movslq -0xe8(%rbp), %rax
movl -0x38(%rbp,%rax,4), %edx
callq 0x95f0
movl %eax, %ecx
movslq -0xe8(%rbp), %rax
movl %ecx, -0xc0(%rbp,%rax,8)
movq -0xa8(%rbp), %rax
addq $0x1d0, %rax            # imm = 0x1D0
movslq -0xe8(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movslq -0xe8(%rbp), %rax
movsd -0x50(%rbp,%rax,8), %xmm1
movslq -0xe8(%rbp), %rax
movsd -0x90(%rbp,%rax,8), %xmm2
movslq -0xe8(%rbp), %rax
movl -0x9c(%rbp,%rax,4), %edi
callq 0x95b0
movl %eax, %edi
movslq -0xe8(%rbp), %rax
movl -0x2c(%rbp,%rax,4), %esi
movslq -0xe8(%rbp), %rax
movl -0x38(%rbp,%rax,4), %edx
callq 0x95f0
movl %eax, %ecx
addl $0x1, %ecx
movslq -0xe8(%rbp), %rax
movl %ecx, -0xbc(%rbp,%rax,8)
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x18fd3
movl -0xb0(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0xac(%rbp), %eax
jge 0x19337
movl -0xb8(%rbp), %eax
movl %eax, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x19321
movl -0xc0(%rbp), %eax
movl %eax, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jge 0x1930b
movl -0xec(%rbp), %edi
movl -0xf0(%rbp), %esi
movl -0xf4(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0xc8(%rbp)
movq -0x18(%rbp), %rcx
movslq -0xc8(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpl (%rcx), %eax
je 0x19196
jmp 0x192f7
movl -0xf4(%rbp), %edi
movsd -0x50(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
movl -0x9c(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xe0(%rbp)
movl -0xf0(%rbp), %edi
movsd -0x48(%rbp), %xmm0
movsd -0x68(%rbp), %xmm1
movl -0x98(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xd8(%rbp)
movl -0xec(%rbp), %edi
movsd -0x40(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movl -0x94(%rbp), %esi
callq 0x9690
movsd %xmm0, -0xd0(%rbp)
movq -0xa8(%rbp), %rcx
xorl %eax, %eax
cmpl (%rcx), %eax
jl 0x19296
movq -0xa8(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0xa8(%rbp), %rax
mulsd 0x18(%rax), %xmm0
movsd %xmm0, -0x100(%rbp)
movq -0xa8(%rbp), %rdi
addq $0x20, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x9910
movaps %xmm0, %xmm1
movsd -0x100(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x19294
movl -0xe4(%rbp), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movslq -0xc8(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movslq -0xc8(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
jmp 0x192f5
leaq -0xe0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
leaq -0xc4(%rbp), %rdx
callq 0xee00
cmpl $0x0, %eax
je 0x192f3
movl -0xe4(%rbp), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movslq -0xc8(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0xc4(%rbp), %ecx
movq -0x18(%rbp), %rax
movslq -0xc8(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x192f5
jmp 0x192f7
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x19138
jmp 0x1930d
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x1911a
jmp 0x19323
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x190fc
jmp 0x19339
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x18f81
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)