#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*/ EXIT_FAILURE;
scalar_t__ exists(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ is_dir(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ terminate(char *);
void check_inverted_index_file(char *inverted_index_file) {
  if (exists(inverted_index_file)) {
    if (is_dir(inverted_index_file)) {
      terminate("The given inverted-index file already exists as a directory.");
    } else {
      char c;
      printf("%s already existed. Do you wanna overwrite it? [Y|n]\n",
             inverted_index_file);
      scanf("%c", &c);
      if (c != 'Y' && c != 'y') {
        printf("Abort\n");
        exit(EXIT_FAILURE);
      }
    }
  }
}


x86 assembly (clang, -O0):
<check_inverted_index_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <exists@plt>
cmp    $0x0,%rax
je     1205 <check_inverted_index_file+0xa5>
mov    -0x8(%rbp),%rdi
call   1040 <is_dir@plt>
cmp    $0x0,%rax
je     11a3 <check_inverted_index_file+0x43>
lea    0xe67(%rip),%rdi
call   1050 <terminate@plt>
jmp    1200 <check_inverted_index_file+0xa0>
mov    -0x8(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x59,%eax
je     11fb <check_inverted_index_file+0x9b>
movsbl -0x9(%rbp),%eax
cmp    $0x79,%eax
je     11fb <check_inverted_index_file+0x9b>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1200 <check_inverted_index_file+0xa0>
jmp    1205 <check_inverted_index_file+0xa5>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_inverted_index_file>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1080 <exists@plt>
test   %rax,%rax
je     11cc <check_inverted_index_file+0x5c>
mov    %rbx,%rdi
call   1050 <is_dir@plt>
test   %rax,%rax
je     11a0 <check_inverted_index_file+0x30>
lea    0xe6a(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1060 <terminate@plt>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xf(%rsp),%al
and    $0xdf,%al
cmp    $0x59,%al
jne    11d2 <check_inverted_index_file+0x62>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [61 x i8] c"The given inverted-index file already exists as a directory.\00"
@.str.1 = [54 x i8] c"%s already existed. Do you wanna overwrite it? [Y|n]\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [7 x i8] c"Abort\0A\00"
@EXIT_FAILURE = global i32 0
define void @check_inverted_index_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @exists(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %30
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i64 @is_dir(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @terminate(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %29
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 89
br i1 %19, label %20, label %28
20: ; preds = %13
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 121
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %20, %13
br label %29
29: ; preds = %28, %11
br label %30
30: ; preds = %29, %1
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"The given inverted-index file already exists as a directory.\00"
@.str.1 = [54 x i8] c"%s already existed. Do you wanna overwrite it? [Y|n]\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@EXIT_FAILURE = global i32 0
@str = [6 x i8] c"Abort\00"
define void @check_inverted_index_file(i8* %0) {
%2 = alloca i8
%3 = tail call i64 @exists(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = tail call i64 @is_dir(i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @terminate(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %21
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = and i8 %13, -33
%15 = icmp eq i8 %14, 89
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %10
br label %21
21: ; preds = %8, %20, %1
ret void
}