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

/* Variables and functions */
scalar_t__ EOF;
struct tnode *addtree(struct tnode *, char *);
scalar_t__ getword(char *, int);
int /*<<< orphan*/ treeprint(struct tnode *);
int main() {
  char word[1000];
  struct tnode *root = NULL;
  while (getword(word, 1000) != EOF) {
    root = addtree(root, word);
  }
  treeprint(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x3f8(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getword@plt>
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
je     118d <main+0x5d>
mov    -0x3f8(%rbp),%rdi
lea    -0x3f0(%rbp),%rsi
call   1050 <addtree@plt>
mov    %rax,-0x3f8(%rbp)
jmp    114d <main+0x1d>
mov    -0x3f8(%rbp),%rdi
call   1030 <treeprint@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <getword@plt>
mov    0x2e98(%rip),%r15
cmp    (%r15),%rax
jne    1159 <main+0x29>
xor    %ebx,%ebx
jmp    1180 <main+0x50>
xor    %ebx,%ebx
mov    %rsp,%r14
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <addtree@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1040 <getword@plt>
cmp    (%r15),%rax
jne    1160 <main+0x30>
mov    %rbx,%rdi
call   1030 <treeprint@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tnode = type { i32 }
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca %struct.tnode*
store i32 0, i32* %1
store %struct.tnode* null, %struct.tnode** %3
br label %4
4: ; preds = %9, %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = call i64 @getword(i8* %5, i32 1000)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load %struct.tnode*, %struct.tnode** %3
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%12 = call %struct.tnode* @addtree(%struct.tnode* %10, i8* %11)
store %struct.tnode* %12, %struct.tnode** %3
br label %4
13: ; preds = %4
%14 = load %struct.tnode*, %struct.tnode** %3
%15 = call i32 @treeprint(%struct.tnode* %14)
ret i32 0
}

LLVM IR (-O2):
%struct.tnode = type { i32 }
@EOF = global i64 0
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call i64 @getword(i8* %2, i32 1000)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %12, label %6
6: ; preds = %0, %6
%7 = phi %struct.tnode* [ %8, %6 ], [ null, %0 ]
%8 = call %struct.tnode* @addtree(%struct.tnode* %7, i8* %2)
%9 = call i64 @getword(i8* %2, i32 1000)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %6
12: ; preds = %6, %0
%13 = phi %struct.tnode* [ null, %0 ], [ %8, %6 ]
%14 = call i32 @treeprint(%struct.tnode* %13)
ret i32 0
}