#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 loadRegister(int /*<<< orphan*/ *);
int nChars(int /*<<< orphan*/ *);
int nColumns(int /*<<< orphan*/ *);
int nRows(int /*<<< orphan*/ *);
int /*<<< orphan*/ newRow(int /*<<< orphan*/ *);
int /*<<< orphan*/ printFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ printRow(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int rowMax(int /*<<< orphan*/ *);
void selectOption(int option) {
  FILE *f;
  switch (option) {
  case 1:
    f = fopen("car.txt", "r");
    printf("Total number of rows: %d\n\n", nRows(f));
    fclose(f);
    break;
  case 2:
    f = fopen("car.txt", "r");
    printf("Total number of columns: %d\n\n", nColumns(f));
    fclose(f);
    break;
  case 3:
    f = fopen("car.txt", "r");
    printf("Total number of characters: %d\n\n", nChars(f));
    fclose(f);
    break;
  case 4:
    f = fopen("car.txt", "r");
    printf("Longest row: %d\n\n", rowMax(f));
    fclose(f);
    break;
  case 5:
    f = fopen("car.txt", "r");
    printRow(f);
    fclose(f);
    break;
  case 6:
    f = fopen("car.txt", "r");
    printFile(f);
    fclose(f);
    break;
  case 7:
    f = fopen("car.txt", "a");
    newRow(f);
    fclose(f);
    break;
  case 8:
    f = fopen("car.txt", "r");
    printf("Rows loaded: %d\n\n", loadRegister(f));
    fclose(f);
    break;
  }
}


x86 assembly (clang, -O0):
<selectOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     1395 <selectOption+0x1e5>
mov    -0x18(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe35(%rip),%rdi
lea    0xe36(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <nRows@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xdf9(%rip),%rdi
lea    0xdfa(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <nColumns@plt>
mov    %eax,%esi
lea    0xdfc(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xdbd(%rip),%rdi
lea    0xdbe(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10d0 <nChars@plt>
mov    %eax,%esi
lea    0xdde(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xd81(%rip),%rdi
lea    0xd82(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <rowMax@plt>
mov    %eax,%esi
lea    0xdc3(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xd45(%rip),%rdi
lea    0xd46(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <printRow@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xd17(%rip),%rdi
lea    0xd18(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <printFile@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xce9(%rip),%rdi
lea    0xd58(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <newRow@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1395 <selectOption+0x1e5>
lea    0xcbb(%rip),%rdi
lea    0xcbc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <loadRegister@plt>
mov    %eax,%esi
lea    0xd11(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectOption>:
add    $0xffffffff,%edi
cmp    $0x7,%edi
ja     11f3 <selectOption+0x43>
push   %rbx
lea    0xe40(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe50(%rip),%rdi
lea    0xe51(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <nRows@plt>
lea    0xe3c(%rip),%rdi
jmp    12f7 <selectOption+0x147>
ret
lea    0xe25(%rip),%rdi
lea    0xe26(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <nColumns@plt>
lea    0xe2c(%rip),%rdi
jmp    12f7 <selectOption+0x147>
lea    0xdfb(%rip),%rdi
lea    0xdfc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <nChars@plt>
lea    0xe20(%rip),%rdi
jmp    12f7 <selectOption+0x147>
lea    0xdd1(%rip),%rdi
lea    0xdd2(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <rowMax@plt>
lea    0xe17(%rip),%rdi
jmp    12f7 <selectOption+0x147>
lea    0xda7(%rip),%rdi
lea    0xda8(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <printRow@plt>
jmp    12fe <selectOption+0x14e>
lea    0xd87(%rip),%rdi
lea    0xd88(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <printFile@plt>
jmp    12fe <selectOption+0x14e>
lea    0xd67(%rip),%rdi
lea    0xdd6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <newRow@plt>
jmp    12fe <selectOption+0x14e>
lea    0xd47(%rip),%rdi
lea    0xd48(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <loadRegister@plt>
lea    0xda1(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"Total number of rows: %d\0A\0A\00"
@.str.3 = [30 x i8] c"Total number of columns: %d\0A\0A\00"
@.str.4 = [33 x i8] c"Total number of characters: %d\0A\0A\00"
@.str.5 = [18 x i8] c"Longest row: %d\0A\0A\00"
@.str.6 = [2 x i8] c"a\00"
@.str.7 = [18 x i8] c"Rows loaded: %d\0A\0A\00"
define void @selectOption(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %58 [
i32 1, label %5
i32 2, label %12
i32 3, label %19
i32 4, label %26
i32 5, label %33
i32 6, label %39
i32 7, label %45
i32 8, label %51
]
5: ; preds = %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = call i32 @nRows(i32* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %3
%11 = call i32 @fclose(i32* %10)
br label %58
12: ; preds = %1
%13 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %3
%15 = call i32 @nColumns(i32* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %3
%18 = call i32 @fclose(i32* %17)
br label %58
19: ; preds = %1
%20 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %3
%21 = load i32*, i32** %3
%22 = call i32 @nChars(i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
br label %58
26: ; preds = %1
%27 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %3
%28 = load i32*, i32** %3
%29 = call i32 @rowMax(i32* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
br label %58
33: ; preds = %1
%34 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %3
%35 = load i32*, i32** %3
%36 = call i32 @printRow(i32* %35)
%37 = load i32*, i32** %3
%38 = call i32 @fclose(i32* %37)
br label %58
39: ; preds = %1
%40 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %40, i32** %3
%41 = load i32*, i32** %3
%42 = call i32 @printFile(i32* %41)
%43 = load i32*, i32** %3
%44 = call i32 @fclose(i32* %43)
br label %58
45: ; preds = %1
%46 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %46, i32** %3
%47 = load i32*, i32** %3
%48 = call i32 @newRow(i32* %47)
%49 = load i32*, i32** %3
%50 = call i32 @fclose(i32* %49)
br label %58
51: ; preds = %1
%52 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %52, i32** %3
%53 = load i32*, i32** %3
%54 = call i32 @loadRegister(i32* %53)
%55 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %54)
%56 = load i32*, i32** %3
%57 = call i32 @fclose(i32* %56)
br label %58
58: ; preds = %1, %51, %45, %39, %33, %26, %19, %12, %5
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"Total number of rows: %d\0A\0A\00"
@.str.3 = [30 x i8] c"Total number of columns: %d\0A\0A\00"
@.str.4 = [33 x i8] c"Total number of characters: %d\0A\0A\00"
@.str.5 = [18 x i8] c"Longest row: %d\0A\0A\00"
@.str.6 = [2 x i8] c"a\00"
@.str.7 = [18 x i8] c"Rows loaded: %d\0A\0A\00"
define void @selectOption(i32 %0) {
switch i32 %0, label %34 [
i32 1, label %2
i32 2, label %6
i32 3, label %10
i32 4, label %14
i32 5, label %18
i32 6, label %21
i32 7, label %24
i32 8, label %27
]
2: ; preds = %1
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @nRows(i32* %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %31
6: ; preds = %1
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @nColumns(i32* %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %31
10: ; preds = %1
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @nChars(i32* %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %12)
br label %31
14: ; preds = %1
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @rowMax(i32* %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %16)
br label %31
18: ; preds = %1
%19 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @printRow(i32* %19)
br label %31
21: ; preds = %1
%22 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @printFile(i32* %22)
br label %31
24: ; preds = %1
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = tail call i32 @newRow(i32* %25)
br label %31
27: ; preds = %1
%28 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call i32 @loadRegister(i32* %28)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %2, %6, %10, %14, %18, %21, %24, %27
%32 = phi i32* [ %28, %27 ], [ %25, %24 ], [ %22, %21 ], [ %19, %18 ], [ %15, %14 ], [ %11, %10 ], [ %7, %6 ], [ %3, %2 ]
%33 = tail call i32 @fclose(i32* %32)
br label %34
34: ; preds = %31, %1
ret void
}