#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ from64(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char **,
                          int *, int);
int /*<<< orphan*/ fromqp(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ to64(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ toqp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int encode = 1, which = 1, i, portablenewlines = 0;
  FILE *fp = stdin;
  FILE *fpo = stdout;
  for (i = 1; i < argc; ++i) {
    if (argv[i][0] == '-') {
      switch (argv[i][1]) {
      case 'o':
        if (++i >= argc) {
          fprintf(stderr, "mimencode: -o requires a file name.\n");
          exit(-1);
        }
        fpo = fopen(argv[i], "w");
        if (!fpo) {
          perror(argv[i]);
          exit(-1);
        }
        break;
      case 'u':
        encode = 0;
        break;
      case 'q':
        which = 2;
        break;
      case 'p':
        portablenewlines = 1;
        break;
      case 'b':
        which = 1;
        break;
      default:
        fprintf(stderr, "Usage: mmencode [-u] [-q] [-b] [-p] [-o outputfile] "
                        "[file name]\n");
        exit(-1);
      }
    } else {
      fp = fopen(argv[i], "r");
      if (!fp) {
        perror(argv[i]);
        exit(-1);
      }
    }
  }
  if (which == 1) {
    if (encode) {
      to64(fp, fpo, portablenewlines);
    } else {
      from64(fp, fpo, (char **)NULL, (int *)0, portablenewlines);
    }
  } else {
    if (encode)
      toqp(fp, fpo);
    else
      fromqp(fp, fpo, NULL, 0);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    134e <main+0x1ce>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12f4 <main+0x174>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x13,%eax
ja     12d0 <main+0x150>
mov    -0x38(%rbp),%rax
lea    0xde1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    -0x8(%rbp),%eax
jl     1259 <main+0xd9>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe09(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    129b <main+0x11b>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    12ef <main+0x16f>
movl   $0x0,-0x14(%rbp)
jmp    12ef <main+0x16f>
movl   $0x2,-0x18(%rbp)
jmp    12ef <main+0x16f>
movl   $0x1,-0x20(%rbp)
jmp    12ef <main+0x16f>
movl   $0x1,-0x18(%rbp)
jmp    12ef <main+0x16f>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    133b <main+0x1bb>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1336 <main+0x1b6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    133b <main+0x1bb>
jmp    1340 <main+0x1c0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ce <main+0x4e>
cmpl   $0x1,-0x18(%rbp)
jne    1394 <main+0x214>
cmpl   $0x0,-0x14(%rbp)
je     1377 <main+0x1f7>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <to64@plt>
jmp    138f <main+0x20f>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1060 <from64@plt>
jmp    13c8 <main+0x248>
cmpl   $0x0,-0x14(%rbp)
je     13b0 <main+0x230>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10a0 <toqp@plt>
jmp    13c3 <main+0x243>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <fromqp@plt>
jmp    13c8 <main+0x248>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%rbx
mov    0x2e2c(%rip),%rax
mov    (%rax),%rsi
xor    %edx,%edx
cmp    $0x2,%edi
jl     12ab <main+0x12b>
mov    %edi,%r12d
mov    %rsi,0x8(%rsp)
mov    $0x1,%r14d
movl   $0x0,(%rsp)
movl   $0x1,0x4(%rsp)
mov    $0x1,%edx
jmp    1208 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
lea    0xed1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r15d,%edx
test   %rax,%rax
je     12fe <main+0x17e>
add    $0x1,%r14d
cmp    %r12d,%r14d
jge    1298 <main+0x118>
mov    %edx,%r15d
movslq %r14d,%r13
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rdi
cmpb   $0x2d,(%rdi)
jne    11e0 <main+0x60>
movsbl 0x1(%rdi),%ecx
add    $0xffffff9e,%ecx
cmp    $0x13,%ecx
ja     1316 <main+0x196>
xor    %edx,%edx
lea    0xdcb(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movl   $0x1,0x4(%rsp)
jmp    1290 <main+0x110>
add    $0x1,%r14d
cmp    %r12d,%r14d
jge    1328 <main+0x1a8>
movslq %r14d,%rbp
mov    0x10(%rsp),%rax
mov    (%rax,%rbp,8),%rdi
lea    0xe0d(%rip),%rsi
call   1070 <fopen@plt>
mov    %r15d,%edx
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    11fb <main+0x7b>
jmp    1347 <main+0x1c7>
movl   $0x1,(%rsp)
jmp    1290 <main+0x110>
movl   $0x2,0x4(%rsp)
mov    %r15d,%edx
jmp    11fb <main+0x7b>
cmpl   $0x1,0x4(%rsp)
jne    12c4 <main+0x144>
test   %edx,%edx
je     12d7 <main+0x157>
mov    (%rsp),%edx
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <to64@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
test   %edx,%edx
je     12ee <main+0x16e>
mov    0x8(%rsp),%rsi
call   10a0 <toqp@plt>
jmp    12b3 <main+0x133>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    (%rsp),%r8d
call   1060 <from64@plt>
jmp    12b3 <main+0x133>
mov    0x8(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <fromqp@plt>
jmp    12b3 <main+0x133>
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
jmp    1338 <main+0x1b8>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%rbp,8),%rdi
jmp    1307 <main+0x187>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32 0
@.str = [37 x i8] c"mimencode: -o requires a file name.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [65 x i8] c"Usage: mmencode [-u] [-q] [-b] [-p] [-o outputfile] [file name]\0A\00"
@.str.3 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 1, i32* %7
store i32 0, i32* %9
%12 = load i32*, i32** @stdin
store i32* %12, i32** %10
%13 = load i32*, i32** @stdout
store i32* %13, i32** %11
store i32 1, i32* %8
br label %14
14: ; preds = %92, %2
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %95
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 45
br i1 %27, label %28, label %73
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
switch i32 %36, label %68 [
i32 111, label %37
i32 117, label %64
i32 113, label %65
i32 112, label %66
i32 98, label %67
]
37: ; preds = %28
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
%40 = load i32, i32* %4
%41 = icmp sge i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 -1)
unreachable
46: ; preds = %37
%47 = load i8**, i8*** %5
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %52, i32** %11
%53 = load i32*, i32** %11
%54 = icmp ne i32* %53, null
br i1 %54, label %63, label %55
55: ; preds = %46
%56 = load i8**, i8*** %5
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @perror(i8* %60)
%62 = call i32 @exit(i32 -1)
unreachable
63: ; preds = %46
br label %72
64: ; preds = %28
store i32 0, i32* %6
br label %72
65: ; preds = %28
store i32 2, i32* %7
br label %72
66: ; preds = %28
store i32 1, i32* %9
br label %72
67: ; preds = %28
store i32 1, i32* %7
br label %72
68: ; preds = %28
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
%71 = call i32 @exit(i32 -1)
unreachable
72: ; preds = %67, %66, %65, %64, %63
br label %91
73: ; preds = %18
%74 = load i8**, i8*** %5
%75 = load i32, i32* %8
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32* @fopen(i8* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %79, i32** %10
%80 = load i32*, i32** %10
%81 = icmp ne i32* %80, null
br i1 %81, label %90, label %82
82: ; preds = %73
%83 = load i8**, i8*** %5
%84 = load i32, i32* %8
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
%88 = call i32 @perror(i8* %87)
%89 = call i32 @exit(i32 -1)
unreachable
90: ; preds = %73
br label %91
91: ; preds = %90, %72
br label %92
92: ; preds = %91
%93 = load i32, i32* %8
%94 = add nsw i32 %93, 1
store i32 %94, i32* %8
br label %14
95: ; preds = %14
%96 = load i32, i32* %7
%97 = icmp eq i32 %96, 1
br i1 %97, label %98, label %112
98: ; preds = %95
%99 = load i32, i32* %6
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %98
%102 = load i32*, i32** %10
%103 = load i32*, i32** %11
%104 = load i32, i32* %9
%105 = call i32 @to64(i32* %102, i32* %103, i32 %104)
br label %111
106: ; preds = %98
%107 = load i32*, i32** %10
%108 = load i32*, i32** %11
%109 = load i32, i32* %9
%110 = call i32 @from64(i32* %107, i32* %108, i8** null, i32* null, i32 %109)
br label %111
111: ; preds = %106, %101
br label %124
112: ; preds = %95
%113 = load i32, i32* %6
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %119
115: ; preds = %112
%116 = load i32*, i32** %10
%117 = load i32*, i32** %11
%118 = call i32 @toqp(i32* %116, i32* %117)
br label %123
119: ; preds = %112
%120 = load i32*, i32** %10
%121 = load i32*, i32** %11
%122 = call i32 @fromqp(i32* %120, i32* %121, i32* null, i32 0)
br label %123
123: ; preds = %119, %115
br label %124
124: ; preds = %123, %111
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32 0
@.str = [37 x i8] c"mimencode: -o requires a file name.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [65 x i8] c"Usage: mmencode [-u] [-q] [-b] [-p] [-o outputfile] [file name]\0A\00"
@.str.3 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32*, i32** @stdin
%4 = load i32*, i32** @stdout
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %68
6: ; preds = %2, %55
%7 = phi i32* [ %61, %55 ], [ %4, %2 ]
%8 = phi i32* [ %60, %55 ], [ %3, %2 ]
%9 = phi i32 [ %59, %55 ], [ 0, %2 ]
%10 = phi i32 [ %62, %55 ], [ 1, %2 ]
%11 = phi i32 [ %57, %55 ], [ 1, %2 ]
%12 = phi i32 [ %56, %55 ], [ 1, %2 ]
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %18, label %47
18: ; preds = %6
%19 = getelementptr inbounds i8, i8* %15, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %43 [
i32 111, label %22
i32 117, label %55
i32 113, label %40
i32 112, label %41
i32 98, label %42
]
22: ; preds = %18
%23 = add nsw i32 %10, 1
%24 = icmp slt i32 %23, %0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 -1)
unreachable
29: ; preds = %22
%30 = sext i32 %23 to i64
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %55
35: ; preds = %29
%36 = getelementptr inbounds i8*, i8** %1, i64 %30
%37 = load i8*, i8** %36
%38 = tail call i32 @perror(i8* %37)
%39 = tail call i32 @exit(i32 -1)
unreachable
40: ; preds = %18
br label %55
41: ; preds = %18
br label %55
42: ; preds = %18
br label %55
43: ; preds = %18
%44 = load i32, i32* @stderr
%45 = tail call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
%46 = tail call i32 @exit(i32 -1)
unreachable
47: ; preds = %6
%48 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = getelementptr inbounds i8*, i8** %1, i64 %13
%52 = load i8*, i8** %51
%53 = tail call i32 @perror(i8* %52)
%54 = tail call i32 @exit(i32 -1)
unreachable
55: ; preds = %18, %29, %42, %41, %40, %47
%56 = phi i32 [ %12, %42 ], [ %12, %41 ], [ %12, %40 ], [ %12, %29 ], [ %12, %47 ], [ 0, %18 ]
%57 = phi i32 [ 1, %42 ], [ %11, %41 ], [ 2, %40 ], [ %11, %29 ], [ %11, %47 ], [ %11, %18 ]
%58 = phi i32 [ %10, %42 ], [ %10, %41 ], [ %10, %40 ], [ %23, %29 ], [ %10, %47 ], [ %10, %18 ]
%59 = phi i32 [ %9, %42 ], [ 1, %41 ], [ %9, %40 ], [ %9, %29 ], [ %9, %47 ], [ %9, %18 ]
%60 = phi i32* [ %8, %42 ], [ %8, %41 ], [ %8, %40 ], [ %8, %29 ], [ %48, %47 ], [ %8, %18 ]
%61 = phi i32* [ %7, %42 ], [ %7, %41 ], [ %7, %40 ], [ %33, %29 ], [ %7, %47 ], [ %7, %18 ]
%62 = add nsw i32 %58, 1
%63 = icmp slt i32 %62, %0
br i1 %63, label %6, label %64
64: ; preds = %55
%65 = icmp eq i32 %57, 1
%66 = icmp eq i32 %56, 0
br i1 %65, label %67, label %75
67: ; preds = %64
br i1 %66, label %73, label %68
68: ; preds = %2, %67
%69 = phi i32 [ %59, %67 ], [ 0, %2 ]
%70 = phi i32* [ %60, %67 ], [ %3, %2 ]
%71 = phi i32* [ %61, %67 ], [ %4, %2 ]
%72 = tail call i32 @to64(i32* %70, i32* %71, i32 %69)
br label %80
73: ; preds = %67
%74 = tail call i32 @from64(i32* %60, i32* %61, i8** null, i32* null, i32 %59)
br label %80
75: ; preds = %64
br i1 %66, label %78, label %76
76: ; preds = %75
%77 = tail call i32 @toqp(i32* %60, i32* %61)
br label %80
78: ; preds = %75
%79 = tail call i32 @fromqp(i32* %60, i32* %61, i32* null, i32 0)
br label %80
80: ; preds = %76, %78, %68, %73
ret i32 0
}