#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 */
struct Node *create();
int /*<<< orphan*/ printf(char *, int);
int *rightView(struct Node *, int *);
int main() {
  struct Node *root = create();
  int size = 0;
  int *res = rightView(root, &size);
  for (int i = 0; i < size; i++)
    printf("%d", res[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <create@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <rightView@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119a <main+0x6a>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1169 <main+0x39>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <create@plt>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   1050 <rightView@plt>
cmpl   $0x0,0xc(%rsp)
jle    118a <main+0x5a>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xe98(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.Node = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call %struct.Node* (...) @create()
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = call i32* @rightView(%struct.Node* %2, i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %8, %0
ret i32 0
8: ; preds = %0, %8
%9 = phi i64 [ %13, %8 ], [ 0, %0 ]
%10 = getelementptr inbounds i32, i32* %4, i64 %9
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %9, 1
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %8, label %7
}