#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ from64(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ to64(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int mm(int encode, char *fin, char *fout) {
  int portablenewlines = 0;
  FILE *in, *out;
  if (fin != NULL)
    in = fopen(fin, "r");
  else
    in = stdin;
  if (fout != NULL)
    out = fopen(fout, "w");
  else
    out = stdout;
  if (encode)
    to64(in, out, portablenewlines);
  else
    from64(in, out, NULL, 0, portablenewlines);
  if (fout != NULL)
    fclose(out);
  if (fin != NULL)
    fclose(in);
  return (0);
}


x86 assembly (clang, -O0):
<mm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117e <mm+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
jmp    118c <mm+0x4c>
mov    0x2e63(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b0 <mm+0x70>
mov    -0x18(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
jmp    11be <mm+0x7e>
mov    0x2e21(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11dd <mm+0x9d>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <to64@plt>
jmp    11f4 <mm+0xb4>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <from64@plt>
cmpq   $0x0,-0x18(%rbp)
je     1208 <mm+0xc8>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x10(%rbp)
je     121c <mm+0xdc>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r12d
test   %rsi,%rsi
je     1181 <mm+0x41>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     1190 <mm+0x50>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbp
jmp    119a <mm+0x5a>
mov    0x2e60(%rip),%rax
mov    (%rax),%r15
test   %rbx,%rbx
jne    116d <mm+0x2d>
mov    0x2e41(%rip),%rax
mov    (%rax),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
test   %r12d,%r12d
je     11d1 <mm+0x91>
xor    %edx,%edx
call   1030 <to64@plt>
test   %rbx,%rbx
je     11b9 <mm+0x79>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %r14,%r14
je     11c6 <mm+0x86>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <from64@plt>
test   %rbx,%rbx
jne    11b1 <mm+0x71>
jmp    11b9 <mm+0x79>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32* null
define i32 @mm(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %8
br label %17
15: ; preds = %3
%16 = load i32*, i32** @stdin
store i32* %16, i32** %8
br label %17
17: ; preds = %15, %12
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %6
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %9
br label %25
23: ; preds = %17
%24 = load i32*, i32** @stdout
store i32* %24, i32** %9
br label %25
25: ; preds = %23, %20
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32*, i32** %8
%30 = load i32*, i32** %9
%31 = load i32, i32* %7
%32 = call i32 @to64(i32* %29, i32* %30, i32 %31)
br label %38
33: ; preds = %25
%34 = load i32*, i32** %8
%35 = load i32*, i32** %9
%36 = load i32, i32* %7
%37 = call i32 @from64(i32* %34, i32* %35, i32* null, i32 0, i32 %36)
br label %38
38: ; preds = %33, %28
%39 = load i8*, i8** %6
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32*, i32** %9
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %41, %38
%45 = load i8*, i8** %5
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32*, i32** %8
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %47, %44
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"w\00"
@stdout = global i32* null
define i32 @mm(i32 %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %3
%8 = load i32*, i32** @stdin
br label %9
9: ; preds = %7, %5
%10 = phi i32* [ %6, %5 ], [ %8, %7 ]
%11 = icmp eq i8* %2, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = load i32*, i32** @stdout
br label %16
16: ; preds = %14, %12
%17 = phi i32* [ %13, %12 ], [ %15, %14 ]
%18 = icmp eq i32 %0, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @to64(i32* %10, i32* %17, i32 0)
br label %23
21: ; preds = %16
%22 = tail call i32 @from64(i32* %10, i32* %17, i32* null, i32 0, i32 0)
br label %23
23: ; preds = %21, %19
br i1 %11, label %26, label %24
24: ; preds = %23
%25 = tail call i32 @fclose(i32* %17)
br label %26
26: ; preds = %24, %23
br i1 %4, label %29, label %27
27: ; preds = %26
%28 = tail call i32 @fclose(i32* %10)
br label %29
29: ; preds = %27, %26
ret i32 0
}