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

/* Variables and functions */
struct word_feq_tree *add_word_to_tree(struct word_feq_tree *, char *, int);
int getword(char *, int);
int /*<<< orphan*/ print_word_feq_tree(struct word_feq_tree *);
int main(void) {
  struct word_feq_tree *wd_feq_tree = NULL;
  char word[100];
  int word_len;
  while ((word_len = getword(word, 100)) > 0) {
    wd_feq_tree = add_word_to_tree(wd_feq_tree, word, word_len);
  }
  print_word_feq_tree(wd_feq_tree);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
mov    %eax,-0x84(%rbp)
cmp    $0x0,%eax
jle    1183 <main+0x53>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x84(%rbp),%edx
call   1030 <add_word_to_tree@plt>
mov    %rax,-0x10(%rbp)
jmp    114a <main+0x1a>
mov    -0x10(%rbp),%rdi
call   1050 <print_word_feq_tree@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsp,%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    1171 <main+0x41>
mov    %rsp,%r14
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <add_word_to_tree@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
test   %eax,%eax
jg     1150 <main+0x20>
mov    %rbx,%rdi
call   1050 <print_word_feq_tree@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.word_feq_tree = type { i32 }
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @getword(i8* %2, i32 100)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %0, %5
%6 = phi i32 [ %9, %5 ], [ %3, %0 ]
%7 = phi %struct.word_feq_tree* [ %8, %5 ], [ null, %0 ]
%8 = call %struct.word_feq_tree* @add_word_to_tree(%struct.word_feq_tree* %7, i8* %2, i32 %6)
%9 = call i32 @getword(i8* %2, i32 100)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %5, %0
%12 = phi %struct.word_feq_tree* [ null, %0 ], [ %8, %5 ]
%13 = call i32 @print_word_feq_tree(%struct.word_feq_tree* %12)
ret i32 0
}