// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_s2wchar
SOAP_FMAC2
soap_s2wchar(struct soap *soap, const char *s, wchar_t **t, long minlen, long maxlen)
{ if (s)
  { long l;
    wchar_t *r;
    *t = r = (wchar_t*)soap_malloc(soap, sizeof(wchar_t) * (strlen(s) + 1));
    if (!r)
      return soap->error = SOAP_EOM;
    if (soap->mode & SOAP_ENC_LATIN)
    { while (*s)
        *r++ = (wchar_t)*s++;
    }
    else
    { /* Convert UTF8 to wchar */
      while (*s)
      { register soap_wchar c, c1, c2, c3, c4;
        c = (unsigned char)*s++;
        if (c < 0x80)
          *r++ = (wchar_t)c;
        else
        { c1 = (soap_wchar)*s++ & 0x3F;
          if (c < 0xE0)
            *r++ = (wchar_t)(((soap_wchar)(c & 0x1F) << 6) | c1);
          else
          { c2 = (soap_wchar)*s++ & 0x3F;
            if (c < 0xF0)
              *r++ = (wchar_t)(((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2);
            else
            { c3 = (soap_wchar)*s++ & 0x3F;
              if (c < 0xF8)
                *r++ = (wchar_t)(((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3);
              else
              { c4 = (soap_wchar)*s++ & 0x3F;
                if (c < 0xFC)
                  *r++ = (wchar_t)(((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4);
                else
                  *r++ = (wchar_t)(((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(*s++ & 0x3F));
              }
            }
          }
        }
      }
    }
    *r = L'\0';
    l = (long)(r - *t);
    if ((maxlen >= 0 && l > maxlen) || l < minlen)
      return soap->error = SOAP_LENGTH;
  }
  return soap->error;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
testq %rsi, %rsi
je 0x467c5
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r12
movq %rsi, %rdi
callq 0x3110
leaq 0x4(,%rax,4), %rsi
movq %rbx, %rdi
callq 0x39272
movq %rax, (%r13)
testq %rax, %rax
je 0x46756
testb $0x20, 0x4(%rbx)
movb (%r12), %r8b
jne 0x46767
testb %r8b, %r8b
je 0x4678a
movq %rax, %rcx
movzbl %r8b, %edx
testb %dl, %dl
js 0x4666e
incq %r12
jmp 0x46741
movzbl 0x1(%r12), %esi
andl $0x3f, %esi
cmpb $-0x21, %r8b
ja 0x4668e
addq $0x2, %r12
andl $0x1f, %edx
shll $0x6, %edx
orl %esi, %edx
jmp 0x46741
movzbl 0x2(%r12), %edi
andl $0x3f, %edi
cmpb $-0x11, %r8b
ja 0x466b5
addq $0x3, %r12
shll $0xc, %edx
movzwl %dx, %edx
shll $0x6, %esi
orl %edx, %esi
orl %edi, %esi
movl %esi, %edx
jmp 0x46741
movzbl 0x3(%r12), %r9d
andl $0x3f, %r9d
cmpb $-0x9, %r8b
ja 0x466e0
addq $0x4, %r12
andl $0x7, %edx
shll $0x12, %edx
shll $0xc, %esi
orl %edx, %esi
shll $0x6, %edi
orl %esi, %edi
orl %r9d, %edi
movl %edi, %edx
jmp 0x46741
movzbl 0x4(%r12), %r10d
andl $0x3f, %r10d
cmpb $-0x5, %r8b
ja 0x46713
addq $0x5, %r12
andl $0x3, %edx
shll $0x18, %edx
shll $0x12, %esi
orl %edx, %esi
shll $0xc, %edi
orl %esi, %edi
shll $0x6, %r9d
orl %edi, %r9d
orl %r10d, %r9d
movl %r9d, %edx
jmp 0x46741
andl $0x1, %edx
shll $0x1e, %edx
shll $0x18, %esi
orl %edx, %esi
shll $0x12, %edi
orl %esi, %edi
shll $0xc, %r9d
orl %edi, %r9d
shll $0x6, %r10d
orl %r9d, %r10d
movzbl 0x5(%r12), %edx
addq $0x6, %r12
andl $0x3f, %edx
orl %r10d, %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movb (%r12), %r8b
testb %r8b, %r8b
jne 0x4665e
jmp 0x4678d
movl $0x14, 0x19214(%rbx)
movl $0x14, %eax
jmp 0x467cb
testb %r8b, %r8b
je 0x4678a
incq %r12
movq %rax, %rcx
movsbl %r8b, %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movb (%r12), %r8b
incq %r12
testb %r8b, %r8b
jne 0x46772
jmp 0x4678d
movq %rax, %rcx
movl $0x0, (%rcx)
subq %rax, %rcx
sarq $0x2, %rcx
testq %r15, %r15
setns %al
cmpq %r15, %rcx
setg %dl
andb %al, %dl
cmpq %r14, %rcx
setl %al
orb %dl, %al
cmpb $0x1, %al
jne 0x467c5
movl $0x2d, 0x19214(%rbx)
movl $0x2d, %eax
jmp 0x467cb
movl 0x19214(%rbx), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq