// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_id_lookup
SOAP_FMAC1
void*
SOAP_FMAC2
soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k)
{ struct soap_ilist *ip;
  void **q;
  if (!p || !id || !*id)
    return p;
  ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */
  if (!ip)
  { if (!(ip = soap_enter(soap, id))) /* new hash table entry for string id */
      return NULL;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d %p (%u bytes)\n", id, t, p, (unsigned int)n));
    ip->type = t;
    ip->size = n; 
    ip->link = p;
    ip->copy = NULL;
    ip->flist = NULL;
    ip->ptr = NULL;
    ip->level = k;
    *p = NULL;
  }
  else if (ip->ptr)
  { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes)\n", id, t, ip->ptr, (unsigned int)n));
    if (ip->type != t)
    { strcpy(soap->id, id);
      soap->error = SOAP_HREF;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility: href='%s' id-type=%d href-type=%d\n", id, ip->type, t));
      return NULL;
    }
    while (ip->level < k)
    { q = (void**)soap_malloc(soap, sizeof(void*));  
      if (!q)
        return NULL;
      *p = (void*)q;
      p = q;
      k--;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
    }
    *p = ip->ptr;
  }
  else if (ip->level > k)
  { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id));
    while (ip->level > k)
    { void *s, **r = &ip->link;
      q = (void**)ip->link;
      while (q)
      { *r = (void*)soap_malloc(soap, sizeof(void*));
        if (!*r)
	  return NULL;
        s = *q;
        *q = *r;
        r = (void**)*r;
        q = (void**)s;
      }
      *r = NULL;
      ip->size = n; 
      ip->copy = NULL;
      ip->level = ip->level - 1;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
    }
    q = (void**)ip->link;
    ip->link = p;
    *p = (void*)q;
  }
  else
  { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes)\n", id, t, p, (unsigned int)n));
    while (ip->level < k)
    { q = (void**)soap_malloc(soap, sizeof(void*));  
      if (!q)
        return NULL;
      *p = q;
      p = q;
      k--;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
    }
    q = (void**)ip->link;
    ip->link = p;
    *p = (void*)q;
  }
  return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r13d
movq %rdx, %rbx
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x3c052
movq %rsi, %r12
cmpb $0x0, (%rsi)
je 0x3c052
movl %r9d, %ebp
movq %rdi, %r14
movq %r8, 0x8(%rsp)
movq %r12, %rsi
callq 0x3bb85
testq %rax, %rax
je 0x3bf4e
movq %rax, %r15
cmpq $0x0, 0x30(%rax)
je 0x3bf8b
cmpl %r13d, 0x8(%r15)
jne 0x3bffd
pushq $0x8
popq %r12
cmpl %ebp, 0x38(%r15)
jae 0x3c041
movq %r14, %rdi
movq %r12, %rsi
callq 0x35f17
testq %rax, %rax
je 0x3c017
movq %rax, (%rbx)
decl %ebp
movq %rax, %rbx
jmp 0x3bf26
movq %r14, %rdi
movq %r12, %rsi
callq 0x3bbc5
testq %rax, %rax
je 0x3c017
movl %r13d, 0x8(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rbx, 0x18(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
andq $0x0, 0x30(%rax)
movl %ebp, 0x38(%rax)
andq $0x0, (%rbx)
jmp 0x3c052
movl 0x38(%r15), %ecx
cmpl %ebp, %ecx
jbe 0x3c01b
movq %r15, %r13
addq $0x18, %r13
movq %r13, 0x10(%rsp)
movq (%r13), %r12
cmpl %ebp, %ecx
jbe 0x3c064
testq %r12, %r12
je 0x3bfd9
movq %r14, %rdi
pushq $0x8
popq %rsi
callq 0x35f17
movq %rax, (%r13)
testq %rax, %rax
je 0x3c017
movq (%r12), %rcx
movq %rax, (%r12)
movq (%r13), %r13
movq %rcx, %r12
jmp 0x3bfaf
andq $0x0, (%r13)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%r15)
andq $0x0, 0x20(%r15)
movl 0x38(%r15), %ecx
decl %ecx
movl %ecx, 0x38(%r15)
movq 0x10(%rsp), %r13
jmp 0x3bfa3
leaq 0x16d38(%r14), %rdi
movq %r12, %rsi
callq 0x3090
movl $0x1a, 0x19214(%r14)
xorl %ebx, %ebx
jmp 0x3c052
pushq $0x8
popq %r12
cmpl %ebp, %ecx
jae 0x3c047
movq %r14, %rdi
movq %r12, %rsi
callq 0x35f17
testq %rax, %rax
je 0x3c017
movq %rax, (%rbx)
decl %ebp
movl 0x38(%r15), %ecx
movq %rax, %rbx
jmp 0x3c01f
movq 0x30(%r15), %rax
jmp 0x3c04f
movq 0x18(%r15), %rax
movq %rbx, 0x18(%r15)
movq %rax, (%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, (%r13)
movq %r12, (%rbx)
jmp 0x3c052