// File: /workspace/github_c_makefile_star2_O1/mohuangrui[P]ArtraCFD/immersed_boundary.c
// Function: GetInterState
static int GetInterState(const int sid, const int k, const int j, const int i, const int did,
        const int end, const int path[restrict][DIMS], const Node *const node, const Partition *const part)
{
    /* search around the specified node to check interfacial state */
    int idx = 0; /* linear array index math variable */
    int ih = 0, jh = 0, kh = 0; /* neighbouring node */
    int flag = 0; /* control flag */
    for (int n = 0; n < end; ++n) {
        kh = k + path[n][Z];
        jh = j + path[n][Y];
        ih = i + path[n][X];
        if (!InPartBox(kh, jh, ih, part->ns[PIN])) {
            continue;
        }
        idx = IndexNode(kh, jh, ih, part->n[Y], part->n[X]);
        switch (sid) {
            case INTERL:
                if (did != node[idx].did) { /* a heterogeneous node on the path */
                    flag = 1;
                }
                break;
            case INTERG:
                if (did == node[idx].did) { /* a computational node on the path */
                    flag = 1;
                }
                break;
            default:
                break;
        }
        if (1 == flag) { /* return the layer number */
            for (int r = 1; r <= part->gl; ++r) {
                if (part->pathSep[r] > n) {
                    return r;
                }
            }
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, 0x14(%rsp)
movl %ecx, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movl %esi, 0x18(%rsp)
movl %edi, 0x10(%rsp)
testl %r9d, %r9d
jle 0x12c84
movq 0x80(%rsp), %rax
addq $0x68, %rax
movq %rax, 0x30(%rsp)
movl %r9d, %eax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
leaq (,%r13,2), %rax
addq %r13, %rax
movq 0x70(%rsp), %rcx
movl 0x8(%rcx,%rax,4), %ebx
addl 0x18(%rsp), %ebx
movl 0x4(%rcx,%rax,4), %r12d
addl 0x1c(%rsp), %r12d
movl (%rcx,%rax,4), %ebp
addl 0x20(%rsp), %ebp
movl %ebx, %edi
movl %r12d, %esi
movl %ebp, %edx
movq 0x30(%rsp), %rcx
callq 0x7eb0
testl %eax, %eax
je 0x12c76
cmpl $0x0, 0x10(%rsp)
movl %r14d, 0x24(%rsp)
sete %r14b
movq 0x80(%rsp), %r15
movl 0xc(%r15), %r8d
movl 0x10(%r15), %ecx
movl %ebx, %edi
movl %r12d, %esi
movl %ebp, %edx
callq 0x7ea3
cltq
movq %rax, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rax,8), %rax
movl 0x14(%rsp), %ecx
movq 0x78(%rsp), %rdx
cmpl %ecx, (%rdx,%rax)
sete %al
xorb %r14b, %al
cmpl $0x1, 0x24(%rsp)
sete %cl
orb %al, %cl
xorl %r14d, %r14d
cmpb $0x1, %cl
jne 0x12c76
movslq 0x24(%r15), %rcx
testq %rcx, %rcx
setle %dl
jle 0x12c64
movslq 0x384(%r15), %rsi
movl $0x1, %eax
cmpq %rsi, %r13
jl 0x12c68
leal 0x1(%rcx), %edx
addq $-0x2, %rdx
movl $0x1, %eax
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x12c5e
movslq 0x388(%r15,%rsi,4), %rdi
incq %rsi
incq %rax
cmpq %rdi, %r13
jge 0x12c3e
cmpq %rcx, %rsi
setae %dl
jmp 0x12c68
cmpq %rcx, %rax
setae %dl
movl 0xc(%rsp), %eax
movl $0x1, %r14d
movl %eax, 0xc(%rsp)
testb %dl, %dl
je 0x12c86
incq %r13
cmpq 0x28(%rsp), %r13
jne 0x12b76
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)