#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int dat[10 + 1] = {-1, 4, 1, 7, 9, 0, 6, 3, 5, 8, 2};
  int num;
  int i;
  printf("¿ô»ú¤òÆþÎÏ  ");
  scanf("%d", &num);
  for (i = 1; i < 10 + 1; i++) {
    if (num == dat[i])
      break;
  }
  if (i == 10 + 1) {
    printf("error!\n");
    return -1;
  }
  if (i > 1)
    printf("parent  %d\n", dat[i / 2]);
  if (2 * i <= 10) {
    printf("child_l %d\n", dat[2 * i]);
    if (2 * i + 1 <= 10)
      printf("child_r %d\n", dat[2 * i + 1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x2c,%edx
call   1040 <memcpy@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x38(%rbp)
cmpl   $0xb,-0x38(%rbp)
jge    11ac <main+0x7c>
mov    -0x34(%rbp),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jne    1199 <main+0x69>
jmp    11ac <main+0x7c>
jmp    119e <main+0x6e>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1179 <main+0x49>
cmpl   $0xb,-0x38(%rbp)
jne    11d0 <main+0xa0>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125d <main+0x12d>
cmpl   $0x1,-0x38(%rbp)
jle    11f9 <main+0xc9>
mov    -0x38(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
cmp    $0xa,%eax
jg     1256 <main+0x126>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cmp    $0xa,%eax
jg     1251 <main+0x121>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main+0x126>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xf1e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf27(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x9,%rax
ja     1186 <main+0x56>
mov    $0x2,%r15d
mov    $0x1,%r14b
mov    $0x1,%ebp
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x5,%r15d
jmp    11d5 <main+0xa5>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    123a <main+0x10a>
mov    $0xa,%r15d
jmp    11d2 <main+0xa2>
mov    $0x7,%r15d
jmp    11d2 <main+0xa2>
mov    $0x8,%r15d
jmp    11d2 <main+0xa2>
mov    $0x6,%r15d
jmp    11d2 <main+0xa2>
mov    $0x3,%r15d
jmp    11d5 <main+0xa5>
mov    $0x4,%r15d
jmp    11d5 <main+0xa5>
mov    $0x9,%r15d
xor    %r14d,%r14d
mov    %r15d,%eax
shr    %eax
lea    0xe4f(%rip),%rcx
mov    (%rcx,%rax,4),%esi
lea    0xe8b(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%ebp
test   %r14b,%r14b
je     123a <main+0x10a>
lea    0x0(%rbp,%rbp,1),%eax
lea    0xe29(%rip),%r14
mov    (%r14,%rax,4),%esi
lea    0xe70(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbp,%rbp,1),%eax
cmp    $0xa,%eax
ja     123a <main+0x10a>
mov    %eax,%eax
mov    (%r14,%rax,4),%esi
lea    0xe5d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.dat = [11 x i32] [i32 -1, i32 4, i32 1, i32 7, i32 9, i32 0, i32 6, i32 3, i32 5, i32 8, i32 2]
@.str = [23 x i8] c"\C2\BF\C3\B4\C2\BB\C3\BA\C2\A4\C3\B2\C3\86\C3\BE\C3\8E\C3\8F \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"error!\0A\00"
@.str.3 = [12 x i8] c"parent %d\0A\00"
@.str.4 = [12 x i8] c"child_l %d\0A\00"
@.str.5 = [12 x i8] c"child_r %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [11 x i32]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 11
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %12, %16
br i1 %17, label %18, label %19
18: ; preds = %11
br label %23
19: ; preds = %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %18, %8
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 11
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %63
28: ; preds = %23
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 1
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %4
%33 = sdiv i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %31, %28
%39 = load i32, i32* %4
%40 = mul nsw i32 2, %39
%41 = icmp sle i32 %40, 10
br i1 %41, label %42, label %62
42: ; preds = %38
%43 = load i32, i32* %4
%44 = mul nsw i32 2, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %4
%50 = mul nsw i32 2, %49
%51 = add nsw i32 %50, 1
%52 = icmp sle i32 %51, 10
br i1 %52, label %53, label %61
53: ; preds = %42
%54 = load i32, i32* %4
%55 = mul nsw i32 2, %54
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %53, %42
br label %62
62: ; preds = %61, %38
store i32 0, i32* %1
br label %63
63: ; preds = %62, %26
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@__const.main.dat = [11 x i32] [i32 -1, i32 4, i32 1, i32 7, i32 9, i32 0, i32 6, i32 3, i32 5, i32 8, i32 2]
@.str = [23 x i8] c"\C2\BF\C3\B4\C2\BB\C3\BA\C2\A4\C3\B2\C3\86\C3\BE\C3\8E\C3\8F \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"parent %d\0A\00"
@.str.4 = [12 x i8] c"child_l %d\0A\00"
@.str.5 = [12 x i8] c"child_r %d\0A\00"
@str = [7 x i8] c"error!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
switch i32 %5, label %6 [
i32 4, label %24
i32 1, label %16
i32 7, label %8
i32 9, label %9
i32 0, label %10
i32 6, label %11
i32 3, label %12
i32 5, label %13
i32 8, label %14
i32 2, label %15
]
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %38
8: ; preds = %0
br label %16
9: ; preds = %0
br label %16
10: ; preds = %0
br label %16
11: ; preds = %0
br label %16
12: ; preds = %0
br label %16
13: ; preds = %0
br label %16
14: ; preds = %0
br label %16
15: ; preds = %0
br label %16
16: ; preds = %0, %15, %14, %13, %12, %11, %10, %9, %8
%17 = phi i1 [ true, %0 ], [ false, %15 ], [ false, %14 ], [ false, %13 ], [ false, %12 ], [ false, %11 ], [ true, %10 ], [ true, %9 ], [ true, %8 ]
%18 = phi i32 [ 2, %0 ], [ 10, %15 ], [ 9, %14 ], [ 8, %13 ], [ 7, %12 ], [ 6, %11 ], [ 5, %10 ], [ 4, %9 ], [ 3, %8 ]
%19 = lshr i32 %18, 1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [11 x i32], [11 x i32]* @__const.main.dat, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br i1 %17, label %24, label %38
24: ; preds = %0, %16
%25 = phi i32 [ %18, %16 ], [ 1, %0 ]
%26 = shl nuw nsw i32 %25, 1
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [11 x i32], [11 x i32]* @__const.main.dat, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = or i32 %26, 1
%32 = icmp ult i32 %31, 11
br i1 %32, label %33, label %38
33: ; preds = %24
%34 = zext i32 %31 to i64
%35 = getelementptr inbounds [11 x i32], [11 x i32]* @__const.main.dat, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %16, %33, %24, %6
%39 = phi i32 [ -1, %6 ], [ 0, %24 ], [ 0, %33 ], [ 0, %16 ]
ret i32 %39
}