#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 */
struct node {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ PrintWords(struct node *);
struct node *addnode(struct node *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char filename[100];
  struct node *root;
  char word[100];
  int linenumber;
  int i;
  char string[100];
  char name[100];
  char lastname[100];
  char funnyname[100];
  int a, b, c;
  fp = fopen(filename, "r");
  fp = fopen("D:/test.txt", "r");
  if (fp == NULL) {
    printf("Error: Couldn't open file\n");
    return -1;
  } else {
    linenumber = 1;
    root = NULL;
    for (i = 0; fscanf(fp, "%s\n", word) != EOF; i++) {
      root = addnode(root, word);
    }
    PrintWords(root);
    fclose(fp);
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe5e(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d7 <main+0x67>
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126e <main+0xfe>
movl   $0x1,-0xf4(%rbp)
movq   $0x0,-0x88(%rbp)
movl   $0x0,-0xf8(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xe21(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%rax
je     124b <main+0xdb>
mov    -0x88(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <addnode@plt>
mov    %rax,-0x88(%rbp)
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    11f6 <main+0x86>
mov    -0x88(%rbp),%rdi
call   1080 <PrintWords@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe78(%rip),%rbx
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1090 <fopen@plt>
lea    0xe66(%rip),%rdi
mov    %rbx,%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11d2 <main+0x62>
mov    %rax,%r15
lea    0xe5b(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0x2e23(%rip),%rbp
xor    %r14d,%r14d
cmp    0x0(%rbp),%rax
jne    11e6 <main+0x76>
xor    %ebx,%ebx
jmp    1222 <main+0xb2>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
jmp    1239 <main+0xc9>
xor    %ebx,%ebx
mov    %rsp,%r12
lea    0xe1c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <addnode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
cmp    0x0(%rbp),%rax
jne    1200 <main+0x90>
mov    %rbx,%rdi
call   1080 <PrintWords@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r14d,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"D:/test.txt\00"
@.str.2 = [27 x i8] c"Error: Couldn't open file\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [100 x i8]
%8 = alloca %struct.node*
%9 = alloca [100 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [100 x i8]
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca [100 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %47
26: ; preds = %2
store i32 1, i32* %10
store %struct.node* null, %struct.node** %8
store i32 0, i32* %11
br label %27
27: ; preds = %37, %26
%28 = load i32*, i32** %6
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%30 = call i64 @fscanf(i32* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i64, i64* @EOF
%32 = icmp ne i64 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = load %struct.node*, %struct.node** %8
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%36 = call %struct.node* @addnode(%struct.node* %34, i8* %35)
store %struct.node* %36, %struct.node** %8
br label %37
37: ; preds = %33
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %27
40: ; preds = %27
%41 = load %struct.node*, %struct.node** %8
%42 = call i32 @PrintWords(%struct.node* %41)
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %40
%46 = call i32 (...) @getchar()
store i32 0, i32* %3
br label %47
47: ; preds = %45, %24
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"D:/test.txt\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@EOF = global i64 0
@str = [26 x i8] c"Error: Couldn't open file\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %22, label %16
14: ; preds = %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %27
16: ; preds = %10, %16
%17 = phi %struct.node* [ %18, %16 ], [ null, %10 ]
%18 = call %struct.node* @addnode(%struct.node* %17, i8* %6)
%19 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %16
22: ; preds = %16, %10
%23 = phi %struct.node* [ null, %10 ], [ %18, %16 ]
%24 = call i32 @PrintWords(%struct.node* %23)
%25 = call i32 @fclose(i32* %8)
%26 = call i32 (...) @getchar()
br label %27
27: ; preds = %22, %14
%28 = phi i32 [ -1, %14 ], [ 0, %22 ]
ret i32 %28
}