#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_paths(char *);
int /*<<< orphan*/ show_statistics(char *);
scalar_t__ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  FILE *input;
  int quit;
  char line[4096];
  char email[102];
  char user[51];
  char tld[51];
  if (argc != 2) {
    printf("Usage: d input_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) {
      if (sscanf(line, "show %s", email)) {
        show_statistics(email);
      } else {
        print_commands();
      }
    } else if (strncmp(line, "paths ", 6) == 0) {
      if (sscanf(line, "paths %s", email)) {
        show_paths(email);
      } else {
        print_commands();
      }
    } else {
      print_commands();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1110,%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   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138a <main+0x1ca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   10e0 <read_input@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1383 <main+0x1c3>
lea    -0x1020(%rbp),%rdi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1080 <fgets@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1279 <main+0xb9>
movl   $0x1,-0x1c(%rbp)
jmp    137e <main+0x1be>
lea    -0x1020(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12a2 <main+0xe2>
mov    $0x0,%al
call   1060 <print_list@plt>
jmp    1379 <main+0x1b9>
lea    -0x1020(%rbp),%rdi
lea    0xd73(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1305 <main+0x145>
lea    -0x1020(%rbp),%rdi
lea    -0x1090(%rbp),%rdx
lea    0xd50(%rip),%rsi
call   10c0 <sscanf@plt>
cmp    $0x0,%rax
je     12f9 <main+0x139>
lea    -0x1090(%rbp),%rdi
call   10b0 <show_statistics@plt>
jmp    1300 <main+0x140>
mov    $0x0,%al
call   10a0 <print_commands@plt>
jmp    1374 <main+0x1b4>
lea    -0x1020(%rbp),%rdi
lea    0xd1e(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1368 <main+0x1a8>
lea    -0x1020(%rbp),%rdi
lea    -0x1090(%rbp),%rdx
lea    0xcfc(%rip),%rsi
call   10c0 <sscanf@plt>
cmp    $0x0,%rax
je     135c <main+0x19c>
lea    -0x1090(%rbp),%rdi
call   1040 <show_paths@plt>
jmp    1363 <main+0x1a3>
mov    $0x0,%al
call   10a0 <print_commands@plt>
jmp    136f <main+0x1af>
mov    $0x0,%al
call   10a0 <print_commands@plt>
jmp    1374 <main+0x1b4>
jmp    1379 <main+0x1b9>
jmp    137e <main+0x1be>
jmp    122c <main+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1110,%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    132c <main+0x16c>
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   1080 <fgets@plt>
lea    0xde1(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     133f <main+0x17f>
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   1080 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     133f <main+0x17f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <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     12f0 <main+0x130>
lea    0xd61(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1320 <main+0x160>
mov    %rbx,%rdi
lea    0xd4f(%rip),%rsi
mov    %rbp,%rdx
call   10c0 <sscanf@plt>
test   %rax,%rax
je     1320 <main+0x160>
mov    %rbp,%rdi
call   1050 <show_paths@plt>
jmp    1267 <main+0xa7>
xchg   %ax,%ax
lea    0xd1d(%rip),%rsi
mov    %rbp,%rdx
call   10c0 <sscanf@plt>
test   %rax,%rax
je     1320 <main+0x160>
mov    %rbp,%rdi
call   10b0 <show_statistics@plt>
jmp    1267 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <print_commands@plt>
jmp    1267 <main+0xa7>
lea    0xcf9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1341 <main+0x181>
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 input_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 i32
%8 = alloca [4096 x i8]
%9 = alloca [102 x i8]
%10 = alloca [51 x i8]
%11 = alloca [51 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %79
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = call i32 @read_input(i32* %21)
%23 = load i32*, i32** %6
%24 = call i32 @fclose(i32* %23)
store i32 0, i32* %7
br label %25
25: ; preds = %77, %16
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %78
28: ; preds = %25
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%30 = load i32, i32* @stdin
%31 = call i32 @fgets(i8* %29, i32 4096, i32 %30)
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %28
store i32 1, i32* %7
br label %77
36: ; preds = %28
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (...) @print_list()
br label %76
42: ; preds = %36
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %42
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%48 = getelementptr inbounds [102 x i8], [102 x i8]* %9, i64 0, i64 0
%49 = call i64 @sscanf(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = getelementptr inbounds [102 x i8], [102 x i8]* %9, i64 0, i64 0
%53 = call i32 @show_statistics(i8* %52)
br label %56
54: ; preds = %46
%55 = call i32 (...) @print_commands()
br label %56
56: ; preds = %54, %51
br label %75
57: ; preds = %42
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%59 = call i64 @strncmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %72
61: ; preds = %57
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%63 = getelementptr inbounds [102 x i8], [102 x i8]* %9, i64 0, i64 0
%64 = call i64 @sscanf(i8* %62, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = getelementptr inbounds [102 x i8], [102 x i8]* %9, i64 0, i64 0
%68 = call i32 @show_paths(i8* %67)
br label %71
69: ; preds = %61
%70 = call i32 (...) @print_commands()
br label %71
71: ; preds = %69, %66
br label %74
72: ; preds = %57
%73 = call i32 (...) @print_commands()
br label %74
74: ; preds = %72, %71
br label %75
75: ; preds = %74, %56
br label %76
76: ; preds = %75, %40
br label %77
77: ; preds = %76, %35
br label %25
78: ; preds = %25
store i32 0, i32* %3
br label %79
79: ; preds = %78, %14
%80 = load i32, i32* %3
ret i32 %80
}

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 input_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 %52
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 %52, label %20
20: ; preds = %10, %47
%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 %47
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 %35
28: ; preds = %25
%29 = call i64 @sscanf(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @show_statistics(i8* %6)
br label %47
33: ; preds = %28
%34 = call i32 (...) @print_commands()
br label %47
35: ; preds = %25
%36 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = call i64 @sscanf(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = call i32 @show_paths(i8* %6)
br label %47
43: ; preds = %38
%44 = call i32 (...) @print_commands()
br label %47
45: ; preds = %35
%46 = call i32 (...) @print_commands()
br label %47
47: ; preds = %23, %45, %43, %41, %31, %33
%48 = load i32, i32* @stdin
%49 = call i32 @fgets(i8* %5, i32 4096, i32 %48)
%50 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %20
52: ; preds = %47, %10, %8
%53 = phi i32 [ 1, %8 ], [ 0, %10 ], [ 0, %47 ]
ret i32 %53
}