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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1080 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1080 <memset@plt>
movl   $0x1,-0x94(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x32,%esi
call   1090 <getword@plt>
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%rax
je     12e3 <main+0x133>
movsbl -0x50(%rbp),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     12bd <main+0x10d>
lea    -0x50(%rbp),%rdi
call   1070 <lowerstr@plt>
lea    -0x50(%rbp),%rdi
call   10c0 <isnotstopword@plt>
cmp    $0x0,%rax
je     12b8 <main+0x108>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x32,%edx
call   1040 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    $0x27,%esi
call   10b0 <squeezechar@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xa0(%rbp),%rdi
mov    %rax,%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1030 <stem@plt>
add    $0x1,%eax
cltq
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x90(%rbp),%rdx
mov    -0x94(%rbp),%ecx
call   10d0 <treeadd@plt>
mov    %rax,-0x10(%rbp)
jmp    12de <main+0x12e>
movsbl -0x50(%rbp),%eax
cmp    $0xa,%eax
jne    12d9 <main+0x129>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    12de <main+0x12e>
jmp    11f7 <main+0x47>
mov    -0x10(%rbp),%rdi
call   1050 <treeprint@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x30(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movw   $0x0,0x70(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1080 <getword@plt>
mov    0x2df4(%rip),%r12
cmp    (%r12),%rax
jne    1217 <main+0x77>
xor    %r14d,%r14d
mov    %r14,%rdi
call   1050 <treeprint@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
xor    %r14d,%r14d
lea    0x40(%rsp),%r15
jmp    124e <main+0xae>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
cmpb   $0xa,(%rsp)
sete   %al
add    %eax,%ebp
mov    %rbx,%rdi
mov    $0x32,%esi
call   1080 <getword@plt>
cmp    (%r12),%rax
je     11fd <main+0x5d>
movsbl (%rsp),%edi
call   1090 <isalpha@plt>
test   %rax,%rax
je     1230 <main+0x90>
mov    %rbx,%rdi
call   1070 <lowerstr@plt>
mov    %rbx,%rdi
call   10b0 <isnotstopword@plt>
test   %rax,%rax
je     123b <main+0x9b>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x32,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x27,%esi
call   10a0 <squeezechar@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <stem@plt>
cltq
movb   $0x0,0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %ebp,%ecx
call   10c0 <treeadd@plt>
mov    %rax,%r14
jmp    123b <main+0x9b>

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 [50 x i8]
%5 = alloca i32
store i32 0, i32* %1
store %struct.tnode* null, %struct.tnode** %2
%6 = bitcast [50 x i8]* %3 to i8*
%7 = bitcast [50 x i8]* %4 to i8*
store i32 1, i32* %5
br label %8
8: ; preds = %53, %0
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%10 = call i64 @getword(i8* %9, i32 50)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %54
13: ; preds = %8
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%15 = load i8, i8* %14
%16 = call i64 @isalpha(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %13
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%20 = call i32 @lowerstr(i8* %19)
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%22 = call i64 @isnotstopword(i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %18
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%27 = call i32 @strncpy(i8* %25, i8* %26, i32 50)
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%29 = call i32 @squeezechar(i8* %28, i8 signext 39)
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = sub nsw i64 %32, 1
%34 = call i32 @stem(i8* %30, i32 0, i64 %33)
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 %36
store i8 0, i8* %37
%38 = load %struct.tnode*, %struct.tnode** %2
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%41 = load i32, i32* %5
%42 = call %struct.tnode* @treeadd(%struct.tnode* %38, i8* %39, i8* %40, i32 %41)
store %struct.tnode* %42, %struct.tnode** %2
br label %43
43: ; preds = %24, %18
br label %53
44: ; preds = %13
%45 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 10
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %52
52: ; preds = %49, %44
br label %53
53: ; preds = %52, %43
br label %8
54: ; preds = %8
%55 = load %struct.tnode*, %struct.tnode** %2
%56 = call i32 @treeprint(%struct.tnode* %55)
ret i32 0
}

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