// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdi, %r14
movq $0x0, 0x6130(%rdi)
xorl %r15d, %r15d
movl $0x2, %edx
xorl %esi, %esi
callq 0x39195
testl %eax, %eax
jne 0x39651
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
xorl %r15d, %r15d
movq 0x6120(%r14), %rsi
movq 0x6128(%r14), %r13
movq 0x6130(%r14), %rcx
movq %r13, %rax
mulq %rbp
shrq %rdx
leaq (%rdx,%rdx,2), %rax
movq %rax, 0x6130(%r14)
testq %rsi, %rsi
je 0x39651
subq %rcx, %r13
cmpq $0x3, %r13
jb 0x39582
leaq -0x2(%r13), %rax
movq %rax, 0x10(%rsp)
addq %rcx, %rsi
xorl %r12d, %r12d
movq %rbx, (%rsp)
movq %rsi, 0x8(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x38565
movl %eax, %ebp
cmpl $0x3d, %eax
je 0x3959e
testl %ebp, %ebp
js 0x3959e
leal -0x2b(%rbp), %eax
cmpl $0x4f, %eax
ja 0x3953a
movl %eax, %eax
leaq 0x18bf1(%rip), %rcx     # 0x52110
movsbq (%rax,%rcx), %rax
cmpq $0x40, %rax
jge 0x395c9
shlq $0x6, %rbx
addq %rax, %rbx
incl %r15d
jmp 0x39543
cmpl $0x21, %ebp
jae 0x395c9
cmpl $0x4, %r15d
jl 0x394f3
movl %ebx, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rsi
movb %al, (%rsi)
movb %bh, 0x1(%rsi)
movb %bl, 0x2(%rsi)
addq $0x3, %rsi
addq $0x3, %r12
cmpq 0x10(%rsp), %r12
movq (%rsp), %rbx
movl $0x0, %r15d
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
jb 0x394e9
movl $0x2, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x39195
testl %eax, %eax
je 0x39497
jmp 0x39651
cmpl $0x2, %r15d
je 0x395d9
cmpl $0x3, %r15d
jne 0x395f6
movl %ebx, %eax
shrl $0xa, %eax
movq 0x8(%rsp), %rsi
movb %al, (%rsi)
incq %rsi
movl $0x2, %ecx
movl $0x2, %eax
movq (%rsp), %rdx
jmp 0x395ec
movl $0x4, 0x19214(%r14)
xorl %r15d, %r15d
jmp 0x39651
movl $0x1, %eax
movl $0x4, %ecx
movq (%rsp), %rdx
movq 0x8(%rsp), %rsi
shrq %cl, %rbx
movb %bl, (%rsi)
addq %rax, %r12
jmp 0x395fa
movq (%rsp), %rdx
subq %r13, %r12
movq 0x6128(%r14), %rsi
addq %r12, %rsi
testq %rdx, %rdx
je 0x3960e
movl %esi, (%rdx)
movq %r14, %rdi
callq 0x39272
movq %rax, %r15
testq %rax, %rax
je 0x39637
movq 0x6120(%r14), %rsi
addq 0x6128(%r14), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x3240
testl %ebp, %ebp
js 0x3964a
movq %r14, %rdi
callq 0x38565
cmpl $-0x3, %eax
jb 0x3963b
movl %eax, %ebp
movl %ebp, 0x6100(%r14)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq