// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x6130(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x51780
cmpl $0x0, %eax
je 0x51c66
movq $0x0, -0x8(%rbp)
jmp 0x51fa1
movq -0x10(%rbp), %rax
movq 0x6120(%rax), %rax
movq -0x10(%rbp), %rcx
addq 0x6130(%rcx), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x6128(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0x6130(%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x6128(%rax), %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
imulq $0x3, %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x6130(%rax)
cmpq $0x0, -0x38(%rbp)
jne 0x51cd2
movq $0x0, -0x8(%rbp)
jmp 0x51fa1
cmpq $0x2, -0x30(%rbp)
jbe 0x51f9c
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jae 0x51f9a
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0x503c0
movl %eax, -0x48(%rbp)
cmpl $0x3d, -0x48(%rbp)
je 0x51d25
cmpl $0x0, -0x48(%rbp)
jge 0x51e85
movl -0x44(%rbp), %eax
movl %eax, -0x58(%rbp)
subl $0x2, %eax
je 0x51d3c
jmp 0x51d32
movl -0x58(%rbp), %eax
subl $0x3, %eax
je 0x51d6b
jmp 0x51db9
movq -0x40(%rbp), %rax
shrq $0x4, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x51db9
movq -0x40(%rbp), %rax
shrq $0xa, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x40(%rbp), %rax
shrq $0x2, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x51ddb
movq -0x10(%rbp), %rax
movq 0x6128(%rax), %rax
addq -0x28(%rbp), %rax
subq -0x30(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x6128(%rax), %rsi
addq -0x28(%rbp), %rsi
subq -0x30(%rbp), %rsi
callq 0x518f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x51e29
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x6120(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x6128(%rax), %rdx
addq -0x28(%rbp), %rdx
subq -0x30(%rbp), %rdx
callq 0x3240
cmpl $0x0, -0x48(%rbp)
jl 0x51e6b
jmp 0x51e31
movq -0x10(%rbp), %rdi
callq 0x503c0
movl %eax, %ecx
movl %ecx, -0x48(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x59(%rbp)
je 0x51e5e
xorl %eax, %eax
cmpl $-0x2, -0x48(%rbp)
movb %al, -0x59(%rbp)
je 0x51e5e
cmpl $-0x3, -0x48(%rbp)
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x51e67
jmp 0x51e69
jmp 0x51e31
jmp 0x51e6b
movl -0x48(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x6100(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x51fa1
movl -0x48(%rbp), %eax
subl $0x2b, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jl 0x51eeb
cmpl $0x4f, -0x48(%rbp)
jg 0x51eeb
movslq -0x48(%rbp), %rcx
leaq 0x2858b(%rip), %rax     # 0x7a430
movsbl (%rax,%rcx), %eax
movl %eax, -0x54(%rbp)
cmpl $0x40, -0x54(%rbp)
jl 0x51ecd
movq -0x10(%rbp), %rax
movl $0x4, 0x19214(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x51fa1
movq -0x40(%rbp), %rax
shlq $0x6, %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x51f1e
movl -0x48(%rbp), %eax
addl $0x2b, %eax
cmpl $0x0, %eax
jl 0x51f01
movl -0x48(%rbp), %eax
addl $0x2b, %eax
cmpl $0x20, %eax
jle 0x51f1c
movq -0x10(%rbp), %rax
movl $0x4, 0x19214(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x51fa1
jmp 0x51f1e
jmp 0x51f20
cmpl $0x4, -0x44(%rbp)
jl 0x51d09
movq -0x40(%rbp), %rax
shrq $0x10, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x40(%rbp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x40(%rbp), %rax
andq $0xff, %rax
movb %al, %cl
movq -0x38(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x28(%rbp)
jmp 0x51ce5
jmp 0x51f9c
jmp 0x51c42
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)