// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
movq 0xa8(%rbx,%rax,8), %rsi
testq %rsi, %rsi
je 0x3a807
movq 0x30(%rsi), %rcx
testq %rcx, %rcx
je 0x3a7f8
movq 0x18(%rsi), %rdx
movq $0x0, 0x18(%rsi)
testq %rdx, %rdx
je 0x3a802
movq (%rdx), %rdi
movq %rcx, (%rdx)
movq %rdi, %rdx
testq %rdi, %rdi
jne 0x3a7e8
jmp 0x3a802
cmpb $0x23, 0x3c(%rsi)
je 0x3a99a
movq (%rsi), %rsi
jmp 0x3a7c9
incq %rax
cmpq $0x7cf, %rax            # imm = 0x7CF
jne 0x3a7c1
xorl %r14d, %r14d
xorl %eax, %eax
movq 0xa8(%rbx,%r14,8), %r12
testq %r12, %r12
je 0x3a977
movq 0x30(%r12), %rcx
testq %rcx, %rcx
je 0x3a96e
movq 0x10(%r12), %rdx
addq %rcx, %rdx
xorl %esi, %esi
movq 0xa8(%rbx,%rsi,8), %rdi
testq %rdi, %rdi
je 0x3a88c
leaq 0x20(%rdi), %r8
movq (%r8), %r8
testq %r8, %r8
je 0x3a868
cmpq %rcx, %r8
jb 0x3a851
cmpq %rdx, %r8
jae 0x3a851
jmp 0x3a96e
leaq 0x28(%rdi), %r8
movq (%r8), %r8
testq %r8, %r8
je 0x3a887
movq 0x10(%r8), %r9
cmpq %rcx, %r9
jb 0x3a86c
cmpq %rdx, %r9
jae 0x3a86c
jmp 0x3a96e
movq (%rdi), %rdi
jmp 0x3a848
incq %rsi
cmpq $0x7cf, %rsi            # imm = 0x7CF
jne 0x3a840
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0x3a8c9
movq $0x0, 0x20(%r12)
movq (%rdi), %r15
movq 0x10(%r12), %rdx
movq 0x30(%r12), %rsi
callq 0x3240
movq %r15, %rdi
testq %r15, %r15
jne 0x3a8ab
movw $0x1, %ax
movq 0x28(%r12), %r15
testq %r15, %r15
je 0x3a96e
movl 0x18(%r15), %ebp
movq 0x30(%r12), %r13
cmpl %ebp, 0x38(%r12)
jae 0x3a90e
movl $0x8, %esi
movq %rbx, %rdi
callq 0x39272
testq %rax, %rax
je 0x3a9cc
movq %r13, (%rax)
decl %ebp
movq %rax, %r13
cmpl %ebp, 0x38(%r12)
jb 0x3a8e7
jmp 0x3a911
movq %r13, %rax
movq 0x28(%r15), %r10
testq %r10, %r10
je 0x3a93f
movl 0x8(%r12), %esi
movl 0x8(%r15), %edx
movq 0x10(%r15), %rcx
movq 0x20(%r15), %r8
movq 0x10(%r12), %rdi
movq %rdi, (%rsp)
movq %rbx, %rdi
movq %rax, %r9
callq *%r10
jmp 0x3a950
movq 0x10(%r15), %rdi
movq 0x10(%r12), %rdx
movq %rax, %rsi
callq 0x3240
movq (%r15), %rax
movq %rax, 0x28(%r12)
movq %r15, %rdi
callq 0x3030
movq 0x28(%r12), %r15
movw $0x1, %ax
jmp 0x3a8ce
movq (%r12), %r12
jmp 0x3a81f
incq %r14
cmpq $0x7cf, %r14            # imm = 0x7CF
jne 0x3a817
xorl %r14d, %r14d
testw %ax, %ax
movl $0x0, %eax
jne 0x3a817
jmp 0x3a9ba
leaq 0x16d38(%rbx), %rdi
addq $0x3d, %rsi
callq 0x3090
movl $0x19, 0x19214(%rbx)
movl $0x19, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x19214(%rbx), %r14d
jmp 0x3a9ba