#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 /*<<< orphan*/ system(char *);
int main() {
  int num[10] = {0, 3, 6, 8, 9};
  int tot = 5;
  int max = 10;
  int x;
  int n;
  int p;
  int trovato;
  int i;
  printf("Inserisci un numero: ");
  scanf("%d", &n);
  if (tot < max) {
    trovato = 0;
    i = 0;
    while ((i < tot) && (trovato == 0)) {
      if (n <= num[i]) {
        trovato = 1;
      } else {
        i++;
      }
    }
  }
  x = tot - 1;
  while (x >= i) {
    num[x + 1] = num[x];
    x--;
  }
  num[i] = n;
  tot++;
  for (p = 0; p < tot; p++) {
    printf("%d", num[p]);
  }
  system("PAUSE");
}


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   1050 <memset@plt>
movl   $0x3,-0x2c(%rbp)
movl   $0x6,-0x28(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0x9,-0x20(%rbp)
movl   $0x5,-0x34(%rbp)
movl   $0xa,-0x38(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    121c <main+0xdc>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x34(%rbp),%ecx
mov    %al,-0x4d(%rbp)
jge    11dc <main+0x9c>
cmpl   $0x0,-0x48(%rbp)
sete   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    11ec <main+0xac>
jmp    1217 <main+0xd7>
mov    -0x40(%rbp),%eax
movslq -0x4c(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jg     1209 <main+0xc9>
movl   $0x1,-0x48(%rbp)
jmp    1212 <main+0xd2>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c1 <main+0x81>
jmp    121c <main+0xdc>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jl     1253 <main+0x113>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1225 <main+0xe5>
mov    -0x40(%rbp),%ecx
movslq -0x4c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    129e <main+0x15e>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    126e <main+0x12e>
lea    0xd74(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
movaps 0xeaf(%rip),%xmm0
movups %xmm0,0x4(%rsp)
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    0x2c(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2c(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
setg   %cl
jle    11a9 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%edx
mov    %ecx,%ecx
mov    (%rsp,%rcx,4),%esi
xor    %ecx,%ecx
cmp    %esi,%eax
setg   %cl
add    %edx,%ecx
cmp    %esi,%eax
jle    11a9 <main+0x79>
cmp    $0x5,%ecx
jb     1190 <main+0x60>
cmp    $0x4,%ecx
ja     11e2 <main+0xb2>
movl   $0x9,0x14(%rsp)
je     11e2 <main+0xb2>
mov    0xc(%rsp),%edx
mov    %edx,0x10(%rsp)
cmp    $0x2,%ecx
ja     11e2 <main+0xb2>
mov    0x8(%rsp),%edx
mov    %edx,0xc(%rsp)
je     11e2 <main+0xb2>
mov    0x4(%rsp),%edx
mov    %edx,0x8(%rsp)
test   %ecx,%ecx
jne    11e2 <main+0xb2>
mov    (%rsp),%edx
mov    %edx,0x4(%rsp)
mov    %ecx,%ecx
mov    %eax,(%rsp,%rcx,4)
mov    (%rsp),%esi
lea    0xe35(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde1(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Inserisci un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"PAUSE\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
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [10 x i32]* %2 to i8*
%11 = bitcast i8* %10 to [10 x i32]*
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 1
store i32 3, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 2
store i32 6, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 3
store i32 8, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 4
store i32 9, i32* %15
store i32 5, i32* %3
store i32 10, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %6)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %44
21: ; preds = %0
store i32 0, i32* %8
store i32 0, i32* %9
br label %22
22: ; preds = %42, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %8
%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 %43
31: ; preds = %29
%32 = load i32, i32* %6
%33 = load i32, i32* %9
%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 %39
38: ; preds = %31
store i32 1, i32* %8
br label %42
39: ; preds = %31
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %42
42: ; preds = %39, %38
br label %22
43: ; preds = %29
br label %44
44: ; preds = %43, %0
%45 = load i32, i32* %3
%46 = sub nsw i32 %45, 1
store i32 %46, i32* %5
br label %47
47: ; preds = %51, %44
%48 = load i32, i32* %5
%49 = load i32, i32* %9
%50 = icmp sge i32 %48, %49
br i1 %50, label %51, label %62
51: ; preds = %47
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %58
store i32 %55, i32* %59
%60 = load i32, i32* %5
%61 = add nsw i32 %60, -1
store i32 %61, i32* %5
br label %47
62: ; preds = %47
%63 = load i32, i32* %6
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %65
store i32 %63, i32* %66
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
store i32 0, i32* %7
br label %69
69: ; preds = %79, %62
%70 = load i32, i32* %7
%71 = load i32, i32* %3
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %82
73: ; preds = %69
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %73
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %69
82: ; preds = %69
%83 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32, i32* %1
ret i32 %84
}

LLVM IR (-O2):
@.str = [22 x i8] c"Inserisci un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"PAUSE\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 1
%5 = bitcast i32* %4 to <4 x i32>*
store <4 x i32> <i32 3, i32 6, i32 8, i32 9>, <4 x i32>* %5
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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* %2)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
%11 = zext i1 %10 to i32
br i1 %10, label %18, label %12
12: ; preds = %18, %0
%13 = phi i32 [ %11, %0 ], [ %25, %18 ]
%14 = icmp ugt i32 %13, 4
br i1 %14, label %47, label %15
15: ; preds = %12
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 9, i32* %16
%17 = icmp eq i32 %13, 4
br i1 %17, label %47, label %28
18: ; preds = %0, %18
%19 = phi i32 [ %25, %18 ], [ %11, %0 ]
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = icmp sgt i32 %9, %22
%24 = zext i1 %23 to i32
%25 = add nuw nsw i32 %19, %24
%26 = icmp ult i32 %25, 5
%27 = and i1 %23, %26
br i1 %27, label %18, label %12
28: ; preds = %15
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%30 = load i32, i32* %29
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 %30, i32* %31
%32 = icmp ult i32 %13, 3
br i1 %32, label %33, label %47
33: ; preds = %28
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%35 = load i32, i32* %34
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 %35, i32* %36
%37 = icmp eq i32 %13, 2
br i1 %37, label %47, label %38
38: ; preds = %33
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%40 = load i32, i32* %39
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 %40, i32* %41
%42 = icmp eq i32 %13, 0
br i1 %42, label %43, label %47
43: ; preds = %38
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 %45, i32* %46
br label %47
47: ; preds = %28, %33, %38, %43, %15, %12
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%51 = zext i32 %13 to i64
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %51
store i32 %9, i32* %52
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %4
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %50
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %49
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %48
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%67 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}