#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 */

/* Variables and functions */
int b64dec(int /*<<< orphan*/);
int b64enc(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fileopen(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int b64main(char *filepath, char *mode) {
  if (strcmp(mode, "enc") == 0) {
    if (b64enc(fileopen(filepath)) == 1) {
      return 1;
    } else {
      fprintf(stderr, "ERR: b64main encode error\n");
      exit(-1);
    }
  } else if (strcmp(mode, "dec") == 0) {
    if (b64dec(fileopen(filepath)) == 1) {
      return 1;
    } else {
      fprintf(stderr, "ERR: b64main decode error\n");
      exit(-1);
    }
  } else {
    fprintf(stderr, "ERR: b64main invalid mode\n");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<b64main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ce <b64main+0x6e>
mov    -0x10(%rbp),%rdi
call   1060 <fileopen@plt>
mov    %eax,%edi
call   1070 <b64enc@plt>
cmp    $0x1,%eax
jne    11af <b64main+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    124b <b64main+0xeb>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122c <b64main+0xcc>
mov    -0x10(%rbp),%rdi
call   1060 <fileopen@plt>
mov    %eax,%edi
call   1030 <b64dec@plt>
cmp    $0x1,%eax
jne    120d <b64main+0xad>
movl   $0x1,-0x4(%rbp)
jmp    124b <b64main+0xeb>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b64main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b8 <b64main+0x58>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11d9 <b64main+0x79>
mov    %r14,%rdi
call   1060 <fileopen@plt>
mov    %eax,%edi
call   1030 <b64dec@plt>
cmp    $0x1,%eax
je     11cc <b64main+0x6c>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
jmp    11fb <b64main+0x9b>
mov    %r14,%rdi
call   1060 <fileopen@plt>
mov    %eax,%edi
call   1070 <b64enc@plt>
cmp    $0x1,%eax
jne    11eb <b64main+0x8b>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
jmp    11fb <b64main+0x9b>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"enc\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ERR: b64main encode error\0A\00"
@.str.2 = [4 x i8] c"dec\00"
@.str.3 = [27 x i8] c"ERR: b64main decode error\0A\00"
@.str.4 = [27 x i8] c"ERR: b64main invalid mode\0A\00"
define i32 @b64main(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @fileopen(i8* %10)
%12 = call i32 @b64enc(i32 %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 1, i32* %3
br label %37
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @fileopen(i8* %24)
%26 = call i32 @b64dec(i32 %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 1, i32* %3
br label %37
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %19
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %28, %14
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"enc\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ERR: b64main encode error\0A\00"
@.str.2 = [4 x i8] c"dec\00"
@.str.3 = [27 x i8] c"ERR: b64main decode error\0A\00"
@.str.4 = [27 x i8] c"ERR: b64main invalid mode\0A\00"
define i32 @b64main(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 @fileopen(i8* %0)
%7 = tail call i32 @b64enc(i32 %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %28, label %9
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = tail call i32 @fileopen(i8* %0)
%18 = tail call i32 @b64dec(i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @exit(i32 -1)
unreachable
24: ; preds = %13
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @exit(i32 -1)
unreachable
28: ; preds = %16, %5
ret i32 1
}