#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ inOrder(struct node *);
int /*<<< orphan*/ postOrder(struct node *);
int /*<<< orphan*/ preOrder(struct node *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
void travarsal(struct node *ptr) {
  int ch;
  do {
    printf("\n\n===Travarsal Menu===");
    printf("\n1 : In-Order");
    printf("\n2 : Pre-Order");
    printf("\n3 : Post-Order");
    printf("\n4 : Exit");
    printf("\nEnter your choice : ");
    scanf("%d", &ch);
    fflush(stdin);
    switch (ch) {
    case 1: {
      inOrder(ptr);
    } break;
    case 2: {
      preOrder(ptr);
    } break;
    case 3: {
      postOrder(ptr);
    } break;
    case 4: {
      printf("\nExit");
    } break;
    default: {
      printf("\nInvalid Input");
    }
    }
  } while (ch != 4);
}


x86 assembly (clang, -O0):
<travarsal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1236 <travarsal+0xd6>
mov    -0x18(%rbp),%rax
lea    0xe0e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
call   1060 <inOrder@plt>
jmp    1242 <travarsal+0xe2>
mov    -0x8(%rbp),%rdi
call   1080 <preOrder@plt>
jmp    1242 <travarsal+0xe2>
mov    -0x8(%rbp),%rdi
call   1040 <postOrder@plt>
jmp    1242 <travarsal+0xe2>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    1242 <travarsal+0xe2>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
jmp    1247 <travarsal+0xe7>
cmpl   $0x4,-0xc(%rbp)
jne    116c <travarsal+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<travarsal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee9(%rip),%r14
lea    0xef8(%rip),%r15
lea    0x4(%rsp),%r12
mov    0x2e60(%rip),%r13
lea    0xe71(%rip),%rbp
jmp    11b7 <travarsal+0x57>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x4,0x4(%rsp)
je     126c <travarsal+0x10c>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11a0 <travarsal+0x40>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %rbx,%rdi
call   1060 <inOrder@plt>
jmp    11ac <travarsal+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <preOrder@plt>
jmp    11ac <travarsal+0x4c>
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <postOrder@plt>
jmp    11ac <travarsal+0x4c>
nopl   (%rax)
lea    0xe10(%rip),%rdi
jmp    11a7 <travarsal+0x47>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [23 x i8] c"\0A\0A===Travarsal Menu===\00"
@.str.1 = [14 x i8] c"\0A1 : In-Order\00"
@.str.2 = [15 x i8] c"\0A2 : Pre-Order\00"
@.str.3 = [16 x i8] c"\0A3 : Post-Order\00"
@.str.4 = [10 x i8] c"\0A4 : Exit\00"
@.str.5 = [22 x i8] c"\0AEnter your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.7 = [6 x i8] c"\0AExit\00"
@.str.8 = [15 x i8] c"\0AInvalid Input\00"
define void @travarsal(%struct.node* %0) {
%2 = alloca %struct.node*
%3 = alloca i32
store %struct.node* %0, %struct.node** %2
br label %4
4: ; preds = %29, %1
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%12 = load i32, i32* @stdin
%13 = call i32 @fflush(i32 %12)
%14 = load i32, i32* %3
switch i32 %14, label %26 [
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %24
]
15: ; preds = %4
%16 = load %struct.node*, %struct.node** %2
%17 = call i32 @inOrder(%struct.node* %16)
br label %28
18: ; preds = %4
%19 = load %struct.node*, %struct.node** %2
%20 = call i32 @preOrder(%struct.node* %19)
br label %28
21: ; preds = %4
%22 = load %struct.node*, %struct.node** %2
%23 = call i32 @postOrder(%struct.node* %22)
br label %28
24: ; preds = %4
%25 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %28
26: ; preds = %4
%27 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %28
28: ; preds = %26, %24, %21, %18, %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 4
br i1 %31, label %4, label %32
32: ; preds = %29
ret void
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [23 x i8] c"\0A\0A===Travarsal Menu===\00"
@.str.1 = [14 x i8] c"\0A1 : In-Order\00"
@.str.2 = [15 x i8] c"\0A2 : Pre-Order\00"
@.str.3 = [16 x i8] c"\0A3 : Post-Order\00"
@.str.4 = [10 x i8] c"\0A4 : Exit\00"
@.str.5 = [22 x i8] c"\0AEnter your choice : \00"
@.str.6 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.7 = [6 x i8] c"\0AExit\00"
@.str.8 = [15 x i8] c"\0AInvalid Input\00"
define void @travarsal(%struct.node* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %25, %1
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%12 = load i32, i32* @stdin
%13 = call i32 @fflush(i32 %12)
%14 = load i32, i32* %2
switch i32 %14, label %23 [
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
]
15: ; preds = %4
%16 = call i32 @inOrder(%struct.node* %0)
br label %25
17: ; preds = %4
%18 = call i32 @preOrder(%struct.node* %0)
br label %25
19: ; preds = %4
%20 = call i32 @postOrder(%struct.node* %0)
br label %25
21: ; preds = %4
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %25
23: ; preds = %4
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %15, %17, %19, %21, %23
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %4
28: ; preds = %25
ret void
}