// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1e, %ebx
testl %edx, %edx
jle 0xef22
movq %r9, %r15
movq %r8, %r13
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %r12
movl 0xc0(%rdi), %eax
cmpl $0x4, %eax
je 0xee95
movl $0x1, %esi
cmpl $0x5, %eax
jne 0xee97
movq %r15, 0x10(%rsp)
movl $0x0, (%r15)
movl $0x1, (%r13)
movl 0x10(%r12), %esi
testl %esi, %esi
jle 0xeec1
leaq 0x10(%r12), %r15
movl $0x1, %eax
xorl %ebx, %ebx
movq %r15, %rdi
movl %eax, %esi
callq 0x91d8
movq %rax, (%r14)
cmpb $0x0, 0x40(%rax)
jne 0xee81
incl %ebx
cmpl %ebp, %ebx
je 0xeebd
movl (%r13), %ecx
leal 0x1(%rcx), %eax
movl %eax, (%r13)
movl (%r15), %esi
cmpl %esi, %ecx
jl 0xee68
jmp 0xeec8
incl %esi
movl %esi, (%r13)
addq $0x10, %r12
movq %r12, %rdi
callq 0x91d8
movq %rax, (%r14)
movl 0xc(%rax), %eax
cmpl %ebp, %eax
jge 0xeeb8
incl %eax
movl %eax, (%r15)
jmp 0xef22
decl %ebp
movl %ebp, (%r15)
xorl %ebx, %ebx
jmp 0xef22
xorl %ebx, %ebx
movl $0x1, %eax
cmpb $0x0, 0x50(%rsp)
setne %cl
decl %ebp
cmpl %ebp, %ebx
sete %dl
testb %dl, %cl
je 0xef16
incl %esi
movl %esi, (%r13)
movl $0x1, (%rsp)
movl $0x1, %ebx
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xed61
testl %eax, %eax
jne 0xef22
movq (%r14), %rax
movl $0x0, 0x8(%rax)
jmp 0xeebd
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl $0x1e, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq