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

/* Variables and functions */
struct tnode *addtree(struct tnode *, char *);
scalar_t__ isalpha(char);
char mgetword(char *, int);
int /*<<< orphan*/ printf(char *);
struct numwordnode *traverse(struct tnode *, struct numwordnode *);
int /*<<< orphan*/ treeprint(struct numwordnode *);
int main(int argc, char *argv[]) {
  struct tnode *root;
  struct numwordnode *numwordroot;
  char word[1000];
  root = NULL;
  numwordroot = NULL;
  while (mgetword(word, 1000) != 'x')
    if (isalpha(word[0]))
      root = addtree(root, word);
  numwordroot = traverse(root, numwordroot);
  printf("Words and their frequencies:\n");
  treeprint(numwordroot);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x3e8,%esi
call   1080 <mgetword@plt>
movsbl %al,%eax
cmp    $0x78,%eax
je     11d5 <main+0x75>
movsbl -0x410(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11d0 <main+0x70>
mov    -0x18(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1070 <addtree@plt>
mov    %rax,-0x18(%rbp)
jmp    1189 <main+0x29>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <traverse@plt>
mov    %rax,-0x20(%rbp)
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <treeprint@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1080 <mgetword@plt>
xor    %ebx,%ebx
cmp    $0x78,%al
jne    11ab <main+0x4b>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <traverse@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <treeprint@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsp,%r14
jmp    11c1 <main+0x61>
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1080 <mgetword@plt>
cmp    $0x78,%al
je     117d <main+0x1d>
movsbl (%rsp),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     11b0 <main+0x50>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <addtree@plt>
mov    %rax,%rbx
jmp    11b0 <main+0x50>

LLVM IR (-O0):
%struct.tnode = type { i32 }
%struct.numwordnode = type { i32 }
@.str = [30 x i8] c"Words and their frequencies:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tnode*
%7 = alloca %struct.numwordnode*
%8 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.tnode* null, %struct.tnode** %6
store %struct.numwordnode* null, %struct.numwordnode** %7
br label %9
9: ; preds = %23, %2
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%11 = call signext i8 @mgetword(i8* %10, i32 1000)
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 120
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%16 = load i8, i8* %15
%17 = call i64 @isalpha(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load %struct.tnode*, %struct.tnode** %6
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%22 = call %struct.tnode* @addtree(%struct.tnode* %20, i8* %21)
store %struct.tnode* %22, %struct.tnode** %6
br label %23
23: ; preds = %19, %14
br label %9
24: ; preds = %9
%25 = load %struct.tnode*, %struct.tnode** %6
%26 = load %struct.numwordnode*, %struct.numwordnode** %7
%27 = call %struct.numwordnode* @traverse(%struct.tnode* %25, %struct.numwordnode* %26)
store %struct.numwordnode* %27, %struct.numwordnode** %7
%28 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%29 = load %struct.numwordnode*, %struct.numwordnode** %7
%30 = call i32 @treeprint(%struct.numwordnode* %29)
ret i32 0
}

LLVM IR (-O2):
%struct.tnode = type { i32 }
%struct.numwordnode = type { i32 }
@str = [29 x i8] c"Words and their frequencies:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call signext i8 @mgetword(i8* %4, i32 1000)
%6 = icmp eq i8 %5, 120
br i1 %6, label %18, label %7
7: ; preds = %2, %14
%8 = phi %struct.tnode* [ %15, %14 ], [ null, %2 ]
%9 = load i8, i8* %4
%10 = call i64 @isalpha(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call %struct.tnode* @addtree(%struct.tnode* %8, i8* %4)
br label %14
14: ; preds = %12, %7
%15 = phi %struct.tnode* [ %13, %12 ], [ %8, %7 ]
%16 = call signext i8 @mgetword(i8* %4, i32 1000)
%17 = icmp eq i8 %16, 120
br i1 %17, label %18, label %7
18: ; preds = %14, %2
%19 = phi %struct.tnode* [ null, %2 ], [ %15, %14 ]
%20 = call %struct.numwordnode* @traverse(%struct.tnode* %19, %struct.numwordnode* null)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%22 = call i32 @treeprint(%struct.numwordnode* %20)
ret i32 0
}