// File: /workspace/github_c_makefile_star2_O1/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 0xf161
movq %r9, %r15
movq %r8, %r13
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %r12
movl 0xc0(%rdi), %eax
cmpl $0x4, %eax
je 0xf0d7
movl $0x1, %esi
cmpl $0x5, %eax
jne 0xf0d9
movq %r15, 0x10(%rsp)
movl $0x0, (%r15)
movl $0x1, (%r13)
movl 0x10(%r12), %esi
testl %esi, %esi
jle 0xf103
leaq 0x10(%r12), %r15
movl $0x1, %eax
xorl %ebx, %ebx
movq %r15, %rdi
movl %eax, %esi
callq 0x911c
movq %rax, (%r14)
cmpb $0x0, 0x40(%rax)
jne 0xf0c3
incl %ebx
cmpl %ebp, %ebx
je 0xf0ff
movl (%r13), %ecx
leal 0x1(%rcx), %eax
movl %eax, (%r13)
movl (%r15), %esi
cmpl %esi, %ecx
jl 0xf0aa
jmp 0xf10a
incl %esi
movl %esi, (%r13)
addq $0x10, %r12
movq %r12, %rdi
callq 0x911c
movq %rax, (%r14)
movl 0xc(%rax), %eax
cmpl %ebp, %eax
jge 0xf0fa
incl %eax
movl %eax, (%r15)
jmp 0xf161
decl %ebp
movl %ebp, (%r15)
xorl %ebx, %ebx
jmp 0xf161
xorl %ebx, %ebx
movl $0x1, %eax
cmpb $0x0, 0x50(%rsp)
setne %cl
decl %ebp
cmpl %ebp, %ebx
sete %dl
testb %dl, %cl
je 0xf155
incl %esi
movl %esi, (%r13)
movl $0x1, (%rsp)
movq %r12, %rdi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xefa3
movl %eax, %ebx
testl %eax, %eax
jne 0xf161
movq (%r14), %rax
movl $0x0, 0x8(%rax)
jmp 0xf161
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