#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_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printCommands();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ remove(char *);
scalar_t__ rename(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ undefinedCommandMsg();
void runCommand(int tokensCount, char tokens[][40]) {
  if (tokensCount == 1) {
    if (strcmp(tokens[0], "help") == 0) {
      printCommands();
    } else if (strcmp(tokens[0], "quit") == 0) {
      exit(EXIT_SUCCESS);
    } else {
      undefinedCommandMsg();
    }
  } else if (tokensCount == 2) {
    if (strcmp(tokens[0], "remove") == 0) {
      if (remove(tokens[1])) {
        printf("  Error when removing file.\n\n");
      } else {
        printf("  File '%s' removed.\n\n", tokens[1]);
      }
    } else if (strcmp(tokens[0], "create") == 0) {
      FILE *file = fopen(tokens[1], "w");
      if (file == NULL) {
        printf("  Error when creating file.\n\n");
      } else {
        printf("  File '%s' created.\n\n", tokens[1]);
      }
      fclose(file);
    } else {
      undefinedCommandMsg();
    }
  } else if (tokensCount == 3) {
    if (strcmp(tokens[0], "rename") == 0) {
      if (rename(tokens[1], tokens[2])) {
        printf("  Error when renaming file.\n\n");
      } else {
        printf("  File '%s' was renamed to '%s'.\n\n", tokens[1], tokens[2]);
      }
    } else {
      undefinedCommandMsg();
    }
  }
}


x86 assembly (clang, -O0):
<runCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1208 <runCommand+0x78>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11cf <runCommand+0x3f>
mov    $0x0,%al
call   1060 <printCommands@plt>
jmp    1203 <runCommand+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <runCommand+0x67>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   1080 <undefinedCommandMsg@plt>
jmp    1203 <runCommand+0x73>
jmp    1385 <runCommand+0x1f5>
cmpl   $0x2,-0x4(%rbp)
jne    12f6 <runCommand+0x166>
mov    -0x10(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1271 <runCommand+0xe1>
mov    -0x10(%rbp),%rdi
add    $0x28,%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
je     1256 <runCommand+0xc6>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    126c <runCommand+0xdc>
mov    -0x10(%rbp),%rsi
add    $0x28,%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12f1 <runCommand+0x161>
mov    -0x10(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12e5 <runCommand+0x155>
mov    -0x10(%rbp),%rdi
add    $0x28,%rdi
lea    0xdb3(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12c1 <runCommand+0x131>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12d7 <runCommand+0x147>
mov    -0x10(%rbp),%rsi
add    $0x28,%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12ec <runCommand+0x15c>
mov    $0x0,%al
call   1080 <undefinedCommandMsg@plt>
jmp    12f1 <runCommand+0x161>
jmp    1380 <runCommand+0x1f0>
cmpl   $0x3,-0x4(%rbp)
jne    137b <runCommand+0x1eb>
mov    -0x10(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    136f <runCommand+0x1df>
mov    -0x10(%rbp),%rdi
add    $0x28,%rdi
mov    -0x10(%rbp),%rsi
add    $0x50,%rsi
call   10a0 <rename@plt>
cmp    $0x0,%rax
je     134c <runCommand+0x1bc>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    136a <runCommand+0x1da>
mov    -0x10(%rbp),%rsi
add    $0x28,%rsi
mov    -0x10(%rbp),%rdx
add    $0x50,%rdx
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1376 <runCommand+0x1e6>
mov    $0x0,%al
call   1080 <undefinedCommandMsg@plt>
jmp    137b <runCommand+0x1eb>
jmp    1380 <runCommand+0x1f0>
jmp    1385 <runCommand+0x1f5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runCommand>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
je     11f4 <runCommand+0x54>
cmp    $0x2,%edi
je     122d <runCommand+0x8d>
cmp    $0x1,%edi
jne    1263 <runCommand+0xc3>
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     126b <runCommand+0xcb>
lea    0xe2c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1255 <runCommand+0xb5>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1255 <runCommand+0xb5>
lea    0x28(%rbx),%r14
add    $0x50,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <rename@plt>
test   %rax,%rax
je     12cb <runCommand+0x12b>
lea    0xe47(%rip),%rdi
jmp    1291 <runCommand+0xf1>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1279 <runCommand+0xd9>
lea    0xde0(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     129d <runCommand+0xfd>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <undefinedCommandMsg@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <printCommands@plt>
add    $0x28,%rbx
mov    %rbx,%rdi
call   1030 <remove@plt>
test   %rax,%rax
je     12e6 <runCommand+0x146>
lea    0xe1b(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>
add    $0x28,%rbx
lea    0xd87(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     12fe <runCommand+0x15e>
lea    0xd72(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    130a <runCommand+0x16a>
lea    0xd7d(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printf@plt>
lea    0xd24(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printf@plt>
lea    0xd8a(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"quit\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [7 x i8] c"remove\00"
@.str.3 = [30 x i8] c" Error when removing file.\0A\0A\00"
@.str.4 = [23 x i8] c" File '%s' removed.\0A\0A\00"
@.str.5 = [7 x i8] c"create\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [30 x i8] c" Error when creating file.\0A\0A\00"
@.str.8 = [23 x i8] c" File '%s' created.\0A\0A\00"
@.str.9 = [7 x i8] c"rename\00"
@.str.10 = [30 x i8] c" Error when renaming file.\0A\0A\00"
@.str.11 = [35 x i8] c" File '%s' was renamed to '%s'.\0A\0A\00"
define void @runCommand(i32 %0, [40 x i8]* %1) {
%3 = alloca i32
%4 = alloca [40 x i8]*
%5 = alloca i32*
store i32 %0, i32* %3
store [40 x i8]* %1, [40 x i8]** %4
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %29
8: ; preds = %2
%9 = load [40 x i8]*, [40 x i8]** %4
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %9, i64 0
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 (...) @printCommands()
br label %28
16: ; preds = %8
%17 = load [40 x i8]*, [40 x i8]** %4
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0
%19 = getelementptr inbounds [40 x i8], [40 x i8]* %18, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = call i32 (...) @undefinedCommandMsg()
br label %27
27: ; preds = %25
br label %28
28: ; preds = %27, %14
br label %113
29: ; preds = %2
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %79
32: ; preds = %29
%33 = load [40 x i8]*, [40 x i8]** %4
%34 = getelementptr inbounds [40 x i8], [40 x i8]* %33, i64 0
%35 = getelementptr inbounds [40 x i8], [40 x i8]* %34, i64 0, i64 0
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %52
38: ; preds = %32
%39 = load [40 x i8]*, [40 x i8]** %4
%40 = getelementptr inbounds [40 x i8], [40 x i8]* %39, i64 1
%41 = getelementptr inbounds [40 x i8], [40 x i8]* %40, i64 0, i64 0
%42 = call i64 @remove(i8* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %51
46: ; preds = %38
%47 = load [40 x i8]*, [40 x i8]** %4
%48 = getelementptr inbounds [40 x i8], [40 x i8]* %47, i64 1
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %48, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %46, %44
br label %78
52: ; preds = %32
%53 = load [40 x i8]*, [40 x i8]** %4
%54 = getelementptr inbounds [40 x i8], [40 x i8]* %53, i64 0
%55 = getelementptr inbounds [40 x i8], [40 x i8]* %54, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %75
58: ; preds = %52
%59 = load [40 x i8]*, [40 x i8]** %4
%60 = getelementptr inbounds [40 x i8], [40 x i8]* %59, i64 1
%61 = getelementptr inbounds [40 x i8], [40 x i8]* %60, i64 0, i64 0
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %62, i32** %5
%63 = load i32*, i32** %5
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %67
65: ; preds = %58
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %72
67: ; preds = %58
%68 = load [40 x i8]*, [40 x i8]** %4
%69 = getelementptr inbounds [40 x i8], [40 x i8]* %68, i64 1
%70 = getelementptr inbounds [40 x i8], [40 x i8]* %69, i64 0, i64 0
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %67, %65
%73 = load i32*, i32** %5
%74 = call i32 @fclose(i32* %73)
br label %77
75: ; preds = %52
%76 = call i32 (...) @undefinedCommandMsg()
br label %77
77: ; preds = %75, %72
br label %78
78: ; preds = %77, %51
br label %112
79: ; preds = %29
%80 = load i32, i32* %3
%81 = icmp eq i32 %80, 3
br i1 %81, label %82, label %111
82: ; preds = %79
%83 = load [40 x i8]*, [40 x i8]** %4
%84 = getelementptr inbounds [40 x i8], [40 x i8]* %83, i64 0
%85 = getelementptr inbounds [40 x i8], [40 x i8]* %84, i64 0, i64 0
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %108
88: ; preds = %82
%89 = load [40 x i8]*, [40 x i8]** %4
%90 = getelementptr inbounds [40 x i8], [40 x i8]* %89, i64 1
%91 = getelementptr inbounds [40 x i8], [40 x i8]* %90, i64 0, i64 0
%92 = load [40 x i8]*, [40 x i8]** %4
%93 = getelementptr inbounds [40 x i8], [40 x i8]* %92, i64 2
%94 = getelementptr inbounds [40 x i8], [40 x i8]* %93, i64 0, i64 0
%95 = call i64 @rename(i8* %91, i8* %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %99
97: ; preds = %88
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
br label %107
99: ; preds = %88
%100 = load [40 x i8]*, [40 x i8]** %4
%101 = getelementptr inbounds [40 x i8], [40 x i8]* %100, i64 1
%102 = getelementptr inbounds [40 x i8], [40 x i8]* %101, i64 0, i64 0
%103 = load [40 x i8]*, [40 x i8]** %4
%104 = getelementptr inbounds [40 x i8], [40 x i8]* %103, i64 2
%105 = getelementptr inbounds [40 x i8], [40 x i8]* %104, i64 0, i64 0
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i8* %102, i8* %105)
br label %107
107: ; preds = %99, %97
br label %110
108: ; preds = %82
%109 = call i32 (...) @undefinedCommandMsg()
br label %110
110: ; preds = %108, %107
br label %111
111: ; preds = %110, %79
br label %112
112: ; preds = %111, %78
br label %113
113: ; preds = %112, %28
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"quit\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [7 x i8] c"remove\00"
@.str.4 = [23 x i8] c" File '%s' removed.\0A\0A\00"
@.str.5 = [7 x i8] c"create\00"
@.str.6 = [2 x i8] c"w\00"
@.str.8 = [23 x i8] c" File '%s' created.\0A\0A\00"
@.str.9 = [7 x i8] c"rename\00"
@.str.11 = [35 x i8] c" File '%s' was renamed to '%s'.\0A\0A\00"
@str = [29 x i8] c" Error when renaming file.\0A\00"
@str.12 = [29 x i8] c" Error when creating file.\0A\00"
@str.13 = [29 x i8] c" Error when removing file.\0A\00"
define void @runCommand(i32 %0, [40 x i8]* %1) {
switch i32 %0, label %59 [
i32 1, label %3
i32 2, label %17
i32 3, label %44
]
3: ; preds = %2
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%5 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (...) @printCommands()
br label %59
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @EXIT_SUCCESS
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %9
%16 = tail call i32 (...) @undefinedCommandMsg()
br label %59
17: ; preds = %2
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 1, i64 0
%23 = tail call i64 @remove(i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.13, i64 0, i64 0))
br label %59
27: ; preds = %21
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %22)
br label %59
29: ; preds = %17
%30 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 1, i64 0
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
br label %40
38: ; preds = %32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %33)
br label %40
40: ; preds = %38, %36
%41 = tail call i32 @fclose(i32* %34)
br label %59
42: ; preds = %29
%43 = tail call i32 (...) @undefinedCommandMsg()
br label %59
44: ; preds = %2
%45 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%46 = tail call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 1, i64 0
%50 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 2, i64 0
%51 = tail call i64 @rename(i8* %49, i8* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %48
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %59
55: ; preds = %48
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i8* %49, i8* %50)
br label %59
57: ; preds = %44
%58 = tail call i32 (...) @undefinedCommandMsg()
br label %59
59: ; preds = %2, %40, %42, %25, %27, %57, %55, %53, %7, %15
ret void
}