// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/intrpt.c
// Function: findMemberIndex
ccInt findMemberIndex(variable *theVariable, ccInt currentOffset, ccInt soughtMemberIndex,
        member **soughtMember, ccInt *memberNumber, ccInt *entryOffset, ccBool allowAddMember)
{
    ccInt indexCounter, rtrn;
    
    if (soughtMemberIndex <= 0)  return invalid_index_err;
    
    
        // if it's a composite variable, return the Nth member
    
    if (theVariable->type == composite_type)  {
        *entryOffset = 0;
        indexCounter = 0;
        for (*memberNumber = 1; *memberNumber <= theVariable->mem.members.elementNum; (*memberNumber)++)  {
            *soughtMember = LL_member(theVariable, *memberNumber);
            if (!(*soughtMember)->ifHidden)  {
                indexCounter++;
                if (indexCounter == soughtMemberIndex)  return passed;
        }   }
        
        if ((!allowAddMember) || (indexCounter != soughtMemberIndex-1))  {
            *entryOffset = *memberNumber;
            return invalid_index_err;         }
        
        else  {
            *memberNumber = theVariable->mem.members.elementNum + 1;
            rtrn = addMember(theVariable, *memberNumber, 1, soughtMember, ccFalse, 1, ccTrue);
            if (rtrn == passed)  (*soughtMember)->memberID = 0;
            return rtrn;
    }   }
    
    
        // if it's an array or string variable, return the Nth index of the first member
    
    if (theVariable->type == string_type)
        *memberNumber = currentOffset+1;
    else  *memberNumber = 1;
    *soughtMember = LL_member(theVariable, *memberNumber);
    
    
    if (soughtMemberIndex > (*soughtMember)->indices)  {
        *entryOffset = (*soughtMember)->indices+1;
        return invalid_index_err;    }
    
    *entryOffset = soughtMemberIndex - 1;
    return passed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x1e
popq %rbx
testl %edx, %edx
jle 0xe468
movq %r9, %r15
movq %r8, %r13
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %r12
movl 0xc0(%rdi), %eax
cmpl $0x4, %eax
je 0xe3e8
cmpl $0x5, %eax
jne 0xe3ec
movq %r15, 0x10(%rsp)
andl $0x0, (%r15)
leaq 0x10(%r12), %r15
xorl %ebx, %ebx
pushq $0x1
popq %rsi
movl %esi, (%r13)
movl (%r15), %eax
cmpl %eax, %esi
jg 0xe419
movq %r15, %rdi
callq 0x9088
movq %rax, (%r14)
cmpb $0x0, 0x40(%rax)
jne 0xe3e0
incl %ebx
cmpl %ebp, %ebx
je 0xe415
movl (%r13), %esi
incl %esi
jmp 0xe3be
incl %esi
jmp 0xe3ef
pushq $0x1
popq %rsi
movl %esi, (%r13)
addq $0x10, %r12
movq %r12, %rdi
callq 0x9088
movq %rax, (%r14)
movl 0xc(%rax), %eax
cmpl %ebp, %eax
jge 0xe410
incl %eax
movl %eax, (%r15)
jmp 0xe468
decl %ebp
movl %ebp, (%r15)
xorl %ebx, %ebx
jmp 0xe468
cmpb $0x0, 0x50(%rsp)
setne %cl
decl %ebp
cmpl %ebp, %ebx
sete %dl
testb %dl, %cl
je 0xe45e
incl %eax
movl %eax, (%r13)
movl $0x1, (%rsp)
pushq $0x1
popq %rbx
movq %r12, %rdi
movl %eax, %esi
movl %ebx, %edx
movq %r14, %rcx
xorl %r8d, %r8d
movl %ebx, %r9d
callq 0xe2d6
testl %eax, %eax
jne 0xe468
movq (%r14), %rax
andl $0x0, 0x8(%rax)
jmp 0xe415
movq 0x10(%rsp), %rax
movl %esi, (%rax)
pushq $0x1e
popq %rbx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq