// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_wchar2s
SOAP_FMAC1
const char*
SOAP_FMAC2
soap_wchar2s(struct soap *soap, const wchar_t *s)
{ register soap_wchar c;
  register char *r, *t;
  const wchar_t *q = s;
  size_t n = 0;
  while ((c = *q++))
  { if (c > 0 && c < 0x80)
      n++;
    else
      n += 6;
  }
  r = t = (char*)soap_malloc(soap, n + 1);
  if (r)
  { /* Convert wchar to UTF8 */
    while ((c = *s++))
    { if (c > 0 && c < 0x80)
        *t++ = (char)c;
      else
      { if (c < 0x0800)
          *t++ = (char)(0xC0 | ((c >> 6) & 0x1F));
        else
        { if (c < 0x010000)
            *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));
          else
          { if (c < 0x200000)
              *t++ = (char)(0xF0 | ((c >> 18) & 0x07));
            else
            { if (c < 0x04000000)
                *t++ = (char)(0xF8 | ((c >> 24) & 0x03));
              else
              { *t++ = (char)(0xFC | ((c >> 30) & 0x01));
                *t++ = (char)(0x80 | ((c >> 24) & 0x3F));
              }
              *t++ = (char)(0x80 | ((c >> 18) & 0x3F));
            }     
            *t++ = (char)(0x80 | ((c >> 12) & 0x3F));
          }
          *t++ = (char)(0x80 | ((c >> 6) & 0x3F));
        }
        *t++ = (char)(0x80 | (c & 0x3F));
      }
    }
    *t = '\0';
  }
  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x30(%rbp)
movl (%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x673c4
cmpl $0x0, -0x14(%rbp)
jle 0x673b6
cmpl $0x80, -0x14(%rbp)
jge 0x673b6
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x673c2
movq -0x38(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x38(%rbp)
jmp 0x67380
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x1, %rsi
callq 0x518f0
movq %rax, -0x28(%rbp)
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x675b9
jmp 0x673ea
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x10(%rbp)
movl (%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x675b2
cmpl $0x0, -0x14(%rbp)
jle 0x67431
cmpl $0x80, -0x14(%rbp)
jge 0x67431
movl -0x14(%rbp), %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x675ad
cmpl $0x800, -0x14(%rbp)     # imm = 0x800
jge 0x67460
movl -0x14(%rbp), %eax
sarl $0x6, %eax
andl $0x1f, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x6758f
cmpl $0x10000, -0x14(%rbp)   # imm = 0x10000
jge 0x6748f
movl -0x14(%rbp), %eax
sarl $0xc, %eax
andl $0xf, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x6756e
cmpl $0x200000, -0x14(%rbp)  # imm = 0x200000
jge 0x674be
movl -0x14(%rbp), %eax
sarl $0x12, %eax
andl $0x7, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x6754d
cmpl $0x4000000, -0x14(%rbp) # imm = 0x4000000
jge 0x674ea
movl -0x14(%rbp), %eax
sarl $0x18, %eax
andl $0x3, %eax
orl $0xf8, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x6752c
movl -0x14(%rbp), %eax
sarl $0x1e, %eax
andl $0x1, %eax
orl $0xfc, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0x18, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0x12, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0xc, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
sarl $0x6, %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
andl $0x3f, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0x673ea
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)