#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 wordtree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ *GetLine(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ NoiseWord(char *);
int /*<<< orphan*/ *addword(struct wordtree **, char *, int);
int /*<<< orphan*/ deleteword(struct wordtree **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printtree(struct wordtree *);
int /*<<< orphan*/ stdin;
char *tokenise(char **, char *);
int main(void) {
  static char buffer[8192] = {0};
  char *s = NULL;
  char *word = NULL;
  int line = 0;
  int giveup = 0;
  struct wordtree *tree = NULL;
  char *delims = " \t\n\r\a\f\v!\"%^&*()_=+{}[]\\|/,.<>:;#~?";
  while (!giveup && GetLine(buffer, sizeof buffer, stdin) != NULL) {
    ++line;
    s = buffer;
    while (!giveup && (word = tokenise(&s, delims)) != NULL) {
      if (!NoiseWord(word)) {
        if (NULL == addword(&tree, word, line)) {
          printf("Error adding data into memory. Giving up.\n");
          giveup = 1;
        }
      }
    }
  }
  if (!giveup) {
    printf("%18s  Line Numbers\n", "Word");
    printtree(tree);
  }
  deleteword(&tree);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe54(%rip),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x20(%rbp)
mov    %al,-0x31(%rbp)
jne    11e3 <main+0x73>
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
lea    0x2ea1(%rip),%rdi
mov    $0x2000,%esi
call   1030 <GetLine@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11f3 <main+0x83>
jmp    1295 <main+0x125>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0x2e6d(%rip),%rax
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x20(%rbp)
mov    %al,-0x32(%rbp)
jne    1231 <main+0xc1>
mov    -0x30(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1070 <tokenise@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    1241 <main+0xd1>
jmp    1290 <main+0x120>
mov    -0x18(%rbp),%rdi
call   1090 <NoiseWord@plt>
cmp    $0x0,%eax
jne    128b <main+0x11b>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x28(%rbp),%rdi
call   1050 <addword@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1286 <main+0x116>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x20(%rbp)
jmp    128b <main+0x11b>
jmp    1207 <main+0x97>
jmp    11b0 <main+0x40>
cmpl   $0x0,-0x20(%rbp)
jne    12bd <main+0x14d>
lea    0xda8(%rip),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <printtree@plt>
lea    -0x28(%rbp),%rdi
call   1080 <deleteword@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
lea    0x2ec0(%rip),%r14
mov    %r14,%rdi
mov    $0x2000,%esi
call   1040 <GetLine@plt>
test   %rax,%rax
je     1260 <main+0xe0>
xor    %r15d,%r15d
lea    0xe30(%rip),%r13
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%r12
jmp    11fb <main+0x7b>
nopl   0x0(%rax)
mov    0x2e01(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x2000,%esi
call   1040 <GetLine@plt>
test   %rax,%rax
je     1260 <main+0xe0>
add    $0x1,%r15d
mov    %r14,0x10(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1080 <tokenise@plt>
test   %rax,%rax
je     11e0 <main+0x60>
mov    %rax,%rbx
jmp    1233 <main+0xb3>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1080 <tokenise@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11e0 <main+0x60>
mov    %rbx,%rdi
call   10a0 <NoiseWord@plt>
test   %eax,%eax
jne    1220 <main+0xa0>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1060 <addword@plt>
test   %rax,%rax
jne    1220 <main+0xa0>
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
jmp    127f <main+0xff>
lea    0xdbc(%rip),%rdi
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1070 <printtree@plt>
lea    0x8(%rsp),%rdi
call   1090 <deleteword@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.wordtree = type { i32 }
@main.buffer = internal global [8192 x i8] zeroinitializer
@.str = [35 x i8] c" \09\0A\0D\07\0C\0B!\22%^&*()_=+{}[]\\|/,.<>:;#~?\00"
@stdin = global i32 0
@.str.1 = [43 x i8] c"Error adding data into memory. Giving up.\0A\00"
@.str.2 = [20 x i8] c"%18s Line Numbers\0A\00"
@.str.3 = [5 x i8] c"Word\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.wordtree*
%7 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store %struct.wordtree* null, %struct.wordtree** %6
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8** %7
br label %8
8: ; preds = %42, %0
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stdin
%13 = call i32* @GetLine(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buffer, i64 0, i64 0), i32 8192, i32 %12)
%14 = icmp ne i32* %13, null
br label %15
15: ; preds = %11, %8
%16 = phi i1 [ false, %8 ], [ %14, %11 ]
br i1 %16, label %17, label %43
17: ; preds = %15
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
store i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buffer, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %41, %17
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = call i8* @tokenise(i8** %2, i8* %24)
store i8* %25, i8** %3
%26 = icmp ne i8* %25, null
br label %27
27: ; preds = %23, %20
%28 = phi i1 [ false, %20 ], [ %26, %23 ]
br i1 %28, label %29, label %42
29: ; preds = %27
%30 = load i8*, i8** %3
%31 = call i32 @NoiseWord(i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = load i32, i32* %4
%36 = call i32* @addword(%struct.wordtree** %6, i8* %34, i32 %35)
%37 = icmp eq i32* null, %36
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %40
40: ; preds = %38, %33
br label %41
41: ; preds = %40, %29
br label %20
42: ; preds = %27
br label %8
43: ; preds = %15
%44 = load i32, i32* %5
%45 = icmp ne i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%48 = load %struct.wordtree*, %struct.wordtree** %6
%49 = call i32 @printtree(%struct.wordtree* %48)
br label %50
50: ; preds = %46, %43
%51 = call i32 @deleteword(%struct.wordtree** %6)
ret i32 0
}

LLVM IR (-O2):
%struct.wordtree = type { i32 }
@main.buffer = internal global [8192 x i8] zeroinitializer
@.str = [35 x i8] c" \09\0A\0D\07\0C\0B!\22%^&*()_=+{}[]\\|/,.<>:;#~?\00"
@stdin = global i32 0
@.str.2 = [20 x i8] c"%18s Line Numbers\0A\00"
@.str.3 = [5 x i8] c"Word\00"
@str = [42 x i8] c"Error adding data into memory. Giving up.\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca %struct.wordtree*
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast %struct.wordtree** %2 to i8*
store %struct.wordtree* null, %struct.wordtree** %2
%5 = load i32, i32* @stdin
%6 = call i32* @GetLine(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buffer, i64 0, i64 0), i32 8192, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %27, label %12
8: ; preds = %24, %12
%9 = load i32, i32* @stdin
%10 = call i32* @GetLine(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buffer, i64 0, i64 0), i32 8192, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %27, label %12
12: ; preds = %0, %8
%13 = phi i32 [ %14, %8 ], [ 0, %0 ]
%14 = add nuw nsw i32 %13, 1
store i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buffer, i64 0, i64 0), i8** %1
%15 = call i8* @tokenise(i8** %1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %8, label %17
17: ; preds = %12, %24
%18 = phi i8* [ %25, %24 ], [ %15, %12 ]
%19 = call i32 @NoiseWord(i8* %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = call i32* @addword(%struct.wordtree** %2, i8* %18, i32 %14)
%23 = icmp eq i32* %22, null
br i1 %23, label %31, label %24
24: ; preds = %21, %17
%25 = call i8* @tokenise(i8** %1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %8, label %17
27: ; preds = %8, %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%29 = load %struct.wordtree*, %struct.wordtree** %2
%30 = call i32 @printtree(%struct.wordtree* %29)
br label %33
31: ; preds = %21
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = call i32 @deleteword(%struct.wordtree** %2)
ret i32 0
}