// File: /workspace/github_c_makefile_star2_O3/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 0x3fde2
movq %rsi, %r12
cmpb $0x0, (%rsi)
je 0x3fde2
movl %r9d, %ebp
movq %rdi, %r14
movq %r8, 0x8(%rsp)
movq %r12, %rsi
callq 0x3f849
testq %rax, %rax
je 0x3fcc0
movq %rax, %r15
movq 0x30(%rax), %rcx
testq %rcx, %rcx
je 0x3fcfd
cmpl %r13d, 0x8(%r15)
jne 0x3fd87
cmpl %ebp, 0x38(%r15)
jae 0x3fdc9
movl $0x8, %esi
movq %r14, %rdi
callq 0x39272
testq %rax, %rax
je 0x3fda1
movq %rax, (%rbx)
decl %ebp
movq %rax, %rbx
cmpl %ebp, 0x38(%r15)
jb 0x3fc90
movq 0x30(%r15), %rcx
movq %rax, %rbx
jmp 0x3fdcc
movq %r14, %rdi
movq %r12, %rsi
callq 0x3f8cf
testq %rax, %rax
je 0x3fda1
movl %r13d, 0x8(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rbx, 0x18(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
xorl %ecx, %ecx
movq %rcx, 0x30(%rax)
movl %ebp, 0x38(%rax)
movq %rcx, (%rbx)
jmp 0x3fde2
movl 0x38(%r15), %eax
cmpl %ebp, %eax
jbe 0x3fda5
movq %r15, %rdx
addq $0x18, %rdx
xorl %esi, %esi
movq 0x8(%rsp), %rcx
movq %rdx, 0x10(%rsp)
movq (%rdx), %r13
movq %rdx, %r12
testq %r13, %r13
je 0x3fd64
movq %rdx, %r12
movl $0x8, %esi
movq %r14, %rdi
callq 0x39272
movq %rax, (%r12)
testq %rax, %rax
je 0x3fda1
movq (%r13), %rcx
movq %rax, (%r13)
movq (%r12), %r12
movq %rcx, %r13
testq %rcx, %rcx
jne 0x3fd2a
movl 0x38(%r15), %eax
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
xorl %esi, %esi
movq %rsi, (%r12)
movq %rcx, 0x10(%r15)
movq %rsi, 0x20(%r15)
decl %eax
movl %eax, 0x38(%r15)
cmpl %ebp, %eax
ja 0x3fd1c
movq 0x18(%r15), %rax
movq %rbx, 0x18(%r15)
movq %rax, (%rbx)
jmp 0x3fde2
leaq 0x16d38(%r14), %rdi
movq %r12, %rsi
callq 0x3090
movl $0x1a, 0x19214(%r14)
xorl %ebx, %ebx
jmp 0x3fde2
jae 0x3fdd1
movl $0x8, %esi
movq %r14, %rdi
callq 0x39272
testq %rax, %rax
je 0x3fda1
movq %rax, (%rbx)
decl %ebp
movq %rax, %rbx
cmpl %ebp, 0x38(%r15)
jb 0x3fda7
jmp 0x3fdd4
movq %rbx, %rax
movq %rcx, (%rax)
jmp 0x3fde2
movq %rbx, %rax
movq 0x18(%r15), %rcx
movq %rax, 0x18(%r15)
movq %rcx, (%rax)
movq %rax, %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq