// File: /workspace/github_c_makefile_star2_O0/mohuangrui[P]ArtraCFD/immersed_boundary.c
// Function: InitializeGeometricField
static void InitializeGeometricField(Space *space)
{
    const Partition *const part = &(space->part);
    Node *const node = space->node;
    const Geometry *const geo = &(space->geo);
    const Polyhedron *poly = NULL;
    int idx = 0; /* linear array index math variable */
    int gid = 0; /* store geometry identifier */
    for (int k = part->ns[PIN][Z][MIN]; k < part->ns[PIN][Z][MAX]; ++k) {
        for (int j = part->ns[PIN][Y][MIN]; j < part->ns[PIN][Y][MAX]; ++j) {
            for (int i = part->ns[PIN][X][MIN]; i < part->ns[PIN][X][MAX]; ++i) {
                idx = IndexNode(k, j, i, part->n[Y], part->n[X]);
                gid = node[idx].did;
                node[idx].gst = node[idx].did; /* preserve domain field */
                if (0 == gid) {
                    node[idx].fid = 0; /* remove passe domain change mark */
                    continue; /* skip non-polyhedron nodes */
                }
                /* the rest is to treat polyhedron nodes */
                poly = geo->poly + gid - 1;
                if (1 == poly->state) {
                    continue; /* keep domain field for nodes in stationary polyhedron */
                }
                /*
                 * The rest is to treat nodes in non-stationary polyhedrons. Due
                 * to the restricted motion, can only reset interfacial nodes for
                 * remapping while keeping non-interfacial nodes to reduce cost.
                 * When polyhedrons move, the previous nth layer may become a
                 * (n-1)th layer, therefore, need to reset gl+1 layers to
                 * ensure the closest face id information of all the future
                 * gl interfacial nodes are updated. However, if only need to
                 * update the closest face id information for the future gl-1
                 * layers, can only reset gl interfacial layers.
                 */
                if (0 < node[idx].lid) {
                    node[idx].did = 0;
                }
            }
        }
    }
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
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 $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x78(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x7c(%rcx), %eax
jge 0x18e06
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x74(%rcx), %eax
jge 0x18df6
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x18de6
movl -0x34(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %r8d
callq 0x9500
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x88, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
xorl %eax, %eax
cmpl -0x30(%rbp), %eax
jne 0x18d75
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
jmp 0x18dd8
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x238, %rcx, %rcx      # imm = 0x238
addq %rcx, %rax
addq $-0x238, %rax           # imm = 0xFDC8
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movl $0x1, %eax
cmpl 0xc(%rcx), %eax
jne 0x18da5
jmp 0x18dd8
movq -0x18(%rbp), %rcx
movslq -0x2c(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpl 0x8(%rcx), %eax
jge 0x18dd6
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
jmp 0x18dd8
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x18ce3
jmp 0x18de8
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x18cc9
jmp 0x18df8
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x18caf
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)