#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*/ diff(char *, char *, char *);
char *extract(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ file(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ init();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void main(int argc, char *argv[]) {
  FILE *cr;
  char loc[100], *generated;
  init();
  printf("Enter the location to perform Filing (Drive or any folder): ");
  scanf("%s", loc);
  printf("\nNow Scanning %s", loc);
  generated = extract(loc);
  cr = fopen(generated, "r");
  if (!cr) {
    printf("File was not previously catalogued.\n");
    file(generated, loc);
    printf("File successfully catalogued.\n");
  } else {
    char tmpname[1000];
    strcpy(tmpname, generated);
    strcat(tmpname, ".TMP");
    file(tmpname, loc);
    diff(tmpname, generated, loc);
  }
  fclose(cr);
  free(generated);
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <init@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x80(%rbp),%rdi
call   10a0 <extract@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    125c <main+0xac>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x88(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10c0 <file@plt>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12a9 <main+0xf9>
lea    -0x470(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x470(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x470(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10c0 <file@plt>
lea    -0x470(%rbp),%rdi
mov    -0x88(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   10d0 <diff@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x458,%rsp
xor    %eax,%eax
call   1080 <init@plt>
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe61(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1090 <scanf@plt>
lea    0xe41(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   10b0 <extract@plt>
mov    %rax,%rbx
lea    0xe36(%rip),%rsi
mov    %rax,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1265 <main+0xa5>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe11(%rip),%rsi
mov    %r15,%rdi
call   10c0 <strcat@plt>
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   10d0 <file@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10e0 <diff@plt>
jmp    1288 <main+0xc8>
lea    0xde9(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   10d0 <file@plt>
lea    0xdf6(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [61 x i8] c"Enter the location to perform Filing (Drive or any folder): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"\0ANow Scanning %s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [37 x i8] c"File was not previously catalogued.\0A\00"
@.str.5 = [31 x i8] c"File successfully catalogued.\0A\00"
@.str.6 = [5 x i8] c".TMP\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [100 x i8]
%7 = alloca i8*
%8 = alloca [1000 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call i32 (...) @init()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = call i8* @extract(i8* %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %5
%19 = load i32*, i32** %5
%20 = icmp ne i32* %19, null
br i1 %20, label %27, label %21
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%23 = load i8*, i8** %7
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = call i32 @file(i8* %23, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %40
27: ; preds = %2
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%29 = load i8*, i8** %7
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%35 = call i32 @file(i8* %33, i8* %34)
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%37 = load i8*, i8** %7
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%39 = call i32 @diff(i8* %36, i8* %37, i8* %38)
br label %40
40: ; preds = %27, %21
%41 = load i32*, i32** %5
%42 = call i32 @fclose(i32* %41)
%43 = load i8*, i8** %7
%44 = call i32 @free(i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"Enter the location to perform Filing (Drive or any folder): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"\0ANow Scanning %s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.6 = [5 x i8] c".TMP\00"
@str = [36 x i8] c"File was not previously catalogued.\00"
@str.7 = [30 x i8] c"File successfully catalogued.\00"
define void @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (...) @init()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = call i8* @extract(i8* %5)
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%15 = call i32 @file(i8* %10, i8* %5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0))
br label %23
17: ; preds = %2
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* %10)
%20 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @file(i8* %18, i8* %5)
%22 = call i32 @diff(i8* %18, i8* %10, i8* %5)
br label %23
23: ; preds = %17, %13
%24 = call i32 @fclose(i32* %11)
%25 = call i32 @free(i8* %10)
ret void
}