// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movq $0x0, 0x6130(%rdi)
movq %r12, %r13
xorl %ebp, %ebp
movl $0x2, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x38fa7
movl $0x0, %r12d
testl %eax, %eax
jne 0x394df
movq 0x6120(%r14), %rsi
movq 0x6128(%r14), %rdi
movq 0x6130(%r14), %rcx
movq %rdi, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq %rdx
leaq (%rdx,%rdx,2), %rax
movq %rax, 0x6130(%r14)
testq %rsi, %rsi
je 0x394da
subq %rcx, %rdi
movb $0x1, %bpl
cmpq $0x3, %rdi
jb 0x394d5
movq %rdi, %rax
addq $-0x2, %rax
movq %rax, 0x20(%rsp)
je 0x394d5
movq %rdi, 0x18(%rsp)
addq %rcx, %rsi
movq %rsi, 0x8(%rsp)
xorl %edx, %edx
xorl %r15d, %r15d
xorl %ebx, %ebx
movq %r13, %r12
movq %rdx, (%rsp)
movq %r14, %rdi
callq 0x382e5
movl %eax, %r13d
cmpl $0x3d, %eax
setne %al
testl %r13d, %r13d
setns %cl
testb %cl, %al
jne 0x39387
cmpl $0x2, %r15d
movq 0x8(%rsp), %rdi
je 0x393e2
cmpl $0x3, %r15d
movq 0x18(%rsp), %r8
jne 0x39404
movq (%rsp), %rsi
movl %esi, %eax
shrl $0xa, %eax
leaq 0x1(%rdi), %rdx
movb %al, (%rdi)
movl $0x2, %ecx
movl $0x2, %eax
jmp 0x393f8
leal -0x2b(%r13), %eax
cmpl $0x4f, %eax
ja 0x393bf
movl %eax, %eax
leaq 0x18d77(%rip), %rcx     # 0x52110
movsbq (%rax,%rcx), %rax
cmpq $0x40, %rax
setl %bpl
movq (%rsp), %rdx
jge 0x3947e
shlq $0x6, %rdx
addq %rax, %rdx
incl %r15d
jmp 0x3948c
movb $0x1, %bpl
cmpl $0x21, %r13d
movq (%rsp), %rdx
jl 0x3948c
movl $0x4, 0x19214(%r14)
xorl %ebp, %ebp
jmp 0x39489
movl $0x1, %eax
movl $0x4, %ecx
movq %rdi, %rdx
movq 0x18(%rsp), %r8
movq (%rsp), %rsi
shrq %cl, %rsi
addq %rax, %rdi
movb %sil, (%rdx)
addq %rax, %rbx
movq 0x10(%rsp), %rcx
movq %rdi, 0x8(%rsp)
testq %rcx, %rcx
je 0x39421
movl %ebx, %eax
subl %r8d, %eax
addl 0x6128(%r14), %eax
movl %eax, (%rcx)
movq %rbx, %rbp
subq %r8, %rbp
movq 0x6128(%r14), %rsi
addq %rbp, %rsi
movq %r14, %rdi
callq 0x39095
movq %rax, %r12
testq %rax, %rax
je 0x3945a
movq 0x6120(%r14), %rsi
addq 0x6128(%r14), %rbp
movq %r12, %rdi
movq %rbp, %rdx
callq 0x3230
testl %r13d, %r13d
js 0x3946f
movq %r14, %rdi
callq 0x382e5
cmpl $-0x3, %eax
jb 0x3945f
movl %eax, %r13d
movl %r13d, 0x6100(%r14)
xorl %ebp, %ebp
movq (%rsp), %rdx
jmp 0x3948c
movl $0x4, 0x19214(%r14)
xorl %r12d, %r12d
testb %bpl, %bpl
je 0x394b6
cmpl $0x4, %r15d
jl 0x3932f
movl %edx, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
movb %al, (%rcx)
movb %dh, 0x1(%rcx)
movb %dl, 0x2(%rcx)
addq $0x3, %rcx
movq %rcx, 0x8(%rsp)
addq $0x3, %rbx
cmpq 0x20(%rsp), %rbx
setb %al
xorl %edx, %edx
movl $0x0, %r15d
testb %al, %bpl
jne 0x3932f
jmp 0x394df
movq %r13, %r12
jmp 0x394df
xorl %ebp, %ebp
xorl %r12d, %r12d
testb %bpl, %bpl
jne 0x39298
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq