// File: /workspace/github_c_makefile_star2_O0/uhlin[P]enhanced-duc/source/b64_decode.c
// Function: b64_decode_len
static int
b64_decode_len(unsigned char const *src)
{
	int tarindex, state, ch;
	uint8_t ofs;

	state = 0;
	tarindex = 0;

	while (1)
	{
		ch = *src++;
		ofs = b64rmap[ch];

		if (ofs >= b64rmap_special) {
			/* Ignore whitespaces */
			if (ofs == b64rmap_space)
				continue;
			/* End of base64 characters */
			if (ofs == b64rmap_end)
				break;
			/* A non-base64 character. */
			return (-1);
		}

		switch (state) {
		case 0:
			state = 1;
			break;
		case 1:
			tarindex++;
			state = 2;
			break;
		case 2:
			tarindex++;
			state = 3;
			break;
		case 3:
			tarindex++;
			state = 0;
			break;
		default:
			abort();
		}
	}

	/*
	 * We are done decoding Base-64 chars.  Let's see if we ended
	 * on a byte boundary, and/or with erroneous trailing characters.
	 */

	if (ch == Pad64) {		/* We got a pad char. */
		ch = *src++;		/* Skip it, get next. */
		switch (state) {
		case 0:		/* Invalid = in first position */
		case 1:		/* Invalid = in second position */
			return (-1);

		case 2:		/* Valid, means one byte of info */
			/* Skip any number of spaces. */
			for ((void)NULL; ch != '\0'; ch = *src++)
				if (b64rmap[ch] != b64rmap_space)
					break;
			/* Make sure there is another trailing = sign. */
			if (ch != Pad64)
				return (-1);
			ch = *src++;		/* Skip the = */
			/* Fall through to "single trailing =" case. */
			/* FALLTHROUGH */

		case 3:		/* Valid, means two bytes of info */
			/*
			 * We know this char is an =.  Is there anything but
			 * whitespace after it?
			 */
			for ((void)NULL; ch != '\0'; ch = *src++)
				if (b64rmap[ch] != b64rmap_space)
					return (-1);

		}
	} else {
		/*
		 * We ended by seeing the end of the string.  Make sure we
		 * have no partial bytes lying around.
		 */
		if (state != 0)
			return (-1);
	}

	return (tarindex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0xba56(%rip), %rax      # 0x10820
movb (%rax,%rcx), %al
movb %al, -0x1d(%rbp)
movzbl -0x1d(%rbp), %eax
cmpl $0xf0, %eax
jl 0x4e01
movzbl -0x1d(%rbp), %eax
cmpl $0xfe, %eax
jne 0x4de8
jmp 0x4daa
movzbl -0x1d(%rbp), %eax
cmpl $0xfd, %eax
jne 0x4df5
jmp 0x4e6b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f71
movl -0x18(%rbp), %eax
movq %rax, -0x28(%rbp)
subq $0x3, %rax
ja 0x4e61
movq -0x28(%rbp), %rax
leaq 0x6207(%rip), %rcx      # 0xb020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, -0x18(%rbp)
jmp 0x4e66
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x2, -0x18(%rbp)
jmp 0x4e66
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x3, -0x18(%rbp)
jmp 0x4e66
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
jmp 0x4e66
callq 0x4220
jmp 0x4daa
cmpl $0x3d, -0x1c(%rbp)
jne 0x4f5a
movq -0x10(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x2, %eax
jb 0x4ead
jmp 0x4e96
movl -0x2c(%rbp), %eax
subl $0x2, %eax
je 0x4eb9
jmp 0x4ea0
movl -0x2c(%rbp), %eax
subl $0x3, %eax
je 0x4f16
jmp 0x4f58
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f71
jmp 0x4ebb
cmpl $0x0, -0x1c(%rbp)
je 0x4ef2
movslq -0x1c(%rbp), %rcx
leaq 0xb954(%rip), %rax      # 0x10820
movzbl (%rax,%rcx), %eax
cmpl $0xfe, %eax
je 0x4ed9
jmp 0x4ef2
jmp 0x4edb
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x4ebb
cmpl $0x3d, -0x1c(%rbp)
je 0x4f01
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f71
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x4f18
cmpl $0x0, -0x1c(%rbp)
je 0x4f56
movslq -0x1c(%rbp), %rcx
leaq 0xb8f7(%rip), %rax      # 0x10820
movzbl (%rax,%rcx), %eax
cmpl $0xfe, %eax
je 0x4f3d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f71
jmp 0x4f3f
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x4f18
jmp 0x4f58
jmp 0x4f6b
cmpl $0x0, -0x18(%rbp)
je 0x4f69
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f71
jmp 0x4f6b
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)