// File: /workspace/github_c_makefile_star2_O1/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 0x46df5
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 0x39095
movq %rax, (%r13)
testq %rax, %rax
je 0x46d8b
testb $0x20, 0x4(%rbx)
movb (%r12), %r8b
jne 0x46d92
testb %r8b, %r8b
je 0x46db5
movq %rax, %rcx
movzbl %r8b, %edx
testb %dl, %dl
js 0x46ca3
incq %r12
jmp 0x46d76
movzbl 0x1(%r12), %esi
andl $0x3f, %esi
cmpb $-0x21, %r8b
ja 0x46cc3
addq $0x2, %r12
andl $0x1f, %edx
shll $0x6, %edx
orl %esi, %edx
jmp 0x46d76
movzbl 0x2(%r12), %edi
andl $0x3f, %edi
cmpb $-0x11, %r8b
ja 0x46cea
addq $0x3, %r12
shll $0xc, %edx
movzwl %dx, %edx
shll $0x6, %esi
orl %edx, %esi
orl %edi, %esi
movl %esi, %edx
jmp 0x46d76
movzbl 0x3(%r12), %r9d
andl $0x3f, %r9d
cmpb $-0x9, %r8b
ja 0x46d15
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 0x46d76
movzbl 0x4(%r12), %r10d
andl $0x3f, %r10d
cmpb $-0x5, %r8b
ja 0x46d48
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 0x46d76
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 0x46c93
jmp 0x46db8
movl $0x14, %eax
jmp 0x46de5
testb %r8b, %r8b
je 0x46db5
incq %r12
movq %rax, %rcx
movsbl %r8b, %edx
movl %edx, (%rcx)
addq $0x4, %rcx
movb (%r12), %r8b
incq %r12
testb %r8b, %r8b
jne 0x46d9d
jmp 0x46db8
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 %cl
orb %dl, %cl
movl $0x2d, %eax
cmpb $0x1, %cl
jne 0x46def
movl %eax, 0x19214(%rbx)
xorl %ecx, %ecx
jmp 0x46df1
movb $0x1, %cl
testb %cl, %cl
je 0x46dfb
movl 0x19214(%rbx), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq