#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ getFilePath(char *, int);
scalar_t__ strcasecmp(char *, char *);
bool checkCommandExists(char *inputCommand) {
  if (strcasecmp(inputCommand, "learn command") == 0) {
    return true;
  } else {
    char directory[100];
    getFilePath(directory, false);
    FILE *commandFile;
    commandFile = fopen(directory, "r");
    char command[100];
    while (fscanf(commandFile, "%[^\x001F]\x001F%*[^\x001E]\x001E", command) !=
           EOF) {
      if (strcasecmp(inputCommand, command) == 0) {
        fclose(commandFile);
        return true;
      }
    }
    fclose(commandFile);
    return false;
  }
}


x86 assembly (clang, -O0):
<checkCommandExists>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1185 <checkCommandExists+0x35>
movl   $0x1,-0x4(%rbp)
jmp    121b <checkCommandExists+0xcb>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
call   1040 <getFilePath@plt>
lea    -0x80(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xe54(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%rax
je     1208 <checkCommandExists+0xb8>
mov    -0x10(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1203 <checkCommandExists+0xb3>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    121b <checkCommandExists+0xcb>
jmp    11a7 <checkCommandExists+0x57>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkCommandExists>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rdi,%r12
lea    0xe95(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11e4 <checkCommandExists+0x94>
lea    0x70(%rsp),%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <getFilePath@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbp
lea    0xe70(%rip),%r15
mov    %rsp,%rbx
mov    0x2e3e(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%r13),%rax
je     11da <checkCommandExists+0x8a>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11b0 <checkCommandExists+0x60>
mov    $0x1,%r14d
mov    %rbp,%rdi
call   1050 <fclose@plt>
jmp    11ea <checkCommandExists+0x9a>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"learn command\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%[^\1F]\1F%*[^\1E]\1E\00"
@EOF = global i64 0
define i32 @checkCommandExists(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [100 x i8]
%5 = alloca i32*
%6 = alloca [100 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %34
11: ; preds = %1
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = call i32 @getFilePath(i8* %12, i32 0)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %5
br label %16
16: ; preds = %30, %11
%17 = load i32*, i32** %5
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = call i64 @strcasecmp(i8* %23, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32*, i32** %5
%29 = call i32 @fclose(i32* %28)
store i32 1, i32* %2
br label %34
30: ; preds = %22
br label %16
31: ; preds = %16
%32 = load i32*, i32** %5
%33 = call i32 @fclose(i32* %32)
store i32 0, i32* %2
br label %34
34: ; preds = %31, %27, %10
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [14 x i8] c"learn command\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%[^\1F]\1F%*[^\1E]\1E\00"
@EOF = global i64 0
define i32 @checkCommandExists(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %1
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, 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.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %11
11: ; preds = %15, %6
%12 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = call i64 @strcasecmp(i8* %0, i8* %10)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %11
18: ; preds = %11, %15
%19 = phi i32 [ 1, %15 ], [ 0, %11 ]
%20 = call i32 @fclose(i32* %9)
br label %21
21: ; preds = %1, %18
%22 = phi i32 [ %19, %18 ], [ 1, %1 ]
ret i32 %22
}