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

/* Variables and functions */
struct words_tree *add_line_to_words_tree(struct words_tree *, char *, int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ print_words_tree(struct words_tree *);
int /*<<< orphan*/ stdin;
int main(void) {
  char cline[500];
  int line_num = 1;
  struct words_tree *wd_tree = NULL;
  while (fgets(cline, 500, stdin)) {
    wd_tree = add_line_to_words_tree(wd_tree, cline, line_num);
    line_num++;
  }
  print_words_tree(wd_tree);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x204(%rbp)
movq   $0x0,-0x210(%rbp)
lea    -0x200(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    $0x1f4,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11af <main+0x7f>
mov    -0x210(%rbp),%rdi
lea    -0x200(%rbp),%rsi
mov    -0x204(%rbp),%edx
call   1030 <add_line_to_words_tree@plt>
mov    %rax,-0x210(%rbp)
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    1157 <main+0x27>
mov    -0x210(%rbp),%rdi
call   1050 <print_words_tree@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1f8,%rsp
mov    0x2ea4(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x1f4,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     119a <main+0x6a>
mov    $0x1,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <add_line_to_words_tree@plt>
mov    %rax,%rbx
add    $0x1,%ebp
mov    (%r15),%edx
mov    %r14,%rdi
mov    $0x1f4,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    1170 <main+0x40>
jmp    119c <main+0x6c>
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1050 <print_words_tree@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.words_tree = type { i32 }
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = alloca i32
%4 = alloca %struct.words_tree*
store i32 0, i32* %1
store i32 1, i32* %3
store %struct.words_tree* null, %struct.words_tree** %4
br label %5
5: ; preds = %10, %0
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 500, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %5
%11 = load %struct.words_tree*, %struct.words_tree** %4
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call %struct.words_tree* @add_line_to_words_tree(%struct.words_tree* %11, i8* %12, i32 %13)
store %struct.words_tree* %14, %struct.words_tree** %4
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %5
17: ; preds = %5
%18 = load %struct.words_tree*, %struct.words_tree** %4
%19 = call i32 @print_words_tree(%struct.words_tree* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.words_tree = type { i32 }
@stdin = global i32 0
define i32 @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i64 @fgets(i8* %2, i32 500, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0, %6
%7 = phi %struct.words_tree* [ %9, %6 ], [ null, %0 ]
%8 = phi i32 [ %10, %6 ], [ 1, %0 ]
%9 = call %struct.words_tree* @add_line_to_words_tree(%struct.words_tree* %7, i8* %2, i32 %8)
%10 = add nuw nsw i32 %8, 1
%11 = load i32, i32* @stdin
%12 = call i64 @fgets(i8* %2, i32 500, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %0
%15 = phi %struct.words_tree* [ null, %0 ], [ %9, %6 ]
%16 = call i32 @print_words_tree(%struct.words_tree* %15)
ret i32 0
}