// File: /workspace/github_c_makefile_star2_O0/orestesleal[P]base64/base64.c
// Function: decode_rd_file
void decode_rd_file(const char *src, const char *dst, unsigned char mode)
{
	struct finfo *fd;
	char *dec_buf;
	int ofd;
	size_t wr;
	size_t dec; /* number of decoded bytes */
	int flags = O_CREAT | O_RDWR;
    int perms = S_IRUSR | O_TRUNC | S_IWUSR;

	if ((fd = get_file(src)) == NULL) {
		fprintf(stderr, "get_file() failed loading %s in main memory\n", src);
		exit(EXIT_FAILURE);
	}

	dec_buf = alloc(fd->size); 
	switch (mode) {
		case BASE64:
			dec = b64_dec((unsigned char *)fd->addr, dec_buf, fd->size); 
			break;
		case BASE32:
			dec = b32_dec((unsigned char *)fd->addr, dec_buf, fd->size); 
			break;
		case BASE16:
			dec = b16_dec(fd->addr, dec_buf, fd->size); 
			break;
		default:
			fprintf(stderr,"error: mode %d not supported\n", mode);
			exit(EXIT_FAILURE);
	}

    if ((ofd = open(dst, flags, perms)) == -1) {
      	fprintf(stderr, "open(2) error, can't create or truncate %s\n", dst);
      	exit(EXIT_FAILURE);
	}
	/* write the contents of `dec_buf` into the file requested on dst */
	if ((wr = write(ofd, dec_buf, dec)) == -1) {
		fprintf(stderr, "write(2) error, can't write to %s\n", dst);
		exit(EXIT_FAILURE);
	}
	close(ofd);
	free(dec_buf);
	free(fd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl $0x42, -0x44(%rbp)
movl $0x380, -0x48(%rbp)     # imm = 0x380
movq -0x8(%rbp), %rdi
callq 0x2b00
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x2d4c
movq 0x22cb(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
leaq 0x2c9(%rip), %rsi       # 0x3004
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10c0
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x2ca0
movq %rax, -0x28(%rbp)
movzbl -0x11(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x1, %eax
je 0x2d7e
jmp 0x2d6a
movl -0x4c(%rbp), %eax
subl $0x2, %eax
je 0x2da0
jmp 0x2d74
movl -0x4c(%rbp), %eax
subl $0x3, %eax
je 0x2dc2
jmp 0x2de4
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0x1f00
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x2e0a
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0x24c0
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x2e0a
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
callq 0x27d0
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x2e0a
movq 0x220d(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movzbl -0x11(%rbp), %edx
leaq 0x45a(%rip), %rsi       # 0x3253
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10c0
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movb $0x0, %al
callq 0x10b0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0x2e49
movq 0x21ce(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1f9(%rip), %rsi       # 0x3031
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10c0
movl -0x2c(%rbp), %edi
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x1040
movq %rax, -0x38(%rbp)
cmpq $-0x1, %rax
jne 0x2e89
movq 0x218e(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1e5(%rip), %rsi       # 0x305d
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10c0
movl -0x2c(%rbp), %edi
callq 0x1060
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rdi
callq 0x1030
addq $0x50, %rsp
popq %rbp
retq