#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*/ writeString;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int checkCommandExists(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileNotFound();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ formatWriteString(char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ getFilePath(char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ promptUserValue(char *, char *, int);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
scalar_t__ strcasecmp(char *, char *);
void forgetCommand() {
  char directory[100];
  getFilePath(directory, false);
  FILE *readFile;
  readFile = fopen(directory, "r");
  if (readFile == NULL) {
    fileNotFound();
  }
  char inputCommand[100];
  promptUserValue(inputCommand, "What command would you like me to forget?",
                  true);
  if (checkCommandExists(inputCommand) == true) {
    char directoryTemp[100];
    getFilePath(directoryTemp, true);
    FILE *writeFile;
    writeFile = fopen(directoryTemp, "w");
    if (writeFile == NULL) {
      printf("You haven't given me the permissions to do that :(");
      exit(1);
    }
    char tempCommand[100];
    char tempAction[100];
    char writeString[100];
    while (fscanf(readFile, "%[^\x001F]\x001F%[^\x001E]\x001E", tempCommand,
                  tempAction) != EOF) {
      if ((strcasecmp(inputCommand, tempCommand) != 0)) {
        formatWriteString(writeString, tempCommand, tempAction);
        fprintf(writeFile, "%s", writeString);
        memset(&writeString[0], 0, sizeof(writeString));
      }
    }
    fclose(readFile);
    fclose(writeFile);
    remove(directory);
    rename(directoryTemp, directory);
    printf("Forgot command\n");
  } else {
    printf("That command does not exist\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<forgetCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
call   1050 <getFilePath@plt>
lea    -0x70(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    122c <forgetCommand+0x3c>
mov    $0x0,%al
call   1100 <fileNotFound@plt>
lea    -0xe0(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0x1,%edx
call   10b0 <promptUserValue@plt>
lea    -0xe0(%rbp),%rdi
call   1110 <checkCommandExists@plt>
cmp    $0x1,%eax
jne    1383 <forgetCommand+0x193>
lea    -0x150(%rbp),%rdi
mov    $0x1,%esi
call   1050 <getFilePath@plt>
lea    -0x150(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x158(%rbp)
cmpq   $0x0,-0x158(%rbp)
jne    12a8 <forgetCommand+0xb8>
lea    0xd95(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    12ad <forgetCommand+0xbd>
mov    -0x78(%rbp),%rdi
lea    -0x1c0(%rbp),%rdx
lea    -0x230(%rbp),%rcx
lea    0xd9b(%rip),%rsi
call   1090 <fscanf@plt>
mov    0x2d16(%rip),%rcx
cmp    (%rcx),%rax
je     1344 <forgetCommand+0x154>
lea    -0xe0(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     133f <forgetCommand+0x14f>
lea    -0x2a0(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
lea    -0x230(%rbp),%rdx
call   10d0 <formatWriteString@plt>
mov    -0x158(%rbp),%rdi
lea    -0x2a0(%rbp),%rdx
lea    0xd47(%rip),%rsi
call   10a0 <fprintf@plt>
lea    -0x2a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1080 <memset@plt>
jmp    12ad <forgetCommand+0xbd>
mov    -0x78(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x158(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x70(%rbp),%rdi
call   1040 <remove@plt>
lea    -0x150(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10e0 <rename@plt>
lea    0xcf8(%rip),%rdi
call   1070 <printf@plt>
jmp    1399 <forgetCommand+0x1a9>
lea    0xcf7(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forgetCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x298,%rsp
lea    0x1c0(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <getFilePath@plt>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1241 <forgetCommand+0x41>
xor    %eax,%eax
call   1110 <fileNotFound@plt>
lea    0xdba(%rip),%rsi
lea    0x150(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
call   10c0 <promptUserValue@plt>
mov    %rbx,%rdi
call   1120 <checkCommandExists@plt>
cmp    $0x1,%eax
jne    1390 <forgetCommand+0x190>
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <getFilePath@plt>
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13a6 <forgetCommand+0x1a6>
mov    %rax,%r14
lea    0xdbc(%rip),%rsi
lea    0x70(%rsp),%rdx
mov    %rsp,%rcx
mov    %r12,%rdi
call   10b0 <fscanf@plt>
mov    0x2d2c(%rip),%rcx
cmp    (%rcx),%rax
jne    130f <forgetCommand+0x10f>
mov    %r12,%rdi
call   1070 <fclose@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
lea    0x1c0(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <remove@plt>
lea    0xe0(%rsp),%rdi
mov    %rbx,%rsi
call   10f0 <rename@plt>
lea    0xd92(%rip),%rdi
call   1060 <puts@plt>
add    $0x298,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x70(%rsp),%rbx
lea    0xd46(%rip),%r13
mov    %rsp,%rbp
lea    0x230(%rsp),%r15
jmp    1351 <forgetCommand+0x151>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   10b0 <fscanf@plt>
mov    0x2ca0(%rip),%rcx
cmp    (%rcx),%rax
je     12c1 <forgetCommand+0xc1>
lea    0x150(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1330 <forgetCommand+0x130>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10e0 <formatWriteString@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10a0 <memset@plt>
jmp    1330 <forgetCommand+0x130>
lea    0xcd7(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xc81(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [42 x i8] c"What command would you like me to forget?\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [51 x i8] c"You haven't given me the permissions to do that :(\00"
@.str.4 = [13 x i8] c"%[^\1F]\1F%[^\1E]\1E\00"
@EOF = global i64 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [16 x i8] c"Forgot command\0A\00"
@.str.7 = [29 x i8] c"That command does not exist\0A\00"
define void @forgetCommand() {
%1 = alloca [100 x i8]
%2 = alloca i32*
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32*
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 @getFilePath(i8* %9, i32 0)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (...) @fileNotFound()
br label %17
17: ; preds = %15, %0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i32 @promptUserValue(i8* %18, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 1)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i32 @checkCommandExists(i8* %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %68
23: ; preds = %17
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i32 @getFilePath(i8* %24, i32 1)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %5
%28 = load i32*, i32** %5
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %23
br label %34
34: ; preds = %56, %33
%35 = load i32*, i32** %2
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%38 = call i64 @fscanf(i32* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %36, i8* %37)
%39 = load i64, i64* @EOF
%40 = icmp ne i64 %38, %39
br i1 %40, label %41, label %57
41: ; preds = %34
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%44 = call i64 @strcasecmp(i8* %42, i8* %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %41
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%50 = call i32 @formatWriteString(i8* %47, i8* %48, i8* %49)
%51 = load i32*, i32** %5
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%53 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%55 = call i32 @memset(i8* %54, i32 0, i32 100)
br label %56
56: ; preds = %46, %41
br label %34
57: ; preds = %34
%58 = load i32*, i32** %2
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %5
%61 = call i32 @fclose(i32* %60)
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%63 = call i32 @remove(i8* %62)
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%66 = call i32 @rename(i8* %64, i8* %65)
%67 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %71
68: ; preds = %17
%69 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %57
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [42 x i8] c"What command would you like me to forget?\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [51 x i8] c"You haven't given me the permissions to do that :(\00"
@.str.4 = [13 x i8] c"%[^\1F]\1F%[^\1E]\1E\00"
@EOF = global i64 0
@str = [28 x i8] c"That command does not exist\00"
@str.8 = [15 x i8] c"Forgot command\00"
define void @forgetCommand() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = call i32 @getFilePath(i8* %7, i32 0)
%9 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (...) @fileNotFound()
br label %13
13: ; preds = %11, %0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @promptUserValue(i8* %14, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 1)
%16 = call i32 @checkCommandExists(i8* %14)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %50
18: ; preds = %13
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = call i32 @getFilePath(i8* %19, i32 1)
%21 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %18
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%30 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* %28)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %44, label %33
33: ; preds = %26, %40
%34 = call i64 @strcasecmp(i8* %14, i8* %27)
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %33
%37 = call i32 @formatWriteString(i8* %29, i8* %27, i8* %28)
%38 = call i32 @fputs(i8* %29, i32* %21)
%39 = call i32 @memset(i8* %29, i32 0, i32 100)
br label %40
40: ; preds = %36, %33
%41 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* %28)
%42 = load i64, i64* @EOF
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %33
44: ; preds = %40, %26
%45 = call i32 @fclose(i32* %9)
%46 = call i32 @fclose(i32* %21)
%47 = call i32 @remove(i8* %7)
%48 = call i32 @rename(i8* %19, i8* %7)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
ret void
50: ; preds = %13
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
}