// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5c6b6
cmpq $0x0, -0x18(%rbp)
je 0x5c6b6
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x5c6c3
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5c98d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5bf30
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x5c763
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5bfc0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x5c703
movq $0x0, -0x8(%rbp)
jmp 0x5c98d
movl -0x24(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x30(%rax)
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
jmp 0x5c985
movq -0x40(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x5c813
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x24(%rbp), %eax
je 0x5c7ad
movq -0x10(%rbp), %rdi
addq $0x16d38, %rdi          # imm = 0x16D38
movq -0x18(%rbp), %rsi
callq 0x3090
movq -0x10(%rbp), %rax
movl $0x1a, 0x19214(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x5c98d
jmp 0x5c7af
movq -0x40(%rbp), %rax
movl 0x38(%rax), %eax
cmpl -0x34(%rbp), %eax
jae 0x5c7ff
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x518f0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x5c7e1
movq $0x0, -0x8(%rbp)
jmp 0x5c98d
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5c7af
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5c983
movq -0x40(%rbp), %rax
movl 0x38(%rax), %eax
cmpl -0x34(%rbp), %eax
jbe 0x5c90f
jmp 0x5c825
movq -0x40(%rbp), %rax
movl 0x38(%rax), %eax
cmpl -0x34(%rbp), %eax
jbe 0x5c8ea
movq -0x40(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x5c8b1
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x518f0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5c883
movq $0x0, -0x8(%rbp)
jmp 0x5c98d
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x5c84d
movq -0x58(%rbp), %rax
movq $0x0, (%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movl 0x38(%rax), %ecx
subl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x38(%rax)
jmp 0x5c825
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5c981
jmp 0x5c911
movq -0x40(%rbp), %rax
movl 0x38(%rax), %eax
cmpl -0x34(%rbp), %eax
jae 0x5c95e
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x518f0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x5c940
movq $0x0, -0x8(%rbp)
jmp 0x5c98d
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5c911
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5c983
jmp 0x5c985
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)