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

/* Variables and functions */
int /*<<< orphan*/ DeleteTree(struct Node *);
int /*<<< orphan*/ Insert(struct Node **, int);
int /*<<< orphan*/ MorrisTraversal(struct Node *);
int /*<<< orphan*/ PrintTree(struct Node *);
int /*<<< orphan*/ morrisTraversalPreorder(struct Node *);
int /*<<< orphan*/ printf(char *);
int main(void) {
  struct Node *root = 0;
  int i;
  Insert(&root, 2);
  Insert(&root, 3);
  Insert(&root, 1);
  printf("Traversal:");
  PrintTree(root);
  printf("\n");
  printf("Traversal:");
  MorrisTraversal(root);
  printf("\n");
  printf(" post order :");
  morrisTraversalPreorder(root);
  DeleteTree(root);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <Insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1060 <Insert@plt>
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <Insert@plt>
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <PrintTree@plt>
lea    0xe4e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <MorrisTraversal@plt>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe23(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <morrisTraversalPreorder@plt>
mov    -0x10(%rbp),%rdi
call   1030 <DeleteTree@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <Insert@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1070 <Insert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <Insert@plt>
lea    0xe4f(%rip),%rbx
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   1050 <PrintTree@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   1080 <MorrisTraversal@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1b(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   1090 <morrisTraversalPreorder@plt>
mov    0x8(%rsp),%rdi
call   1040 <DeleteTree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@.str = [11 x i8] c"Traversal:\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [14 x i8] c" post order :\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Node*
%3 = alloca i32
store i32 0, i32* %1
store %struct.Node* null, %struct.Node** %2
%4 = call i32 @Insert(%struct.Node** %2, i32 2)
%5 = call i32 @Insert(%struct.Node** %2, i32 3)
%6 = call i32 @Insert(%struct.Node** %2, i32 1)
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.Node*, %struct.Node** %2
%9 = call i32 @PrintTree(%struct.Node* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%12 = load %struct.Node*, %struct.Node** %2
%13 = call i32 @MorrisTraversal(%struct.Node* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = load %struct.Node*, %struct.Node** %2
%17 = call i32 @morrisTraversalPreorder(%struct.Node* %16)
%18 = load %struct.Node*, %struct.Node** %2
%19 = call i32 @DeleteTree(%struct.Node* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.Node = type { i32 }
@.str = [11 x i8] c"Traversal:\00"
@.str.2 = [14 x i8] c" post order :\00"
define i32 @main() {
%1 = alloca %struct.Node*
%2 = bitcast %struct.Node** %1 to i8*
store %struct.Node* null, %struct.Node** %1
%3 = call i32 @Insert(%struct.Node** %1, i32 2)
%4 = call i32 @Insert(%struct.Node** %1, i32 3)
%5 = call i32 @Insert(%struct.Node** %1, i32 1)
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = load %struct.Node*, %struct.Node** %1
%8 = call i32 @PrintTree(%struct.Node* %7)
%9 = call i32 @putchar(i32 10)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.Node*, %struct.Node** %1
%12 = call i32 @MorrisTraversal(%struct.Node* %11)
%13 = call i32 @putchar(i32 10)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = load %struct.Node*, %struct.Node** %1
%16 = call i32 @morrisTraversalPreorder(%struct.Node* %15)
%17 = load %struct.Node*, %struct.Node** %1
%18 = call i32 @DeleteTree(%struct.Node* %17)
ret i32 0
}