#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fs_create(char *, int);
int /*<<< orphan*/ fs_delete(char *, int);
int /*<<< orphan*/ fs_exit();
int /*<<< orphan*/ fs_find(char *);
int /*<<< orphan*/ fs_init();
int /*<<< orphan*/ fs_read(char *);
int /*<<< orphan*/ fs_write(char *, char *);
int getdelims(char **, char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
char *strtok(char *, char *);
int main(void) {
  char *line, *cmd, *arg, *str;
  int chars_read;
  bool done;
  fs_init();
  done = false;
  while (!done) {
    chars_read = getdelims(&line, "\r\n", stdin);
    if (chars_read == 0) {
      free(line);
      continue;
    }
    if (chars_read == -1) {
      free(line);
      break;
    }
    cmd = strtok(line, " \t");
    arg = strtok(NULL, " \t\r\n");
    switch (cmd[0]) {
    case 'c':
      fs_create(arg, (bool)cmd[6]);
      break;
    case 'd':
      fs_delete(arg, (bool)cmd[6]);
      break;
    case 'r':
      fs_read(arg);
      break;
    case 'w':
      str = strtok(NULL, "\r\n");
      if (str != NULL) {
        str = strchr(str, '"');
        str = strtok(str, "\"");
      }
      fs_write(arg, str);
      break;
    case 'f':
      fs_find(arg);
      break;
    case 'e':
      done = true;
      fs_exit();
      break;
    }
    free(line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <fs_init@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e3 <main+0x33>
jmp    133f <main+0x18f>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1050 <getdelims@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1217 <main+0x67>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    11cd <main+0x1d>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    122f <main+0x7f>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    133f <main+0x18f>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    0xe0d(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x14,%eax
ja     1331 <main+0x181>
mov    -0x38(%rbp),%rax
lea    0xd85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl 0x6(%rax),%esi
call   1060 <fs_create@plt>
jmp    1331 <main+0x181>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl 0x6(%rax),%esi
call   10c0 <fs_delete@plt>
jmp    1331 <main+0x181>
mov    -0x20(%rbp),%rdi
call   1090 <fs_read@plt>
jmp    1331 <main+0x181>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd90(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1303 <main+0x153>
mov    -0x28(%rbp),%rdi
mov    $0x22,%esi
call   1080 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd62(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10b0 <fs_write@plt>
jmp    1331 <main+0x181>
mov    -0x20(%rbp),%rdi
call   1030 <fs_find@plt>
jmp    1331 <main+0x181>
movl   $0x1,-0x30(%rbp)
mov    $0x0,%al
call   1070 <fs_exit@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    11cd <main+0x1d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <fs_init@plt>
mov    0x2e1f(%rip),%r12
lea    0xe89(%rip),%rbx
mov    %rsp,%r14
jmp    1201 <main+0x51>
xor    %eax,%eax
call   1070 <fs_exit@plt>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
call   1040 <free@plt>
test   %ebp,%ebp
jne    12e5 <main+0x135>
mov    (%r12),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <getdelims@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11f0 <main+0x40>
cmp    $0xffffffff,%ebp
je     12dc <main+0x12c>
mov    (%rsp),%rdi
lea    0xe2a(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,%r15
xor    %ebp,%ebp
xor    %edi,%edi
lea    0xe1a(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,%r13
movsbl (%r15),%eax
add    $0xffffff9d,%eax
cmp    $0x14,%eax
ja     11f0 <main+0x40>
lea    0xda8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl 0x6(%r15),%esi
mov    %r13,%rdi
call   1060 <fs_create@plt>
jmp    11f0 <main+0x40>
movsbl 0x6(%r15),%esi
mov    %r13,%rdi
call   10c0 <fs_delete@plt>
jmp    11f0 <main+0x40>
mov    %r13,%rdi
call   1030 <fs_find@plt>
jmp    11f0 <main+0x40>
mov    %r13,%rdi
call   1090 <fs_read@plt>
jmp    11f0 <main+0x40>
xor    %edi,%edi
mov    %rbx,%rsi
call   10d0 <strtok@plt>
mov    $0x0,%esi
test   %rax,%rax
je     12cf <main+0x11f>
mov    %rax,%rdi
mov    $0x22,%esi
call   1080 <strchr@plt>
mov    %rax,%rdi
lea    0xd95(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,%rsi
mov    %r13,%rdi
call   10b0 <fs_write@plt>
jmp    11f0 <main+0x40>
mov    (%rsp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c" \09\00"
@.str.2 = [5 x i8] c" \09\0D\0A\00"
@.str.3 = [2 x i8] c"\22\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @fs_init()
store i32 0, i32* %7
br label %9
9: ; preds = %70, %18, %0
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %73
13: ; preds = %9
%14 = load i32, i32* @stdin
%15 = call i32 @getdelims(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @free(i8* %19)
br label %9
21: ; preds = %13
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = call i32 @free(i8* %25)
br label %73
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = call i8* @strtok(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %3
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %30, i8** %4
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
switch i32 %34, label %70 [
i32 99, label %35
i32 100, label %42
i32 114, label %49
i32 119, label %52
i32 102, label %65
i32 101, label %68
]
35: ; preds = %27
%36 = load i8*, i8** %4
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 @fs_create(i8* %36, i32 %40)
br label %70
42: ; preds = %27
%43 = load i8*, i8** %4
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 6
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 @fs_delete(i8* %43, i32 %47)
br label %70
49: ; preds = %27
%50 = load i8*, i8** %4
%51 = call i32 @fs_read(i8* %50)
br label %70
52: ; preds = %27
%53 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %53, i8** %5
%54 = load i8*, i8** %5
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8*, i8** %5
%58 = call i8* @strchr(i8* %57, i8 signext 34)
store i8* %58, i8** %5
%59 = load i8*, i8** %5
%60 = call i8* @strtok(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %60, i8** %5
br label %61
61: ; preds = %56, %52
%62 = load i8*, i8** %4
%63 = load i8*, i8** %5
%64 = call i32 @fs_write(i8* %62, i8* %63)
br label %70
65: ; preds = %27
%66 = load i8*, i8** %4
%67 = call i32 @fs_find(i8* %66)
br label %70
68: ; preds = %27
store i32 1, i32* %7
%69 = call i32 (...) @fs_exit()
br label %70
70: ; preds = %27, %68, %65, %61, %49, %42, %35
%71 = load i8*, i8** %2
%72 = call i32 @free(i8* %71)
br label %9
73: ; preds = %24, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c" \09\00"
@.str.2 = [5 x i8] c" \09\0D\0A\00"
@.str.3 = [2 x i8] c"\22\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (...) @fs_init()
br label %4
4: ; preds = %0, %7
%5 = load i32, i32* @stdin
%6 = call i32 @getdelims(i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
switch i32 %6, label %15 [
i32 0, label %7
i32 -1, label %12
]
7: ; preds = %21, %26, %31, %39, %42, %44, %15, %4
%8 = phi i32 [ %6, %4 ], [ 0, %15 ], [ 1, %44 ], [ 0, %42 ], [ 0, %39 ], [ 0, %31 ], [ 0, %26 ], [ 0, %21 ]
%9 = load i8*, i8** %1
%10 = call i32 @free(i8* %9)
%11 = icmp eq i32 %8, 0
br i1 %11, label %4, label %46
12: ; preds = %4
%13 = load i8*, i8** %1
%14 = call i32 @free(i8* %13)
br label %46
15: ; preds = %4
%16 = load i8*, i8** %1
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
switch i32 %20, label %7 [
i32 99, label %21
i32 100, label %26
i32 114, label %31
i32 119, label %33
i32 102, label %42
i32 101, label %44
]
21: ; preds = %15
%22 = getelementptr inbounds i8, i8* %17, i64 6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 @fs_create(i8* %18, i32 %24)
br label %7
26: ; preds = %15
%27 = getelementptr inbounds i8, i8* %17, i64 6
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 @fs_delete(i8* %18, i32 %29)
br label %7
31: ; preds = %15
%32 = call i32 @fs_read(i8* %18)
br label %7
33: ; preds = %15
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = call i8* @strchr(i8* %34, i8 signext 34)
%38 = call i8* @strtok(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
%40 = phi i8* [ %38, %36 ], [ null, %33 ]
%41 = call i32 @fs_write(i8* %18, i8* %40)
br label %7
42: ; preds = %15
%43 = call i32 @fs_find(i8* %18)
br label %7
44: ; preds = %15
%45 = call i32 (...) @fs_exit()
br label %7
46: ; preds = %7, %12
ret i32 0
}