#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  static int A[20];
  int I, i, j, eleman, N;
  printf("What is your Array lenght ? :\n");
  scanf("%d", &N);
  printf("Enter elements of array : \n");
  for (i = 0; i < N; i++) {
    I = 1;
    printf("	*What is %d. element? :\n	*** :", i + 1);
    scanf("%d", &eleman);
    while ((I <= N) && (A[I] != 0)) {
      if (eleman > A[I])
        I = 2 * I + 1;
      else
        I = 2 * I;
    }
    A[I] = eleman;
    printf("	*****A[%d] = %d \n", I, A[I]);
  }
  for (i = 1; i <= I; i++)
    printf("%d , ", A[i]);
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1253 <main+0x123>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x19(%rbp)
jg     11cf <main+0x9f>
movslq -0x8(%rbp),%rcx
lea    0x2e8b(%rip),%rax
cmpl   $0x0,(%rax,%rcx,4)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11df <main+0xaf>
jmp    1215 <main+0xe5>
mov    -0x14(%rbp),%eax
movslq -0x8(%rbp),%rdx
lea    0x2e63(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jle    1207 <main+0xd7>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1210 <main+0xe0>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a9 <main+0x79>
mov    -0x14(%rbp),%edx
movslq -0x8(%rbp),%rcx
lea    0x2e2d(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rcx
lea    0x2e1c(%rip),%rax
mov    (%rax,%rcx,4),%edx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x42>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1290 <main+0x160>
movslq -0xc(%rbp),%rcx
lea    0x2ddf(%rip),%rax
mov    (%rax,%rcx,4),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    125a <main+0x12a>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,(%rsp)
jle    1212 <main+0xd2>
lea    0xe7d(%rip),%r15
lea    0x4(%rsp),%r12
lea    0x2ec1(%rip),%r14
lea    0xe8d(%rip),%r13
xor    %ebp,%ebp
jmp    11b6 <main+0x76>
nopw   0x0(%rax,%rax,1)
movslq %ebx,%rsi
mov    %edx,(%r14,%rsi,4)
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    (%rsp),%ebp
jge    120c <main+0xcc>
add    $0x1,%ebp
lea    0xe43(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%edx
mov    $0x1,%ebx
test   %eax,%eax
jle    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ebx,%rcx
mov    (%r14,%rcx,4),%ecx
test   %ecx,%ecx
je     11a0 <main+0x60>
xor    %esi,%esi
cmp    %ecx,%edx
setg   %sil
lea    (%rsi,%rbx,2),%ebx
cmp    %eax,%ebx
jle    11f0 <main+0xb0>
jmp    11a0 <main+0x60>
test   %ebx,%ebx
jg     1212 <main+0xd2>
jmp    1247 <main+0x107>
add    $0x1,%ebx
mov    $0x1,%ebp
lea    0x2e2f(%rip),%r15
lea    0xe0e(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1230 <main+0xf0>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.A = internal global [20 x i32] zeroinitializer
@.str = [31 x i8] c"What is your Array lenght ? :\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Enter elements of array : \0A\00"
@.str.3 = [32 x i8] c"\09*What is %d. element? :\0A\09*** :\00"
@.str.4 = [19 x i8] c"\09*****A[%d] = %d \0A\00"
@.str.5 = [6 x i8] c"%d , \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %10
10: ; preds = %57, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %60
14: ; preds = %10
store i32 1, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %19
19: ; preds = %45, %14
%20 = load i32, i32* %2
%21 = load i32, i32* %6
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, 0
br label %29
29: ; preds = %23, %19
%30 = phi i1 [ false, %19 ], [ %28, %23 ]
br i1 %30, label %31, label %46
31: ; preds = %29
%32 = load i32, i32* %5
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp sgt i32 %32, %36
br i1 %37, label %38, label %42
38: ; preds = %31
%39 = load i32, i32* %2
%40 = mul nsw i32 2, %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %45
42: ; preds = %31
%43 = load i32, i32* %2
%44 = mul nsw i32 2, %43
store i32 %44, i32* %2
br label %45
45: ; preds = %42, %38
br label %19
46: ; preds = %29
%47 = load i32, i32* %5
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %49
store i32 %47, i32* %50
%51 = load i32, i32* %2
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %51, i32 %55)
br label %57
57: ; preds = %46
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %10
60: ; preds = %10
store i32 1, i32* %3
br label %61
61: ; preds = %71, %60
%62 = load i32, i32* %3
%63 = load i32, i32* %2
%64 = icmp sle i32 %62, %63
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %65
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 1
store i32 %73, i32* %3
br label %61
74: ; preds = %61
%75 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@main.A = internal unnamed_addr global [20 x i32] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"\09*What is %d. element? :\0A\09*** :\00"
@.str.4 = [19 x i8] c"\09*****A[%d] = %d \0A\00"
@.str.5 = [6 x i8] c"%d , \00"
@str = [30 x i8] c"What is your Array lenght ? :\00"
@str.6 = [27 x i8] c"Enter elements of array : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %16, label %12
10: ; preds = %36
%11 = icmp slt i32 %37, 1
br i1 %11, label %50, label %12
12: ; preds = %0, %10
%13 = phi i32 [ %37, %10 ], [ undef, %0 ]
%14 = add nuw i32 %13, 1
%15 = zext i32 %14 to i64
br label %43
16: ; preds = %0, %36
%17 = phi i32 [ %18, %36 ], [ 0, %0 ]
%18 = add nuw nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 1
%23 = load i32, i32* %1
br i1 %22, label %36, label %24
24: ; preds = %16, %30
%25 = phi i32 [ %34, %30 ], [ 1, %16 ]
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = icmp sgt i32 %23, %28
%32 = shl nsw i32 %25, 1
%33 = zext i1 %31 to i32
%34 = or i32 %32, %33
%35 = icmp sgt i32 %34, %21
br i1 %35, label %36, label %24
36: ; preds = %24, %30, %16
%37 = phi i32 [ 1, %16 ], [ %34, %30 ], [ %25, %24 ]
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %38
store i32 %23, i32* %39
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %23)
%41 = load i32, i32* %2
%42 = icmp slt i32 %18, %41
br i1 %42, label %16, label %10
43: ; preds = %12, %43
%44 = phi i64 [ 1, %12 ], [ %48, %43 ]
%45 = getelementptr inbounds [20 x i32], [20 x i32]* @main.A, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %46)
%48 = add nuw nsw i64 %44, 1
%49 = icmp eq i64 %48, %15
br i1 %49, label %50, label %43
50: ; preds = %43, %10
%51 = call i32 (...) @getch()
ret i32 0
}