// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
movl $0x0, 0x4(%rdi)
movb $0x0, 0x10(%rdi)
movslq 0x8(%rdi), %rdi
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
cmpq $0x3, %rdi
jg 0x270f
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %edx
andl $-0x2, %edx
xorl $0x2, %edx
orl %r14d, %edx
jne 0x2483
movl %r8d, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
movslq %edi, %rax
movb $0x3d, 0xc(%rbx,%rax)
movl 0x8(%rbx), %ecx
leal 0x1(%rcx), %edi
movl %edi, 0x8(%rbx)
cmpl $0x3, %ecx
jl 0x2468
jmp 0x2506
leal (%rdi,%r14), %edx
cmpl $0x3, %edx
jg 0x24f4
addq %rbx, %rdi
addq $0xc, %rdi
movslq %r14d, %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x2130
movslq 0x8(%rbx), %rax
leaq (%rax,%r12), %rcx
addq $0xc, %rcx
cmpq $0xd, %rcx
jl 0x24e4
leaq 0xc(%rbx), %rcx
addq %rax, %r12
leaq (%rbx,%r12), %rdx
addq $0xc, %rdx
leaq 0x97d7(%rip), %rsi      # 0xbca0
movzbl (%rcx), %edi
cmpq $0x3d, %rdi
je 0x24dc
cmpb $0x7f, (%rdi,%rsi)
je 0x26d3
incq %rcx
cmpq %rdx, %rcx
jb 0x24c9
addl %r14d, %eax
movl %eax, 0x8(%rbx)
movl $0x1, %eax
jmp 0x270f
movl %r8d, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
testl %edi, %edi
jle 0x2697
movl $0x4, %r12d
subl %edi, %r12d
leaq 0xc(%rbx), %rsi
movl %edi, %edx
leaq 0x8(%rsp), %rdi
callq 0x2130
movl $0x0, 0x8(%rbx)
movl $0x4, %eax
subl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x8, %rdi
movslq %r12d, %r13
movq %r15, %rsi
movq %r13, %rdx
callq 0x2130
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
cmpl $0x0, (%rbx)
jne 0x270f
subl %r13d, %r14d
addq %r13, %r15
movb 0x8(%rsp), %al
leaq 0x973d(%rip), %r11      # 0xbca0
movq 0x10(%rsp), %rbp
movzbl %al, %ecx
movsbl (%rcx,%r11), %edx
cmpl $0x7f, %edx
je 0x26a2
movzbl 0x9(%rsp), %ecx
movsbl (%rcx,%r11), %r10d
cmpl $0x7f, %r10d
je 0x26a7
movl %r10d, %esi
shrl $0x4, %esi
leal (%rsi,%rdx,4), %edx
movb %dl, 0x5(%rsp)
movb 0xa(%rsp), %dl
movb 0xb(%rsp), %sil
movl %edx, %r8d
xorb $0x3d, %r8b
movl %esi, %r9d
xorb $0x3d, %r9b
orb %r8b, %r9b
jne 0x25cb
movw $0x0, 0x6(%rsp)
movl $0x1, (%rbx)
movl $0x1, %r12d
jmp 0x262e
movzbl %dl, %r8d
movsbl (%r8,%r11), %r8d
cmpl $0x7f, %r8d
je 0x26e0
shll $0x4, %r10d
movl %r8d, %r9d
shrl $0x2, %r9d
orl %r10d, %r9d
movb %r9b, 0x6(%rsp)
cmpb $0x3d, %sil
jne 0x260a
movb $0x0, 0x7(%rsp)
movl $0x1, (%rbx)
movl $0x2, %r12d
jmp 0x262e
movzbl %sil, %r9d
movb (%r9,%r11), %r9b
cmpb $0x7f, %r9b
je 0x26f6
shlb $0x6, %r8b
orb %r8b, %r9b
movb %r9b, 0x7(%rsp)
movl $0x3, %r12d
testq %rbp, %rbp
je 0x266c
subl %r12d, 0xc(%rsp)
jl 0x26d9
movl %r12d, %r13d
movq %rbp, %rdi
leaq 0x5(%rsp), %rsi
movq %r13, %rdx
movq %r15, 0x10(%rsp)
movq %r14, %r15
movq %r11, %r14
callq 0x2130
movq %r14, %r11
movq %r15, %r14
movq 0x10(%rsp), %r15
addq %r13, %rbp
jmp 0x266e
xorl %ebp, %ebp
addl %r12d, 0x4(%rbx)
cmpl $0x4, %r14d
jl 0x26b6
movl (%r15), %eax
movl %eax, 0x8(%rsp)
addq $0x4, %r15
addq $-0x4, %r14
cmpl $0x0, (%rbx)
je 0x2568
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x270f
movl $0x4, %r12d
jmp 0x2526
movb %al, 0x10(%rbx)
jmp 0x270a
movb %cl, 0x10(%rbx)
movb %al, 0xc(%rbx)
movl $0x1, 0x8(%rbx)
jmp 0x270a
testl %r14d, %r14d
jle 0x26f2
leaq 0xc(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2130
movl %r14d, 0x8(%rbx)
jmp 0x24ea
movb %dil, 0x10(%rbx)
jmp 0x270a
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x270f
movb %dl, 0x10(%rbx)
movb %al, 0xc(%rbx)
movb %cl, 0xd(%rbx)
movl $0x2, 0x8(%rbx)
jmp 0x270a
xorl %eax, %eax
jmp 0x270f
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