// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdi, %rbx
xorl %eax, %eax
movq 0xa8(%rbx,%rax,8), %rsi
testq %rsi, %rsi
je 0x3a6af
movq 0x30(%rsi), %rcx
testq %rcx, %rcx
je 0x3a6a0
movq 0x18(%rsi), %rdx
movq $0x0, 0x18(%rsi)
testq %rdx, %rdx
je 0x3a6aa
movq (%rdx), %rdi
movq %rcx, (%rdx)
movq %rdi, %rdx
testq %rdi, %rdi
jne 0x3a690
jmp 0x3a6aa
cmpb $0x23, 0x3c(%rsi)
je 0x3a892
movq (%rsi), %rsi
jmp 0x3a671
incq %rax
cmpq $0x7cf, %rax            # imm = 0x7CF
jne 0x3a669
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %r9
movq 0xa8(%rbx,%r9,8), %r13
movl %eax, %r10d
testq %r13, %r13
je 0x3a84e
movq 0x30(%r13), %rax
testq %rax, %rax
je 0x3a845
movq 0x10(%r13), %rcx
addq %rax, %rcx
xorl %edx, %edx
movq 0xa8(%rbx,%rdx,8), %rsi
testq %rsi, %rsi
je 0x3a747
leaq 0x20(%rsi), %rdi
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3a723
cmpq %rax, %rdi
jb 0x3a70c
cmpq %rcx, %rdi
jae 0x3a70c
jmp 0x3a845
leaq 0x28(%rsi), %rdi
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3a742
movq 0x10(%rdi), %r8
cmpq %rax, %r8
jb 0x3a727
cmpq %rcx, %r8
jae 0x3a727
jmp 0x3a845
movq (%rsi), %rsi
jmp 0x3a703
incq %rdx
cmpq $0x7cf, %rdx            # imm = 0x7CF
jne 0x3a6fb
movl %r10d, 0x14(%rsp)
movq 0x20(%r13), %rdi
testq %rdi, %rdi
je 0x3a78a
movq $0x0, 0x20(%r13)
movq (%rdi), %r14
movq 0x10(%r13), %rdx
movq 0x30(%r13), %rsi
callq 0x3230
movq %r14, %rdi
testq %r14, %r14
jne 0x3a769
movw $0x1, %ax
movq %rax, 0x20(%rsp)
movq 0x28(%r13), %r14
testq %r14, %r14
je 0x3a83b
movl 0x18(%r14), %ecx
movq 0x30(%r13), %r15
movl %ecx, %r12d
movl 0x38(%r13), %ebp
cmpl %ecx, %ebp
jae 0x3a7dd
movl $0x8, %esi
movq %rbx, %rdi
callq 0x39095
testq %rax, %rax
je 0x3a7c9
movq %r15, (%rax)
leal -0x1(%r12), %ecx
movq %rax, %r15
jmp 0x3a7d6
movl 0x19214(%rbx), %ecx
movl %ecx, 0x14(%rsp)
movl %r12d, %ecx
testq %rax, %rax
jne 0x3a79f
jmp 0x3a830
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x3a808
movl 0x8(%r13), %esi
movl 0x8(%r14), %edx
movq 0x10(%r14), %rcx
movq 0x20(%r14), %r8
movq 0x10(%r13), %rdi
movq %rdi, (%rsp)
movq %rbx, %rdi
movq %r15, %r9
callq *%rax
jmp 0x3a818
movq 0x10(%r14), %rdi
movq 0x10(%r13), %rdx
movq %r15, %rsi
callq 0x3230
movq (%r14), %rax
movq %rax, 0x28(%r13)
movq %r14, %rdi
callq 0x3030
movw $0x1, %ax
movq %rax, 0x20(%rsp)
cmpl %r12d, %ebp
jae 0x3a78a
jmp 0x3a8b4
movq 0x18(%rsp), %r9
movl 0x14(%rsp), %r10d
movq (%r13), %r13
jmp 0x3a6dc
incq %r9
movl %r10d, %eax
movq %r9, 0x18(%rsp)
cmpq $0x7cf, %r9             # imm = 0x7CF
jne 0x3a6cc
movq $0x0, 0x18(%rsp)
movl %r10d, %eax
movl $0x0, 0x14(%rsp)
cmpw $0x0, 0x20(%rsp)
movl $0x0, %ecx
movq %rcx, 0x20(%rsp)
jne 0x3a6cc
jmp 0x3a8b4
leaq 0x16d38(%rbx), %rdi
addq $0x3d, %rsi
callq 0x3090
movl $0x19, 0x19214(%rbx)
movl $0x19, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq