// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_resolve
SOAP_FMAC2
soap_resolve(struct soap *soap)
{ register int i;
  register struct soap_ilist *ip = NULL;
  register struct soap_flist *fp = NULL;
  short flag;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n"));
  for (i = 0; i < SOAP_IDHASH; i++)
  { for (ip = soap->iht[i]; ip; ip = ip->next)
    { if (ip->ptr)
      { register void *p, **q, *r;
        q = (void**)ip->link;
        ip->link = NULL;
        r = ip->ptr;
        DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s'\n", ip->id));
        while (q)
        { p = *q;
          *q = r;
          DBGLOG(TEST,SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, r));
          q = (void**)p;
        }
      }
      else if (*ip->id == '#')
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing data for id='%s'\n", ip->id));
        strcpy(soap->id, ip->id + 1);
        return soap->error = SOAP_MISSING_ID;
      }
    }
  }
  do
  { flag = 0;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution phase\n"));
    for (i = 0; i < SOAP_IDHASH; i++)
    { for (ip = soap->iht[i]; ip; ip = ip->next)
      { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size))
        { if (ip->copy)
          { register void *p, **q = (void**)ip->copy;
            DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id));
            ip->copy = NULL;
            do
            { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size));
              p = *q;
              memcpy(q, ip->ptr, ip->size);
              q = (void**)p;
            } while (q);
            flag = 1;
          }
          for (fp = ip->flist; fp; fp = ip->flist)
          { register unsigned int k = fp->level;
            register void *p = ip->ptr;
            DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d location=%p level=%u,%u id='%s'\n", ip->type, p, ip->level, fp->level, ip->id));
            while (ip->level < k)
            { register void **q = (void**)soap_malloc(soap, sizeof(void*));  
              if (!q)
                return soap->error;
              *q = p;
              DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level, new location=%p holds=%p...\n", q, *q));
              p = (void*)q;
              k--;
            }
            if (fp->fcopy)
              fp->fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size);
            else
              soap_fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size);
            ip->flist = fp->next;
            SOAP_FREE(soap, fp);
            flag = 1;
          }
        }
      }
    }
  } while (flag);
#ifdef SOAP_DEBUG
  for (i = 0; i < SOAP_IDHASH; i++)
  { for (ip = soap->iht[i]; ip; ip = ip->next)
    { if (ip->copy || ip->flist)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the developers\n", ip->id));
      }
    }
  }
#endif
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution done\n"));
  return SOAP_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0xa8(%rdi), %rbp
xorl %eax, %eax
cmpq $0x7cf, %rax            # imm = 0x7CF
je 0x373ff
leaq (,%rax,8), %rsi
addq %rbp, %rsi
movq (%rsi), %rsi
testq %rsi, %rsi
je 0x373ce
movq 0x30(%rsi), %rcx
testq %rcx, %rcx
je 0x373c6
movq 0x18(%rsi), %rdx
andq $0x0, 0x18(%rsi)
testq %rdx, %rdx
je 0x3739c
movq (%rdx), %rdi
movq %rcx, (%rdx)
movq %rdi, %rdx
jmp 0x373b6
cmpb $0x23, 0x3c(%rsi)
jne 0x3739c
jmp 0x373d3
incq %rax
jmp 0x37389
leaq 0x16d38(%rbx), %rdi
addq $0x3d, %rsi
callq 0x3090
movl $0x19, 0x19214(%rbx)
pushq $0x19
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
xorl %r10d, %r10d
cmpq $0x7cf, %rax            # imm = 0x7CF
je 0x37565
leaq (,%rax,8), %r15
addq %rbp, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x3755d
movq 0x30(%r15), %rcx
testq %rcx, %rcx
je 0x3741b
movq 0x10(%r15), %rdx
addq %rcx, %rdx
xorl %esi, %esi
cmpq $0x7cf, %rsi            # imm = 0x7CF
je 0x3748e
leaq (,%rsi,8), %rdi
addq %rbp, %rdi
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x37489
leaq 0x20(%rdi), %r8
movq (%r8), %r8
testq %r8, %r8
je 0x3746d
cmpq %rcx, %r8
jb 0x37459
cmpq %rdx, %r8
jae 0x37459
jmp 0x3741b
leaq 0x28(%rdi), %r8
movq (%r8), %r8
testq %r8, %r8
je 0x3744d
movq 0x10(%r8), %r9
cmpq %rcx, %r9
jb 0x37471
cmpq %rdx, %r9
jae 0x37471
jmp 0x3741b
incq %rsi
jmp 0x37439
movq %rax, 0x10(%rsp)
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x374be
andq $0x0, 0x20(%r15)
movq (%rdi), %r14
movq 0x10(%r15), %rdx
movq 0x30(%r15), %rsi
callq 0x3240
movq %r14, %rdi
testq %r14, %r14
jne 0x374a1
jmp 0x37549
movq 0x28(%r15), %r12
testq %r12, %r12
je 0x37553
movl 0x18(%r12), %r14d
movq 0x30(%r15), %r13
cmpl %r14d, 0x38(%r15)
jae 0x374f9
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x35f17
testq %rax, %rax
je 0x3757c
movq %r13, (%rax)
decl %r14d
movq %rax, %r13
jmp 0x374d4
movq 0x28(%r12), %rax
testq %rax, %rax
je 0x37528
movl 0x8(%r15), %esi
movl 0x8(%r12), %edx
movq 0x10(%r12), %rcx
movq 0x20(%r12), %r8
movq 0x10(%r15), %rdi
movq %rdi, (%rsp)
movq %rbx, %rdi
movq %r13, %r9
callq *%rax
jmp 0x37539
movq 0x10(%r12), %rdi
movq 0x10(%r15), %rdx
movq %r13, %rsi
callq 0x3240
movq (%r12), %rax
movq %rax, 0x28(%r15)
movq %r12, %rdi
callq 0x3030
movw $0x1, %r10w
jmp 0x374be
movq 0x10(%rsp), %rax
jmp 0x3741b
incq %rax
jmp 0x37404
xorl %eax, %eax
testw %r10w, %r10w
movl $0x0, %r10d
jne 0x37404
jmp 0x373f0
movl 0x19214(%rbx), %eax
jmp 0x373f0