#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int language_type(char *);
int /*<<< orphan*/ list_mb(int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_tex_output(char *);
int /*<<< orphan*/ process_f(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ process_mb(int /*<<< orphan*/ *);
int /*<<< orphan*/ process_simple(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  char *);
int /*<<< orphan*/ stderr;
void process_file(char *fname, int language, FILE *combined_doc) {
  FILE *out = combined_doc;
  FILE *in;
  if (language == -1)
    language = language_type(fname);
  if ((in = fopen(fname, "r")) == NULL) {
    fprintf(stderr, "Could not open input %s\n", fname);
    exit(-1);
  }
  if (!combined_doc && language != 2 && language != 7)
    out = open_tex_output(fname);
  if (language == 0)
    process_simple(in, out, " \t/*");
  else if (language == 1)
    process_simple(in, out, " \t%");
  else if (language == 2)
    process_mb(in);
  else if (language == 7)
    list_mb(in);
  else if (language == 3)
    process_f(in, out);
  else if (language == 4)
    process_simple(in, out, " \t-");
  else if (language == 5)
    process_simple(in, out, "#");
  else if (language == 6)
    process_simple(in, out, " \t;");
  if (!combined_doc && out)
    fclose(out);
  fclose(in);
}


x86 assembly (clang, -O0):
<process_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11d1 <process_file+0x31>
mov    -0x8(%rbp),%rdi
call   1070 <language_type@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1212 <process_file+0x72>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdff(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    123e <process_file+0x9e>
cmpl   $0x2,-0xc(%rbp)
je     123e <process_file+0x9e>
cmpl   $0x7,-0xc(%rbp)
je     123e <process_file+0x9e>
mov    -0x8(%rbp),%rdi
call   1080 <open_tex_output@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1261 <process_file+0xc1>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xdc4(%rip),%rdx
call   1050 <process_simple@plt>
jmp    1357 <process_file+0x1b7>
cmpl   $0x1,-0xc(%rbp)
jne    1284 <process_file+0xe4>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xda6(%rip),%rdx
call   1050 <process_simple@plt>
jmp    1352 <process_file+0x1b2>
cmpl   $0x2,-0xc(%rbp)
jne    129c <process_file+0xfc>
mov    -0x28(%rbp),%rdi
call   10c0 <process_mb@plt>
jmp    134d <process_file+0x1ad>
cmpl   $0x7,-0xc(%rbp)
jne    12b4 <process_file+0x114>
mov    -0x28(%rbp),%rdi
call   1030 <list_mb@plt>
jmp    1348 <process_file+0x1a8>
cmpl   $0x3,-0xc(%rbp)
jne    12d0 <process_file+0x130>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <process_f@plt>
jmp    1343 <process_file+0x1a3>
cmpl   $0x4,-0xc(%rbp)
jne    12f3 <process_file+0x153>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xd3b(%rip),%rdx
call   1050 <process_simple@plt>
jmp    133e <process_file+0x19e>
cmpl   $0x5,-0xc(%rbp)
jne    1316 <process_file+0x176>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xd1c(%rip),%rdx
call   1050 <process_simple@plt>
jmp    1339 <process_file+0x199>
cmpl   $0x6,-0xc(%rbp)
jne    1334 <process_file+0x194>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xcfb(%rip),%rdx
call   1050 <process_simple@plt>
jmp    1339 <process_file+0x199>
jmp    133e <process_file+0x19e>
jmp    1343 <process_file+0x1a3>
jmp    1348 <process_file+0x1a8>
jmp    134d <process_file+0x1ad>
jmp    1352 <process_file+0x1b2>
jmp    1357 <process_file+0x1b7>
cmpq   $0x0,-0x18(%rbp)
jne    1376 <process_file+0x1d6>
cmpq   $0x0,-0x20(%rbp)
je     1376 <process_file+0x1d6>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    $0xffffffff,%esi
jne    11bf <process_file+0x1f>
mov    %rbx,%rdi
call   1070 <language_type@plt>
mov    %eax,%ebp
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     129f <process_file+0xff>
mov    %rax,%r12
mov    %r14,%r15
test   %r14,%r14
je     1206 <process_file+0x66>
cmp    $0x7,%ebp
ja     126e <process_file+0xce>
mov    %ebp,%eax
lea    0xe0c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe37(%rip),%rdx
jmp    1263 <process_file+0xc3>
xor    %r15d,%r15d
cmp    $0x2,%ebp
je     11e2 <process_file+0x42>
cmp    $0x7,%ebp
je     11e2 <process_file+0x42>
mov    %rbx,%rdi
call   1080 <open_tex_output@plt>
mov    %rax,%r15
jmp    11e2 <process_file+0x42>
lea    0xe19(%rip),%rdx
jmp    1263 <process_file+0xc3>
mov    %r12,%rdi
call   10c0 <process_mb@plt>
test   %r14,%r14
je     1273 <process_file+0xd3>
jmp    1280 <process_file+0xe0>
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <process_f@plt>
test   %r14,%r14
je     1273 <process_file+0xd3>
jmp    1280 <process_file+0xe0>
lea    0xdf3(%rip),%rdx
jmp    1263 <process_file+0xc3>
lea    0xdee(%rip),%rdx
jmp    1263 <process_file+0xc3>
lea    0xde7(%rip),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <process_simple@plt>
test   %r14,%r14
jne    1280 <process_file+0xe0>
test   %r15,%r15
je     1280 <process_file+0xe0>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
mov    %r12,%rdi
call   1030 <list_mb@plt>
test   %r14,%r14
je     1273 <process_file+0xd3>
jmp    1280 <process_file+0xe0>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Could not open input %s\0A\00"
@.str.2 = [5 x i8] c" \09/*\00"
@.str.3 = [4 x i8] c" \09%\00"
@.str.4 = [4 x i8] c" \09-\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [4 x i8] c" \09;\00"
define void @process_file(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32*, i32** %6
store i32* %9, i32** %7
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %4
%14 = call i32 @language_type(i8* %13)
store i32 %14, i32* %5
br label %15
15: ; preds = %12, %3
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %4
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %15
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 2
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i32, i32* %5
%32 = icmp ne i32 %31, 7
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i8*, i8** %4
%35 = call i32* @open_tex_output(i8* %34)
store i32* %35, i32** %7
br label %36
36: ; preds = %33, %30, %27, %24
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32*, i32** %8
%41 = load i32*, i32** %7
%42 = call i32 @process_simple(i32* %40, i32* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %97
43: ; preds = %36
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32*, i32** %8
%48 = load i32*, i32** %7
%49 = call i32 @process_simple(i32* %47, i32* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %96
50: ; preds = %43
%51 = load i32, i32* %5
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32*, i32** %8
%55 = call i32 @process_mb(i32* %54)
br label %95
56: ; preds = %50
%57 = load i32, i32* %5
%58 = icmp eq i32 %57, 7
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32*, i32** %8
%61 = call i32 @list_mb(i32* %60)
br label %94
62: ; preds = %56
%63 = load i32, i32* %5
%64 = icmp eq i32 %63, 3
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = load i32*, i32** %8
%67 = load i32*, i32** %7
%68 = call i32 @process_f(i32* %66, i32* %67)
br label %93
69: ; preds = %62
%70 = load i32, i32* %5
%71 = icmp eq i32 %70, 4
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = load i32*, i32** %8
%74 = load i32*, i32** %7
%75 = call i32 @process_simple(i32* %73, i32* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %92
76: ; preds = %69
%77 = load i32, i32* %5
%78 = icmp eq i32 %77, 5
br i1 %78, label %79, label %83
79: ; preds = %76
%80 = load i32*, i32** %8
%81 = load i32*, i32** %7
%82 = call i32 @process_simple(i32* %80, i32* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %91
83: ; preds = %76
%84 = load i32, i32* %5
%85 = icmp eq i32 %84, 6
br i1 %85, label %86, label %90
86: ; preds = %83
%87 = load i32*, i32** %8
%88 = load i32*, i32** %7
%89 = call i32 @process_simple(i32* %87, i32* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %90
90: ; preds = %86, %83
br label %91
91: ; preds = %90, %79
br label %92
92: ; preds = %91, %72
br label %93
93: ; preds = %92, %65
br label %94
94: ; preds = %93, %59
br label %95
95: ; preds = %94, %53
br label %96
96: ; preds = %95, %46
br label %97
97: ; preds = %96, %39
%98 = load i32*, i32** %6
%99 = icmp ne i32* %98, null
br i1 %99, label %106, label %100
100: ; preds = %97
%101 = load i32*, i32** %7
%102 = icmp ne i32* %101, null
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = load i32*, i32** %7
%105 = call i32 @fclose(i32* %104)
br label %106
106: ; preds = %103, %100, %97
%107 = load i32*, i32** %8
%108 = call i32 @fclose(i32* %107)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Could not open input %s\0A\00"
@.str.2 = [5 x i8] c" \09/*\00"
@.str.3 = [4 x i8] c" \09%\00"
@.str.4 = [4 x i8] c" \09-\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [4 x i8] c" \09;\00"
define void @process_file(i8* %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, -1
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @language_type(i8* %0)
br label %7
7: ; preds = %5, %3
%8 = phi i32 [ %6, %5 ], [ %1, %3 ]
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %7
%16 = icmp eq i32* %2, null
br i1 %16, label %17, label %20
17: ; preds = %15
switch i32 %8, label %18 [
i32 7, label %20
i32 2, label %20
]
18: ; preds = %17
%19 = tail call i32* @open_tex_output(i8* %0)
br label %20
20: ; preds = %17, %17, %15, %18
%21 = phi i32* [ %19, %18 ], [ null, %17 ], [ %2, %15 ], [ null, %17 ]
switch i32 %8, label %38 [
i32 0, label %22
i32 1, label %24
i32 2, label %26
i32 7, label %28
i32 3, label %30
i32 4, label %32
i32 5, label %34
i32 6, label %36
]
22: ; preds = %20
%23 = tail call i32 @process_simple(i32* %9, i32* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %38
24: ; preds = %20
%25 = tail call i32 @process_simple(i32* %9, i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %38
26: ; preds = %20
%27 = tail call i32 @process_mb(i32* %9)
br label %38
28: ; preds = %20
%29 = tail call i32 @list_mb(i32* %9)
br label %38
30: ; preds = %20
%31 = tail call i32 @process_f(i32* %9, i32* %21)
br label %38
32: ; preds = %20
%33 = tail call i32 @process_simple(i32* %9, i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %38
34: ; preds = %20
%35 = tail call i32 @process_simple(i32* %9, i32* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %38
36: ; preds = %20
%37 = tail call i32 @process_simple(i32* %9, i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %20, %24, %28, %32, %36, %34, %30, %26, %22
%39 = icmp ne i32* %21, null
%40 = select i1 %16, i1 %39, i1 false
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 @fclose(i32* %21)
br label %43
43: ; preds = %41, %38
%44 = tail call i32 @fclose(i32* %9)
ret void
}