#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;
scalar_t__ getword(char *, int);
scalar_t__ isalpha(char);
scalar_t__ isnotstopword(char *);
int /*<<< orphan*/ lowerstr(char *);
struct tnode *treeadd(struct tnode *, char *, int);
int /*<<< orphan*/ treeprint(struct tnode *);
int main(void) {
  struct tnode *root = NULL;
  char word[50] = "";
  int line = 1;
  while (getword(word, 50) != EOF)
    if (isalpha(word[0])) {
      lowerstr(word);
      if (isnotstopword(word))
        root = treeadd(root, word, line);
    } else if (word[0] == '\n')
      line++;
  treeprint(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
movl   $0x1,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1060 <getword@plt>
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <main+0xb4>
movsbl -0x50(%rbp),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     1204 <main+0x94>
lea    -0x50(%rbp),%rdi
call   1040 <lowerstr@plt>
lea    -0x50(%rbp),%rdi
call   1080 <isnotstopword@plt>
cmp    $0x0,%rax
je     11ff <main+0x8f>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1090 <treeadd@plt>
mov    %rax,-0x10(%rbp)
jmp    121f <main+0xaf>
movsbl -0x50(%rbp),%eax
cmp    $0xa,%eax
jne    121a <main+0xaa>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    121f <main+0xaf>
jmp    119e <main+0x2e>
mov    -0x10(%rbp),%rdi
call   1030 <treeprint@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
mov    %rsp,%rdi
mov    $0x32,%esi
call   1050 <getword@plt>
mov    0x2e52(%rip),%r15
cmp    (%r15),%rax
jne    11b3 <main+0x53>
xor    %r14d,%r14d
mov    %r14,%rdi
call   1030 <treeprint@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
xor    %r14d,%r14d
mov    %rsp,%rbx
jmp    11dd <main+0x7d>
xor    %eax,%eax
cmpb   $0xa,(%rsp)
sete   %al
add    %eax,%ebp
mov    %rbx,%rdi
mov    $0x32,%esi
call   1050 <getword@plt>
cmp    (%r15),%rax
je     119e <main+0x3e>
movsbl (%rsp),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     11c0 <main+0x60>
mov    %rbx,%rdi
call   1040 <lowerstr@plt>
mov    %rbx,%rdi
call   1070 <isnotstopword@plt>
test   %rax,%rax
je     11cb <main+0x6b>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1080 <treeadd@plt>
mov    %rax,%r14
jmp    11cb <main+0x6b>

LLVM IR (-O0):
%struct.tnode = type { i32 }
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tnode*
%3 = alloca [50 x i8]
%4 = alloca i32
store i32 0, i32* %1
store %struct.tnode* null, %struct.tnode** %2
%5 = bitcast [50 x i8]* %3 to i8*
store i32 1, i32* %4
br label %6
6: ; preds = %37, %0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i64 @getword(i8* %7, i32 50)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %38
11: ; preds = %6
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = load i8, i8* %12
%14 = call i64 @isalpha(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%18 = call i32 @lowerstr(i8* %17)
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%20 = call i64 @isnotstopword(i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load %struct.tnode*, %struct.tnode** %2
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%25 = load i32, i32* %4
%26 = call %struct.tnode* @treeadd(%struct.tnode* %23, i8* %24, i32 %25)
store %struct.tnode* %26, %struct.tnode** %2
br label %27
27: ; preds = %22, %16
br label %37
28: ; preds = %11
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %36
36: ; preds = %33, %28
br label %37
37: ; preds = %36, %27
br label %6
38: ; preds = %6
%39 = load %struct.tnode*, %struct.tnode** %2
%40 = call i32 @treeprint(%struct.tnode* %39)
ret i32 0
}

LLVM IR (-O2):
%struct.tnode = type { i32 }
@EOF = global i64 0
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = call i64 @getword(i8* %2, i32 50)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %29, label %6
6: ; preds = %0, %23
%7 = phi i32 [ %25, %23 ], [ 1, %0 ]
%8 = phi %struct.tnode* [ %24, %23 ], [ null, %0 ]
%9 = load i8, i8* %2
%10 = call i64 @isalpha(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %6
%13 = call i32 @lowerstr(i8* %2)
%14 = call i64 @isnotstopword(i8* %2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %12
%17 = call %struct.tnode* @treeadd(%struct.tnode* %8, i8* %2, i32 %7)
br label %23
18: ; preds = %6
%19 = load i8, i8* %2
%20 = icmp eq i8 %19, 10
%21 = zext i1 %20 to i32
%22 = add nsw i32 %7, %21
br label %23
23: ; preds = %18, %12, %16
%24 = phi %struct.tnode* [ %17, %16 ], [ %8, %12 ], [ %8, %18 ]
%25 = phi i32 [ %7, %16 ], [ %7, %12 ], [ %22, %18 ]
%26 = call i64 @getword(i8* %2, i32 50)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %6
29: ; preds = %23, %0
%30 = phi %struct.tnode* [ null, %0 ], [ %24, %23 ]
%31 = call i32 @treeprint(%struct.tnode* %30)
ret i32 0
}