#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 num[10] = {2, 5, 6, 8, 9};
  int n;
  int tot;
  int max;
  int trovato;
  int i;
  int x;
  printf("Inserire il numero da cercare: ");
  scanf("%d", &n);
  tot = 5;
  max = 10;
  if (tot < max) {
    i = 0;
    trovato = 0;
    while ((i < tot) && (trovato == 0)) {
      if (n <= num[i]) {
        i++;
      } else {
        trovato == 1;
      }
    }
  } else {
  }
  x = tot - 1;
  while (i >= 1) {
    num[x + 1] = num[x];
    x--;
  }
  num[i] = n;
  tot++;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x2,-0x30(%rbp)
movl   $0x5,-0x2c(%rbp)
movl   $0x6,-0x28(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0x9,-0x20(%rbp)
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x5,-0x38(%rbp)
movl   $0xa,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    120a <main+0xda>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x44(%rbp),%ecx
xor    %eax,%eax
cmp    -0x38(%rbp),%ecx
mov    %al,-0x49(%rbp)
jge    11d1 <main+0xa1>
cmpl   $0x0,-0x40(%rbp)
sete   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11e1 <main+0xb1>
jmp    1205 <main+0xd5>
mov    -0x34(%rbp),%eax
movslq -0x44(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jg     1200 <main+0xd0>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1200 <main+0xd0>
jmp    11b6 <main+0x86>
jmp    120f <main+0xdf>
jmp    120f <main+0xdf>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x1,-0x44(%rbp)
jl     1244 <main+0x114>
movslq -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x48(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    1218 <main+0xe8>
mov    -0x34(%rbp),%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x9,0x20(%rsp)
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
cmp    $0x3,%eax
setl   %cl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%edx
xor    %esi,%esi
cmp    0x10(%rsp,%rdx,4),%eax
setle  %sil
add    %esi,%ecx
cmp    $0x5,%ecx
jb     1180 <main+0x60>
lea    0x24(%rsp),%rax
mov    $0x9,%ecx
nopl   (%rax)
mov    %ecx,(%rax)
mov    -0x8(%rax),%ecx
add    $0xfffffffffffffffc,%rax
jmp    11a0 <main+0x80>

LLVM IR (-O0):
@.str = [32 x i8] c"Inserire il numero da cercare: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [10 x i32]* %2 to i8*
%10 = bitcast i8* %9 to [10 x i32]*
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i32 0, i32 0
store i32 2, i32* %11
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i32 0, i32 1
store i32 5, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i32 0, i32 2
store i32 6, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i32 0, i32 3
store i32 8, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %10, i32 0, i32 4
store i32 9, i32* %15
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 5, i32* %4
store i32 10, i32* %5
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %47
21: ; preds = %0
store i32 0, i32* %7
store i32 0, i32* %6
br label %22
22: ; preds = %45, %21
%23 = load i32, i32* %7
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 0
br label %29
29: ; preds = %26, %22
%30 = phi i1 [ false, %22 ], [ %28, %26 ]
br i1 %30, label %31, label %46
31: ; preds = %29
%32 = load i32, i32* %3
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp sle i32 %32, %36
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %45
41: ; preds = %31
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 1
%44 = zext i1 %43 to i32
br label %45
45: ; preds = %41, %38
br label %22
46: ; preds = %29
br label %48
47: ; preds = %0
br label %48
48: ; preds = %47, %46
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %8
br label %51
51: ; preds = %54, %48
%52 = load i32, i32* %7
%53 = icmp sge i32 %52, 1
br i1 %53, label %54, label %65
54: ; preds = %51
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %61
store i32 %58, i32* %62
%63 = load i32, i32* %8
%64 = add nsw i32 %63, -1
store i32 %64, i32* %8
br label %51
65: ; preds = %51
%66 = load i32, i32* %3
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %68
store i32 %66, i32* %69
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 1
store i32 %71, i32* %4
%72 = load i32, i32* %1
ret i32 %72
}

LLVM IR (-O2):
@.str = [32 x i8] c"Inserire il numero da cercare: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%5 = bitcast i32* %4 to i8*
%6 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 2, i32 5, i32 6, i32 8>, <4 x i32>* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 9, i32* %7
%8 = bitcast i32* %2 to i8*
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 3
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %0, %14
%15 = phi i32 [ %13, %0 ], [ %21, %14 ]
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = icmp sle i32 %11, %18
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %15, %20
%22 = icmp ult i32 %21, 5
br i1 %22, label %14, label %23
23: ; preds = %14, %23
%24 = phi i32 [ %30, %23 ], [ 9, %14 ]
%25 = phi i64 [ %28, %23 ], [ 4, %14 ]
%26 = add nsw i64 %25, 1
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %26
store i32 %24, i32* %27
%28 = add i64 %25, -1
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
br label %23
}