#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ print_commands();
int /*<<< orphan*/ print_list();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_input(int /*<<< orphan*/ *);
int /*<<< orphan*/ show_email_addresses(char *);
int /*<<< orphan*/ show_paths(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  int quit;
  char line[4096];
  char email[102];
  FILE *input;
  if (argc != 2) {
    printf("Usage: d imput_file\n");
    return 1;
  }
  input = fopen(argv[1], "r");
  read_input(input);
  fclose(input);
  quit = 0;
  while (quit == 0) {
    fgets(line, 4096, stdin);
    if (strcmp(line, "quit\n") == 0) {
      quit = 1;
    } else if (strcmp(line, "list\n") == 0) {
      print_list();
    } else if (strncmp(line, "show ", 5) == 0) {
      sscanf(line, "show %s", email);
      show_email_addresses(email);
    } else if (strncmp(line, "paths ", 6) == 0) {
      sscanf(line, "paths %s", email);
      show_paths(email);
    } else {
      print_commands();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11fb <main+0x3b>
lea    0xe16(%rip),%rdi
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1367 <main+0x1a7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x1098(%rbp)
mov    -0x1098(%rbp),%rdi
call   10e0 <read_input@plt>
mov    -0x1098(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1360 <main+0x1a0>
lea    -0x1020(%rbp),%rdi
mov    0x2d9b(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1090 <fgets@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1282 <main+0xc2>
movl   $0x1,-0x14(%rbp)
jmp    135b <main+0x19b>
lea    -0x1020(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12ab <main+0xeb>
mov    $0x0,%al
call   1060 <print_list@plt>
jmp    1356 <main+0x196>
lea    -0x1020(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12f8 <main+0x138>
lea    -0x1020(%rbp),%rdi
lea    -0x1090(%rbp),%rdx
lea    0xd47(%rip),%rsi
call   10c0 <sscanf@plt>
lea    -0x1090(%rbp),%rdi
call   1070 <show_email_addresses@plt>
jmp    1351 <main+0x191>
lea    -0x1020(%rbp),%rdi
lea    0xd2b(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1345 <main+0x185>
lea    -0x1020(%rbp),%rdi
lea    -0x1090(%rbp),%rdx
lea    0xd09(%rip),%rsi
call   10c0 <sscanf@plt>
lea    -0x1090(%rbp),%rdi
call   1040 <show_paths@plt>
jmp    134c <main+0x18c>
mov    $0x0,%al
call   10b0 <print_commands@plt>
jmp    1351 <main+0x191>
jmp    1356 <main+0x196>
jmp    135b <main+0x19b>
jmp    1235 <main+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1078,%rsp
cmp    $0x2,%edi
jne    131b <main+0x15b>
mov    0x8(%rsi),%rdi
lea    0xe1b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10e0 <read_input@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x2de4(%rip),%r13
mov    0x0(%r13),%edx
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1090 <fgets@plt>
lea    0xde1(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x16e>
lea    0xdcf(%rip),%r14
lea    0x70(%rsp),%rbx
lea    0xdbd(%rip),%r15
lea    0xdc2(%rip),%r12
mov    %rsp,%rbp
jmp    128c <main+0xcc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <print_list@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1090 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x16e>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1260 <main+0xa0>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     12e0 <main+0x120>
lea    0xd61(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12fc <main+0x13c>
xor    %eax,%eax
call   10b0 <print_commands@plt>
jmp    1267 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xd2d(%rip),%rsi
mov    %rbp,%rdx
call   10c0 <sscanf@plt>
mov    %rbp,%rdi
call   1080 <show_email_addresses@plt>
jmp    1267 <main+0xa7>
mov    %rbx,%rdi
lea    0xd1d(%rip),%rsi
mov    %rbp,%rdx
call   10c0 <sscanf@plt>
mov    %rbp,%rdi
call   1050 <show_paths@plt>
jmp    1267 <main+0xa7>
lea    0xd0a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1330 <main+0x170>
xor    %eax,%eax
add    $0x1078,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Usage: d imput_file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"quit\0A\00"
@.str.3 = [6 x i8] c"list\0A\00"
@.str.4 = [6 x i8] c"show \00"
@.str.5 = [8 x i8] c"show %s\00"
@.str.6 = [7 x i8] c"paths \00"
@.str.7 = [9 x i8] c"paths %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca [102 x i8]
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %67
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = call i32 @read_input(i32* %19)
%21 = load i32*, i32** %9
%22 = call i32 @fclose(i32* %21)
store i32 0, i32* %6
br label %23
23: ; preds = %65, %14
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %66
26: ; preds = %23
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %27, i32 4096, i32 %28)
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 1, i32* %6
br label %65
34: ; preds = %26
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (...) @print_list()
br label %64
40: ; preds = %34
%41 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%42 = call i64 @strncmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [102 x i8], [102 x i8]* %8, i64 0, i64 0
%47 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [102 x i8], [102 x i8]* %8, i64 0, i64 0
%49 = call i32 @show_email_addresses(i8* %48)
br label %63
50: ; preds = %40
%51 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%52 = call i64 @strncmp(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %50
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%56 = getelementptr inbounds [102 x i8], [102 x i8]* %8, i64 0, i64 0
%57 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = getelementptr inbounds [102 x i8], [102 x i8]* %8, i64 0, i64 0
%59 = call i32 @show_paths(i8* %58)
br label %62
60: ; preds = %50
%61 = call i32 (...) @print_commands()
br label %62
62: ; preds = %60, %54
br label %63
63: ; preds = %62, %44
br label %64
64: ; preds = %63, %38
br label %65
65: ; preds = %64, %33
br label %23
66: ; preds = %23
store i32 0, i32* %3
br label %67
67: ; preds = %66, %12
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"quit\0A\00"
@.str.3 = [6 x i8] c"list\0A\00"
@.str.4 = [6 x i8] c"show \00"
@.str.5 = [8 x i8] c"show %s\00"
@.str.6 = [7 x i8] c"paths \00"
@.str.7 = [9 x i8] c"paths %s\00"
@str = [20 x i8] c"Usage: d imput_file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [102 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [102 x i8], [102 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %44
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @read_input(i32* %13)
%15 = tail call i32 @fclose(i32* %13)
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %5, i32 4096, i32 %16)
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %44, label %20
20: ; preds = %10, %39
%21 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (...) @print_list()
br label %39
25: ; preds = %20
%26 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%30 = call i32 @show_email_addresses(i8* %6)
br label %39
31: ; preds = %25
%32 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%36 = call i32 @show_paths(i8* %6)
br label %39
37: ; preds = %31
%38 = call i32 (...) @print_commands()
br label %39
39: ; preds = %23, %34, %37, %28
%40 = load i32, i32* @stdin
%41 = call i32 @fgets(i8* %5, i32 4096, i32 %40)
%42 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %20
44: ; preds = %39, %10, %8
%45 = phi i32 [ 1, %8 ], [ 0, %10 ], [ 0, %39 ]
ret i32 %45
}