// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_getbase64
SOAP_FMAC1
unsigned char*
SOAP_FMAC2
soap_getbase64(struct soap *soap, int *n, int malloc_flag)
{ 
#ifdef WITH_DOM
  if ((soap->mode & SOAP_XML_DOM) && soap->dom)
  { soap->dom->data = soap_string_in(soap, 0, -1, -1);
    return (unsigned char*)soap_base642s(soap, soap->dom->data, NULL, 0, n);
  }
#endif
#ifdef WITH_FAST
  soap->labidx = 0;
  for (;;)
  { register size_t i, k;
    register char *s;
    if (soap_append_lab(soap, NULL, 2))
      return NULL;
    s = soap->labbuf + soap->labidx;
    k = soap->lablen - soap->labidx;
    soap->labidx = 3 * (soap->lablen / 3);
    if (!s)
      return NULL;
    if (k > 2)
    { for (i = 0; i < k - 2; i += 3)
      { register unsigned long m = 0;
        register int j = 0;
        do
        { register soap_wchar c = soap_get(soap);
          if (c == '=' || c < 0)
          { unsigned char *p;
            switch (j)
            { case 2:
                *s++ = (char)((m >> 4) & 0xFF);
                i++;
                break;
              case 3:
                *s++ = (char)((m >> 10) & 0xFF);
                *s++ = (char)((m >> 2) & 0xFF);
                i += 2;
            }
            if (n)
              *n = (int)(soap->lablen + i - k);
            p = (unsigned char*)soap_malloc(soap, soap->lablen + i - k);
            if (p)
              memcpy(p, soap->labbuf, soap->lablen + i - k);
            if (c >= 0)
            { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT)
                ;
            }
            soap_unget(soap, c);
            return p;
          }
          c -= '+';
          if (c >= 0 && c <= 79)
          { register int b = soap_base64i[c];
            if (b >= 64)
            { soap->error = SOAP_TYPE;
              return NULL;  
            }
            m = (m << 6) + b;
            j++;
          }
          else if (!soap_blank(c + '+'))
          { soap->error = SOAP_TYPE;
            return NULL;  
          }
        } while (j < 4);
        *s++ = (char)((m >> 16) & 0xFF);
        *s++ = (char)((m >> 8) & 0xFF);
        *s++ = (char)(m & 0xFF);
      }
    }
  }
#else
  if (soap_new_block(soap) == NULL)
    return NULL;
  for (;;)
  { register int i;
    register char *s = (char*)soap_push_block(soap, NULL, 3 * SOAP_BLKLEN); /* must be multiple of 3 */
    if (!s)
    { soap_end_block(soap, NULL);
      return NULL;
    }
    for (i = 0; i < SOAP_BLKLEN; i++)
    { register unsigned long m = 0;
      register int j = 0;
      do
      { register soap_wchar c = soap_get(soap);
        if (c == '=' || c < 0)
        { unsigned char *p;
          i *= 3;
          switch (j)
          { case 2:
              *s++ = (char)((m >> 4) & 0xFF);
              i++;
              break;
            case 3:
              *s++ = (char)((m >> 10) & 0xFF);
              *s++ = (char)((m >> 2) & 0xFF);
              i += 2;
          }
          if (n)
            *n = (int)soap_size_block(soap, NULL, i);
          p = (unsigned char*)soap_save_block(soap, NULL, 0);
          if (c >= 0)
          { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT)
              ;
          }
          soap_unget(soap, c);
          return p;
        }
        c -= '+';
        if (c >= 0 && c <= 79)
        { int b = soap_base64i[c];
          if (b >= 64)
          { soap->error = SOAP_TYPE;
            return NULL;  
          }
          m = (m << 6) + b;
          j++;
        }
        else if (!soap_blank(c))
        { soap->error = SOAP_TYPE;
          return NULL;  
        }
      } while (j < 4);
      *s++ = (char)((m >> 16) & 0xFF);
      *s++ = (char)((m >> 8) & 0xFF);
      *s++ = (char)(m & 0xFF);
    }
  }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
andq $0x0, 0x6130(%rdi)
xorl %ebx, %ebx
pushq $0x2
popq %r14
pushq $0x3
popq %r15
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x35e4f
testl %eax, %eax
jne 0x362c1
movq 0x6120(%r12), %rbp
movq 0x6128(%r12), %r13
movq 0x6130(%r12), %rcx
movq %r13, %rax
xorl %edx, %edx
divq %r15
movq %r13, %rax
subq %rdx, %rax
movq %rax, 0x6130(%r12)
testq %rbp, %rbp
je 0x362c1
subq %rcx, %r13
cmpq $0x3, %r13
jb 0x36126
addq %rcx, %rbp
leaq -0x2(%r13), %rcx
xorl %eax, %eax
movq %rcx, 0x10(%rsp)
cmpq %rcx, %rax
jae 0x36126
movq %rax, (%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x352a1
movl %eax, %r14d
cmpl $0x3d, %eax
je 0x3620f
testl %r14d, %r14d
js 0x3620f
leal -0x2b(%r14), %eax
cmpl $0x4f, %eax
ja 0x361d5
movl %eax, %eax
leaq 0x16f52(%rip), %rcx     # 0x4d110
movsbq (%rax,%rcx), %rax
cmpq $0x40, %rax
jge 0x3622e
shlq $0x6, %rbx
addq %rax, %rbx
incl %r15d
jmp 0x361db
cmpl $0x21, %r14d
jae 0x3622e
cmpl $0x4, %r15d
jl 0x36197
movl %ebx, %eax
shrl $0x10, %eax
movb %al, (%rbp)
movb %bh, 0x1(%rbp)
movb %bl, 0x2(%rbp)
addq $0x3, %rbp
movq (%rsp), %rax
addq $0x3, %rax
xorl %ebx, %ebx
pushq $0x2
popq %r14
pushq $0x3
popq %r15
movq 0x10(%rsp), %rcx
jmp 0x36189
cmpl $0x2, %r15d
je 0x36241
cmpl $0x3, %r15d
jne 0x3625b
movl %ebx, %eax
shrl $0xa, %eax
movb %al, (%rbp)
incq %rbp
pushq $0x2
popq %rcx
movq %rcx, %rax
jmp 0x36247
movl $0x4, 0x19214(%r12)
xorl %ebx, %ebx
jmp 0x362c1
pushq $0x1
popq %rax
pushq $0x4
popq %rcx
movq (%rsp), %r15
shrq %cl, %rbx
movb %bl, (%rbp)
addq %rax, %r15
movq 0x8(%rsp), %rax
jmp 0x36264
movq 0x8(%rsp), %rax
movq (%rsp), %r15
subq %r13, %r15
movq 0x6128(%r12), %rsi
addq %r15, %rsi
testq %rax, %rax
je 0x36279
movl %esi, (%rax)
movq %r12, %rdi
callq 0x35f17
movq %rax, %rbx
testq %rax, %rax
je 0x362a4
movq 0x6120(%r12), %rsi
addq 0x6128(%r12), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x3240
testl %r14d, %r14d
js 0x362b9
movq %r12, %rdi
callq 0x352a1
cmpl $-0x3, %eax
jb 0x362a9
movl %eax, %r14d
movl %r14d, 0x6100(%r12)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq