#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 height(struct Node *);
int /*<<< orphan*/ printLevelOrder(struct Node *, int);
int /*<<< orphan*/ printf(char *, int);
void levelOrderTraversal(struct Node *root) {
  int h = height(root);
  printf("%d\n", h);
  for (int i = 1; i < h + 1; i++)
    printLevelOrder(root, i);
}


x86 assembly (clang, -O0):
<levelOrderTraversal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <height@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1189 <levelOrderTraversal+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <printLevelOrder@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <levelOrderTraversal+0x2e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<levelOrderTraversal>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1050 <height@plt>
mov    %eax,%r15d
lea    0xeb9(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
test   %r15d,%r15d
jle    117d <levelOrderTraversal+0x4d>
neg    %r15d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printLevelOrder@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1160 <levelOrderTraversal+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @levelOrderTraversal(%struct.Node* %0) {
%2 = alloca %struct.Node*
%3 = alloca i32
%4 = alloca i32
store %struct.Node* %0, %struct.Node** %2
%5 = load %struct.Node*, %struct.Node** %2
%6 = call i32 @height(%struct.Node* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 1, i32* %4
br label %9
9: ; preds = %18, %1
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load %struct.Node*, %struct.Node** %2
%16 = load i32, i32* %4
%17 = call i32 @printLevelOrder(%struct.Node* %15, i32 %16)
br label %18
18: ; preds = %14
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %9
21: ; preds = %9
ret void
}

LLVM IR (-O2):
%struct.Node = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define void @levelOrderTraversal(%struct.Node* %0) {
%2 = tail call i32 @height(%struct.Node* %0)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i32 %2, 1
br i1 %4, label %5, label %6
5: ; preds = %6, %1
ret void
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ 1, %1 ]
%8 = tail call i32 @printLevelOrder(%struct.Node* %0, i32 %7)
%9 = add nuw i32 %7, 1
%10 = icmp eq i32 %7, %2
br i1 %10, label %5, label %6
}