#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 */
struct tnode *addtree(struct tnode *, char *, int);
int atoi(char *);
scalar_t__ isalpha(char);
char mgetword(char *, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ treeprint(struct tnode *);
int main(int argc, char *argv[]) {
  struct tnode *root;
  char word[1000];
  int len;
  int lineno = 0;
  root = NULL;
  while (mgetword(word, 1000, &lineno) != 'x')
    if (isalpha(word[0]))
      root = addtree(root, word, lineno);
  if (argc == 1)
    len = 8;
  else if (argc == 2)
    len = atoi(argv[1]);
  else {
    printf("Incorrect number of arguments.\n");
    return 1;
  }
  printf("Words with line numbers\n");
  treeprint(root);
  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)
movl   $0x0,-0x408(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
lea    -0x408(%rbp),%rdx
call   1070 <mgetword@plt>
movsbl %al,%eax
cmp    $0x78,%eax
je     11e4 <main+0x84>
movsbl -0x400(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11df <main+0x7f>
mov    -0x18(%rbp),%rdi
lea    -0x400(%rbp),%rsi
mov    -0x408(%rbp),%edx
call   1060 <addtree@plt>
mov    %rax,-0x18(%rbp)
jmp    118b <main+0x2b>
cmpl   $0x1,-0x8(%rbp)
jne    11fd <main+0x9d>
movl   $0x8,-0x404(%rbp)
jmp    123c <main+0xdc>
cmpl   $0x2,-0x8(%rbp)
jne    121f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x404(%rbp)
jmp    1237 <main+0xd7>
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1258 <main+0xf8>
jmp    123c <main+0xdc>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <treeprint@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3f8,%rsp
mov    %edi,%r14d
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0x3e8,%esi
call   1070 <mgetword@plt>
xor    %ebx,%ebx
cmp    $0x78,%al
jne    11a4 <main+0x54>
add    $0xffffffff,%r14d
cmp    $0x2,%r14d
jae    11e7 <main+0x97>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <treeprint@plt>
xor    %eax,%eax
jmp    11f8 <main+0xa8>
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%r15
jmp    11c4 <main+0x74>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1070 <mgetword@plt>
cmp    $0x78,%al
je     1182 <main+0x32>
movsbl 0x10(%rsp),%edi
call   1050 <isalpha@plt>
test   %rax,%rax
je     11b0 <main+0x60>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <addtree@plt>
mov    %rax,%rbx
jmp    11b0 <main+0x60>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tnode = type { i32 }
@.str = [32 x i8] c"Incorrect number of arguments.\0A\00"
@.str.1 = [25 x i8] c"Words with line numbers\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tnode*
%7 = alloca [1000 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* %9
store %struct.tnode* null, %struct.tnode** %6
br label %10
10: ; preds = %25, %2
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%12 = call signext i8 @mgetword(i8* %11, i32 1000, i32* %9)
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 120
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%17 = load i8, i8* %16
%18 = call i64 @isalpha(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load %struct.tnode*, %struct.tnode** %6
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%23 = load i32, i32* %9
%24 = call %struct.tnode* @addtree(%struct.tnode* %21, i8* %22, i32 %23)
store %struct.tnode* %24, %struct.tnode** %6
br label %25
25: ; preds = %20, %15
br label %10
26: ; preds = %10
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 8, i32* %8
br label %41
30: ; preds = %26
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %8
br label %40
38: ; preds = %30
%39 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %45
40: ; preds = %33
br label %41
41: ; preds = %40, %29
%42 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%43 = load %struct.tnode*, %struct.tnode** %6
%44 = call i32 @treeprint(%struct.tnode* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %41, %38
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.tnode = type { i32 }
@str = [31 x i8] c"Incorrect number of arguments.\00"
@str.2 = [24 x i8] c"Words with line numbers\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = call signext i8 @mgetword(i8* %5, i32 1000, i32* %4)
%8 = icmp eq i8 %7, 120
br i1 %8, label %21, label %9
9: ; preds = %2, %17
%10 = phi %struct.tnode* [ %18, %17 ], [ null, %2 ]
%11 = load i8, i8* %5
%12 = call i64 @isalpha(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i32, i32* %4
%16 = call %struct.tnode* @addtree(%struct.tnode* %10, i8* %5, i32 %15)
br label %17
17: ; preds = %14, %9
%18 = phi %struct.tnode* [ %16, %14 ], [ %10, %9 ]
%19 = call signext i8 @mgetword(i8* %5, i32 1000, i32* %4)
%20 = icmp eq i8 %19, 120
br i1 %20, label %21, label %9
21: ; preds = %17, %2
%22 = phi %struct.tnode* [ null, %2 ], [ %18, %17 ]
%23 = add i32 %0, -1
%24 = icmp ult i32 %23, 2
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %30
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.2, i64 0, i64 0))
%29 = call i32 @treeprint(%struct.tnode* %22)
br label %30
30: ; preds = %27, %25
%31 = phi i32 [ 0, %27 ], [ 1, %25 ]
ret i32 %31
}