// File: /workspace/github_c_makefile_star2_O1/NedFreed[P]msglint/msglint.c
// Function: decode64
int decode64(base64ctx *bctx, const char *in, int inlen,
	     char *out, int outmax)
{
    int infill, outfill, j;
    unsigned in0, in1, in2, in3;
    unsigned char *iptr, *end;
    unsigned char inbuf[4], outbuf[3];

    /* set up results */
    bctx->outlen = 0;
    bctx->badc = 0;
    
    /* check for invalid params, insufficient data */
    if (bctx->tmplen > 3) return (-3);
    if (inlen == 0 && (bctx->tmplen == 2 || bctx->tmplen == 3)) {
	while (bctx->tmplen < 4) {
	    bctx->tmpbuf[bctx->tmplen] = '=';
	    ++bctx->tmplen;
	}
    } else if (inlen + bctx->tmplen < 4) {
	memcpy(bctx->tmpbuf + bctx->tmplen, in, inlen);
	iptr = (unsigned char *) bctx->tmpbuf;
	end = iptr + bctx->tmplen + inlen;
	while (iptr < end) {
	    if (*iptr != '=' && CHAR64(*iptr) == XX) {
		bctx->badc = *iptr;
		return (-1);
	    }
	    ++iptr;
	}
	bctx->tmplen += inlen;
	return (1);
    }

    /* fill up initial input data buffer */
    infill = 4;
    if (bctx->tmplen > 0) {
	infill -= bctx->tmplen;
	memcpy(inbuf, bctx->tmpbuf, bctx->tmplen);
	bctx->tmplen = 0;
    }
    memcpy(inbuf + (4 - infill), in, infill);
    in += infill;
    inlen -= infill;

    for (;;) {
	/* check for end */
	if (bctx->sawend) return (-4);

	/* do decode/validation */
	if ((in0 = CHAR64(inbuf[0])) == XX) {
	    bctx->badc = inbuf[0];
	    return (-1);
	}
	if ((in1 = CHAR64(inbuf[1])) == XX) {
	    bctx->badc = inbuf[1];
	    bctx->tmpbuf[0] = inbuf[0];
	    bctx->tmplen = 1;
	    return (-1);
	}
	outbuf[0] = (in0 << 2) + (in1 >> 4);
	outfill = 3;
	if (inbuf[2] == '=' && inbuf[3] == '=') {
	    outbuf[1] = outbuf[2] = 0;
	    outfill = 1;
	    bctx->sawend = 1;
	} else if ((in2 = CHAR64(inbuf[2])) == XX) {
	    bctx->badc = inbuf[2];
	    bctx->tmpbuf[0] = inbuf[0];
	    bctx->tmpbuf[1] = inbuf[1];
	    bctx->tmplen = 2;
	    return (-1);
	} else {
	    outbuf[1] = (in1 << 4) | (in2 >> 2);
	    if (inbuf[3] == '=') {
		outbuf[2] = 0;
		outfill = 2;
		bctx->sawend = 1;
	    } else if ((in3 = CHAR64(inbuf[3])) == XX) {
		bctx->badc = inbuf[3];
		bctx->tmpbuf[0] = inbuf[0];
		bctx->tmpbuf[1] = inbuf[1];
		bctx->tmpbuf[2] = inbuf[2];
		bctx->tmplen = 3;
		return (-1);
	    } else {
		outbuf[2] = (in2 << 6) | in3;
	    }
	}

	/* process output buffer */
	if (out != NULL) {
	    if (outmax < outfill) return (-2);
	    memcpy(out, outbuf, outfill);
	    out += outfill;
	    outmax -= outfill;
	}
	bctx->outlen += outfill;

	/* fill input buffer */
	if (inlen < 4) break;
	memcpy(inbuf, in, 4);
	in += 4;
	inlen -= 4;
    }

    /* save remaining input buffer */
    if (inlen > 0) {
	memcpy(bctx->tmpbuf, in, inlen);
	bctx->tmplen = inlen;

	return (1);
    }

    return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movl $0x0, 0x4(%rdi)
movb $0x0, 0x10(%rdi)
movslq 0x8(%rdi), %rsi
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
cmpq $0x3, %rsi
jg 0x26f2
movl %edx, %r14d
movq %rdi, %rbx
testl %edx, %edx
jne 0x2472
movl %esi, %edx
andl $-0x2, %edx
cmpl $0x2, %edx
jne 0x2472
movl 0x8(%rbx), %eax
cmpl $0x3, %eax
jg 0x24e4
cltq
movb $0x3d, 0xc(%rbx,%rax)
movl 0x8(%rbx), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x8(%rbx)
cmpl $0x3, %edx
jl 0x245b
jmp 0x24e4
leal (%rsi,%r14), %edx
cmpl $0x3, %edx
jg 0x24e4
leaq (%rbx,%rsi), %rdi
addq $0xc, %rdi
movslq %r14d, %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x2120
movslq 0x8(%rbx), %rax
leaq (%rax,%r12), %rcx
addq $0xc, %rcx
cmpq $0xd, %rcx
jl 0x24d4
leaq 0xc(%rbx), %rcx
addq %rax, %r12
leaq (%rbx,%r12), %rdx
addq $0xc, %rdx
leaq 0x9857(%rip), %rsi      # 0xbd10
movzbl (%rcx), %edi
cmpq $0x3d, %rdi
je 0x24cc
cmpb $0x7f, (%rdi,%rsi)
je 0x26b6
incq %rcx
cmpq %rdx, %rcx
jb 0x24b9
addl %r14d, %eax
movl %eax, 0x8(%rbx)
movl $0x1, %eax
jmp 0x26f2
movl %r8d, 0x14(%rsp)
movq %rcx, 0x8(%rsp)
movslq 0x8(%rbx), %rdx
movl $0x4, %r12d
movl $0x4, %r13d
testq %rdx, %rdx
jle 0x251b
subl %edx, %r13d
leaq 0xc(%rbx), %rsi
leaq 0x4(%rsp), %rdi
callq 0x2120
movl $0x0, 0x8(%rbx)
subl %r13d, %r12d
leaq (%rsp,%r12), %rdi
addq $0x4, %rdi
movslq %r13d, %r13
movq %r15, %rsi
movq %r13, %rdx
callq 0x2120
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
cmpl $0x0, (%rbx)
jne 0x26f2
subl %r13d, %r14d
addq %r13, %r15
leaq 0x97c1(%rip), %r11      # 0xbd10
movq 0x8(%rsp), %rbp
movzbl 0x4(%rsp), %eax
movsbl (%rax,%r11), %edx
cmpl $0x7f, %edx
je 0x2685
movzbl 0x5(%rsp), %ecx
movsbl (%rcx,%r11), %r10d
cmpl $0x7f, %r10d
je 0x268a
movl %r10d, %esi
shrl $0x4, %esi
leal (%rsi,%rdx,4), %edx
movb %dl, 0x1(%rsp)
movb 0x6(%rsp), %dl
movb 0x7(%rsp), %sil
movl %edx, %r8d
xorb $0x3d, %r8b
movl %esi, %r9d
xorb $0x3d, %r9b
orb %r8b, %r9b
jne 0x25b9
movw $0x0, 0x2(%rsp)
movl $0x1, (%rbx)
movl $0x1, %r12d
jmp 0x261c
movzbl %dl, %r8d
movsbl (%r8,%r11), %r8d
cmpl $0x7f, %r8d
je 0x26c3
shll $0x4, %r10d
movl %r8d, %r9d
shrl $0x2, %r9d
orl %r10d, %r9d
movb %r9b, 0x2(%rsp)
cmpb $0x3d, %sil
jne 0x25f8
movb $0x0, 0x3(%rsp)
movl $0x1, (%rbx)
movl $0x2, %r12d
jmp 0x261c
movzbl %sil, %r9d
movb (%r9,%r11), %r9b
cmpb $0x7f, %r9b
je 0x26d9
shlb $0x6, %r8b
orb %r8b, %r9b
movb %r9b, 0x3(%rsp)
movl $0x3, %r12d
testq %rbp, %rbp
je 0x265a
subl %r12d, 0x14(%rsp)
jl 0x26bc
movl %r12d, %r13d
movq %rbp, %rdi
leaq 0x1(%rsp), %rsi
movq %r13, %rdx
movq %r15, 0x8(%rsp)
movq %r14, %r15
movq %r11, %r14
callq 0x2120
movq %r14, %r11
movq %r15, %r14
movq 0x8(%rsp), %r15
addq %r13, %rbp
jmp 0x265c
xorl %ebp, %ebp
addl %r12d, 0x4(%rbx)
cmpl $0x4, %r14d
jl 0x2699
movl (%r15), %eax
movl %eax, 0x4(%rsp)
addq $0x4, %r15
addq $-0x4, %r14
cmpl $0x0, (%rbx)
je 0x2554
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x26f2
movb %al, 0x10(%rbx)
jmp 0x26ed
movb %cl, 0x10(%rbx)
movb %al, 0xc(%rbx)
movl $0x1, 0x8(%rbx)
jmp 0x26ed
testl %r14d, %r14d
jle 0x26d5
leaq 0xc(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2120
movl %r14d, 0x8(%rbx)
jmp 0x24da
movb %dil, 0x10(%rbx)
jmp 0x26ed
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x26f2
movb %dl, 0x10(%rbx)
movb %al, 0xc(%rbx)
movb %cl, 0xd(%rbx)
movl $0x2, 0x8(%rbx)
jmp 0x26ed
xorl %eax, %eax
jmp 0x26f2
movb %sil, 0x10(%rbx)
movb %al, 0xc(%rbx)
movb %cl, 0xd(%rbx)
movb %dl, 0xe(%rbx)
movl $0x3, 0x8(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq