#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int base64_get_next_byte();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *out;
  int input;
  if (argc != 2) {
    fputs("please specify output file name\n", stderr);
    return 1;
  }
  out = fopen(argv[1], "wb");
  if (out == NULL) {
    fputs("output file open error\n", stderr);
    return 1;
  }
  while ((input = base64_get_next_byte()) >= 0)
    putc(input, out);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    120e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d5 <main+0x85>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    120e <main+0xbe>
jmp    11da <main+0x8a>
mov    $0x0,%al
call   1040 <base64_get_next_byte@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     11fe <main+0xae>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <putc@plt>
jmp    11da <main+0x8a>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1197 <main+0x47>
mov    0x8(%rsi),%rdi
lea    0xebe(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b3 <main+0x63>
mov    %rax,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <base64_get_next_byte@plt>
test   %eax,%eax
js     11a9 <main+0x59>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
jmp    1180 <main+0x30>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe59(%rip),%rdi
jmp    11c3 <main+0x73>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11cd <main+0x7d>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"please specify output file name\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [24 x i8] c"output file open error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 1, i32* %3
br label %34
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %21)
store i32 1, i32* %3
br label %34
23: ; preds = %13
br label %24
24: ; preds = %27, %23
%25 = call i32 (...) @base64_get_next_byte()
store i32 %25, i32* %7
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %7
%29 = load i32*, i32** %6
%30 = call i32 @putc(i32 %28, i32* %29)
br label %24
31: ; preds = %24
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
store i32 0, i32* %3
br label %34
34: ; preds = %31, %20, %10
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [33 x i8] c"please specify output file name\0A\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [24 x i8] c"output file open error\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %25
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 (...) @base64_get_next_byte()
%14 = icmp sgt i32 %13, -1
br i1 %14, label %18, label %23
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %25
18: ; preds = %12, %18
%19 = phi i32 [ %21, %18 ], [ %13, %12 ]
%20 = tail call i32 @putc(i32 %19, i32* %10)
%21 = tail call i32 (...) @base64_get_next_byte()
%22 = icmp sgt i32 %21, -1
br i1 %22, label %18, label %23
23: ; preds = %18, %12
%24 = tail call i32 @fclose(i32* %10)
br label %25
25: ; preds = %23, %15, %4
%26 = phi i32 [ 1, %4 ], [ 1, %15 ], [ 0, %23 ]
ret i32 %26
}