#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 EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void uniquewords() {
  FILE *input = fopen("inputFile.txt", "r");
  char temp[32];
  char words[4096][32];
  int wordRepeats[4096];
  int uniqW = 0;
  int status;
  for (status = fscanf(input, "%s", temp); status != EOF && uniqW <= 4096;
       status = fscanf(input, "%s", temp)) {
    int unique = 1;
    temp[31] = '\0';
    for (int i = 0; i < uniqW; i++) {
      if (strcmp(temp, words[i]) == 0) {
        wordRepeats[i] = wordRepeats[i] + 1;
        unique = 0;
      }
    }
    if (unique)
      strncpy(words[uniqW++], temp, 32);
  }
  printf("There are %d different words.\n", uniqW);
}


x86 assembly (clang, -O0):
<uniquewords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x24050,%rsp
lea    0xe9e(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x24034(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe85(%rip),%rsi
call   1050 <fscanf@plt>
mov    %eax,-0x24038(%rbp)
mov    -0x24038(%rbp),%ecx
xor    %eax,%eax
mov    0x2e43(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x24041(%rbp)
je     11c6 <uniquewords+0x76>
cmpl   $0x1000,-0x24034(%rbp)
setle  %al
mov    %al,-0x24041(%rbp)
mov    -0x24041(%rbp),%al
test   $0x1,%al
jne    11d9 <uniquewords+0x89>
jmp    12cd <uniquewords+0x17d>
movl   $0x1,-0x2403c(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x24040(%rbp)
mov    -0x24040(%rbp),%eax
cmp    -0x24034(%rbp),%eax
jge    126d <uniquewords+0x11d>
lea    -0x30(%rbp),%rdi
movslq -0x24040(%rbp),%rax
lea    -0x20030(%rbp),%rsi
shl    $0x5,%rax
add    %rax,%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1254 <uniquewords+0x104>
movslq -0x24040(%rbp),%rax
mov    -0x24030(%rbp,%rax,4),%ecx
add    $0x1,%ecx
movslq -0x24040(%rbp),%rax
mov    %ecx,-0x24030(%rbp,%rax,4)
movl   $0x0,-0x2403c(%rbp)
jmp    1259 <uniquewords+0x109>
mov    -0x24040(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24040(%rbp)
jmp    11f1 <uniquewords+0xa1>
cmpl   $0x0,-0x2403c(%rbp)
je     12a9 <uniquewords+0x159>
mov    -0x24034(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x24034(%rbp)
cltq
lea    -0x20030(%rbp),%rdi
shl    $0x5,%rax
add    %rax,%rdi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
call   1030 <strncpy@plt>
jmp    12ae <uniquewords+0x15e>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xd53(%rip),%rsi
call   1050 <fscanf@plt>
mov    %eax,-0x24038(%rbp)
jmp    1196 <uniquewords+0x46>
mov    -0x24034(%rbp),%esi
lea    0xd39(%rip),%rdi
call   1040 <printf@plt>
add    $0x24050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uniquewords>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x24038,%rsp
lea    0xe98(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
lea    0xe95(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x2e54(%rip),%rcx
xor    %r15d,%r15d
cmp    (%rcx),%eax
je     1254 <uniquewords+0x104>
xor    %r15d,%r15d
lea    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
movb   $0x0,0x2f(%rsp)
test   %r15d,%r15d
jle    1205 <uniquewords+0xb5>
mov    %r15d,%ebp
mov    $0x1,%r12d
lea    0x4030(%rsp),%rbx
xor    %r14d,%r14d
jmp    11dd <uniquewords+0x8d>
add    $0x1,%r14
add    $0x20,%rbx
cmp    %r14,%rbp
je     1200 <uniquewords+0xb0>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11d0 <uniquewords+0x80>
addl   $0x1,0x30(%rsp,%r14,4)
xor    %r12d,%r12d
jmp    11d0 <uniquewords+0x80>
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     1228 <uniquewords+0xd8>
movslq %r15d,%rax
add    $0x1,%r15d
shl    $0x5,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x4030,%rdi
mov    %r13,%rsi
mov    $0x20,%edx
call   1030 <strncpy@plt>
mov    0x8(%rsp),%rdi
lea    0xddc(%rip),%rsi
mov    %r13,%rdx
call   1050 <fscanf@plt>
mov    0x2da5(%rip),%rcx
cmp    (%rcx),%eax
je     1254 <uniquewords+0x104>
cmp    $0x1001,%r15d
jl     11b0 <uniquewords+0x60>
lea    0xdb8(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
add    $0x24038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"inputFile.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i32 0
@.str.3 = [31 x i8] c"There are %d different words.\0A\00"
define void @uniquewords() {
%1 = alloca i32*
%2 = alloca [32 x i8]
%3 = alloca [4096 x [32 x i8]]
%4 = alloca [4096 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %1
store i32 0, i32* %5
%10 = load i32*, i32** %1
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%12 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
store i32 %12, i32* %6
br label %13
13: ; preds = %61, %0
%14 = load i32, i32* %6
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %5
%19 = icmp sle i32 %18, 4096
br label %20
20: ; preds = %17, %13
%21 = phi i1 [ false, %13 ], [ %19, %17 ]
br i1 %21, label %22, label %65
22: ; preds = %20
store i32 1, i32* %7
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 31
store i8 0, i8* %23
store i32 0, i32* %8
br label %24
24: ; preds = %46, %22
%25 = load i32, i32* %8
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %49
28: ; preds = %24
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4096 x [32 x i8]], [4096 x [32 x i8]]* %3, i64 0, i64 %31
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %32, i64 0, i64 0
%34 = call i64 @strcmp(i8* %29, i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %28
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4096 x i32], [4096 x i32]* %4, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4096 x i32], [4096 x i32]* %4, i64 0, i64 %43
store i32 %41, i32* %44
store i32 0, i32* %7
br label %45
45: ; preds = %36, %28
br label %46
46: ; preds = %45
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %24
49: ; preds = %24
%50 = load i32, i32* %7
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [4096 x [32 x i8]], [4096 x [32 x i8]]* %3, i64 0, i64 %55
%57 = getelementptr inbounds [32 x i8], [32 x i8]* %56, i64 0, i64 0
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%59 = call i32 @strncpy(i8* %57, i8* %58, i32 32)
br label %60
60: ; preds = %52, %49
br label %61
61: ; preds = %60
%62 = load i32*, i32** %1
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%64 = call i32 @fscanf(i32* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %63)
store i32 %64, i32* %6
br label %13
65: ; preds = %20
%66 = load i32, i32* %5
%67 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %66)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"inputFile.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i32 0
@.str.3 = [31 x i8] c"There are %d different words.\0A\00"
define void @uniquewords() {
%1 = alloca [32 x i8]
%2 = alloca [4096 x [32 x i8]]
%3 = alloca [4096 x i32]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4096 x [32 x i8]], [4096 x [32 x i8]]* %2, i64 0, i64 0, i64 0
%7 = bitcast [4096 x i32]* %3 to i8*
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %46, label %11
11: ; preds = %0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 31
br label %13
13: ; preds = %11, %39
%14 = phi i32 [ 0, %11 ], [ %40, %39 ]
store i8 0, i8* %12
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = zext i32 %14 to i64
br label %20
18: ; preds = %30
%19 = icmp eq i32 %31, 0
br i1 %19, label %39, label %34
20: ; preds = %16, %30
%21 = phi i64 [ 0, %16 ], [ %32, %30 ]
%22 = phi i32 [ 1, %16 ], [ %31, %30 ]
%23 = getelementptr inbounds [4096 x [32 x i8]], [4096 x [32 x i8]]* %2, i64 0, i64 %21, i64 0
%24 = call i64 @strcmp(i8* %5, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %21
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
br label %30
30: ; preds = %20, %26
%31 = phi i32 [ 0, %26 ], [ %22, %20 ]
%32 = add nuw nsw i64 %21, 1
%33 = icmp eq i64 %32, %17
br i1 %33, label %18, label %20
34: ; preds = %13, %18
%35 = add nsw i32 %14, 1
%36 = sext i32 %14 to i64
%37 = getelementptr inbounds [4096 x [32 x i8]], [4096 x [32 x i8]]* %2, i64 0, i64 %36, i64 0
%38 = call i32 @strncpy(i8* %37, i8* %5, i32 32)
br label %39
39: ; preds = %34, %18
%40 = phi i32 [ %35, %34 ], [ %14, %18 ]
%41 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%42 = load i32, i32* @EOF
%43 = icmp ne i32 %41, %42
%44 = icmp slt i32 %40, 4097
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %13, label %46
46: ; preds = %39, %0
%47 = phi i32 [ 0, %0 ], [ %40, %39 ]
%48 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %47)
ret void
}