#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;
struct tnode *addtree(struct tnode *, char *, int, int *);
int atoi(char *);
scalar_t__ getword(char *, int);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printtree(struct tnode *);
int strlen(char *);
int main(int argc, char **argv) {
  struct tnode *root;
  char word[100];
  int found = 0;
  int num;
  if (--argc && (**argv == '-'))
    num = atoi(*argv + 1);
  else
    num = 6;
  root = NULL;
  while (getword(word, 100) != EOF) {
    if (isalpha(word[0]) && strlen(word) >= num)
      root = addtree(root, word, num, &found);
    found = 0;
  }
  printtree(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11c3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11c3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   1080 <atoi@plt>
mov    %eax,-0x88(%rbp)
jmp    11cd <main+0x6d>
movl   $0x6,-0x88(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
je     1248 <main+0xe8>
movsbl -0x80(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     1239 <main+0xd9>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x88(%rbp),%eax
jl     1239 <main+0xd9>
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x88(%rbp),%edx
lea    -0x84(%rbp),%rcx
call   1070 <addtree@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x84(%rbp)
jmp    11d5 <main+0x75>
mov    -0x18(%rbp),%rdi
call   1050 <printtree@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
movl   $0x0,0xc(%rsp)
mov    $0x6,%ebp
cmp    $0x1,%edi
je     1194 <main+0x34>
mov    (%rsi),%rdi
cmpb   $0x2d,(%rdi)
jne    1194 <main+0x34>
add    $0x1,%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
mov    0x2e3e(%rip),%r12
cmp    (%r12),%rax
jne    11cd <main+0x6d>
xor    %r14d,%r14d
mov    %r14,%rdi
call   1050 <printtree@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r15
jmp    11fb <main+0x9b>
nopl   0x0(%rax)
movl   $0x0,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <getword@plt>
cmp    (%r12),%rax
je     11b3 <main+0x53>
movsbl 0x10(%rsp),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     11e0 <main+0x80>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jl     11e0 <main+0x80>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r15,%rcx
call   1070 <addtree@plt>
mov    %rax,%r14
jmp    11e0 <main+0x80>

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

LLVM IR (-O2):
%struct.tnode = type { i32 }
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp eq i32 %0, 1
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 45
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = tail call i32 @atoi(i8* %13)
br label %15
15: ; preds = %2, %8, %12
%16 = phi i32 [ %14, %12 ], [ 6, %8 ], [ 6, %2 ]
%17 = call i64 @getword(i8* %5, i32 100)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %35, label %20
20: ; preds = %15, %30
%21 = phi %struct.tnode* [ %31, %30 ], [ null, %15 ]
%22 = load i8, i8* %5
%23 = call i64 @isalpha(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = call i32 @strlen(i8* %5)
%27 = icmp slt i32 %26, %16
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call %struct.tnode* @addtree(%struct.tnode* %21, i8* %5, i32 %16, i32* %4)
br label %30
30: ; preds = %28, %25, %20
%31 = phi %struct.tnode* [ %29, %28 ], [ %21, %25 ], [ %21, %20 ]
store i32 0, i32* %4
%32 = call i64 @getword(i8* %5, i32 100)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %20
35: ; preds = %30, %15
%36 = phi %struct.tnode* [ null, %15 ], [ %31, %30 ]
%37 = call i32 @printtree(%struct.tnode* %36)
ret i32 0
}