// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/sasl.c
// Function: base64_encode
char *base64_encode(xmpp_ctx_t *ctx, 
		    const unsigned char * const buffer, const unsigned len)
{
    int clen;
    char *cbuf, *c;
    uint32_t word, hextet;
    int i;

    clen = base64_encoded_len(ctx, len);
    cbuf = xmpp_alloc(ctx, clen + 1);
    if (cbuf != NULL) {
	c = cbuf;
	/* loop over data, turning every 3 bytes into 4 characters */
	for (i = 0; i < len - 2; i += 3) {
	    word = buffer[i] << 16 | buffer[i+1] << 8 | buffer[i+2];
	    hextet = (word & 0x00FC0000) >> 18;
	    *c++ = _base64_charmap[hextet];
	    hextet = (word & 0x0003F000) >> 12;
	    *c++ = _base64_charmap[hextet];
	    hextet = (word & 0x00000FC0) >> 6;
	    *c++ = _base64_charmap[hextet];
	    hextet = (word & 0x000003F);
	    *c++ = _base64_charmap[hextet];
	}
	/* zero, one or two bytes left */
	switch (len - i) {
	    case 0:
		break;
	    case 1:
		hextet = (buffer[len-1] & 0xFC) >> 2;
		*c++ = _base64_charmap[hextet];
		hextet = (buffer[len-1] & 0x03) << 4;
		*c++ = _base64_charmap[hextet];
		*c++ = _base64_charmap[64]; /* pad */
		*c++ = _base64_charmap[64]; /* pad */
		break;
	    case 2:
		hextet = (buffer[len-2] & 0xFC) >> 2;
		*c++ = _base64_charmap[hextet];
		hextet = ((buffer[len-2] & 0x03) << 4) |
			 ((buffer[len-1] & 0xF0) >> 4);
		*c++ = _base64_charmap[hextet];
		hextet = (buffer[len-1] & 0x0F) << 2;
		*c++ = _base64_charmap[hextet];
		*c++ = _base64_charmap[64]; /* pad */
		break;
	}
	/* add a terminal null */
	*c = '\0';
    }

    return cbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xbc60
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x6680
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xadbb
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jae 0xabff
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x10, %eax
movq -0x10(%rbp), %rcx
movl -0x34(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x34(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
andl $0xfc0000, %eax         # imm = 0xFC0000
shrl $0x12, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa328(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x2c(%rbp), %eax
andl $0x3f000, %eax          # imm = 0x3F000
shrl $0xc, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa2fa(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x2c(%rbp), %eax
andl $0xfc0, %eax            # imm = 0xFC0
shrl $0x6, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa2cc(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x2c(%rbp), %eax
andl $0x3f, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa2a3(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movl -0x34(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x34(%rbp)
jmp 0xaaf2
movl -0x14(%rbp), %eax
movl -0x34(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x38(%rbp)
je 0xac29
jmp 0xac0e
movl -0x38(%rbp), %eax
subl $0x1, %eax
je 0xac2e
jmp 0xac18
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0xacd5
jmp 0xadb4
jmp 0xadb4
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0xfc, %eax
sarl $0x2, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa22b(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0x3, %eax
shll $0x4, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa1f2(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movb 0xa218(%rip), %cl       # 0x14ec0
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movb 0xa201(%rip), %cl       # 0x14ec0
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
jmp 0xadb4
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0xfc, %eax
sarl $0x2, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa184(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0x3, %eax
shll $0x4, %eax
movq -0x10(%rbp), %rcx
movl -0x14(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
andl $0xf0, %ecx
sarl $0x4, %ecx
orl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa130(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
shll $0x2, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
leaq 0xa0f7(%rip), %rax      # 0x14e80
movb (%rax,%rcx), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movb 0xa11d(%rip), %cl       # 0x14ec0
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)