#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 i;
  int v[10] = {10, 1, 5, 4, 3, 6, 2, 8, 7, 9};
  int n;
  int pos;
  printf("Inserire il numero da cercare: ");
  scanf("%d", &n);
  v[10] = n;
  i = 0;
  while (v[i] != n) {
    i++;
  }
  pos = i;
  if (pos < 10) {
    printf("numero trovato in posizione: %d", pos);
  } else {
    printf("numero non trovato");
  }
  printf("\n");
}


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    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x34(%rbp),%eax
je     119e <main+0x6e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117f <main+0x4f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    11c4 <main+0x94>
mov    -0x38(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0xa2>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    0xee5(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x38(%rsp)
mov    $0xffffffff,%esi
lea    0x10(%rsp),%rcx
nopl   0x0(%rax)
add    $0x1,%esi
lea    0x4(%rcx),%rdx
cmp    %eax,(%rcx)
mov    %rdx,%rcx
jne    1190 <main+0x60>
cmp    $0x9,%esi
ja     11b3 <main+0x83>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c1 <main+0x91>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.v = [10 x i32] [i32 10, i32 1, i32 5, i32 4, i32 3, i32 6, i32 2, i32 8, i32 7, i32 9]
@.str = [32 x i8] c"Inserire il numero da cercare: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"numero trovato in posizione: %d\00"
@.str.3 = [19 x i8] c"numero non trovato\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %3 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 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* %4)
%9 = load i32, i32* %4
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 10
store i32 %9, i32* %10
store i32 0, i32* %2
br label %11
11: ; preds = %18, %0
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = load i32, i32* %4
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %11
21: ; preds = %11
%22 = load i32, i32* %2
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %30
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@__const.main.v = [10 x i32] [i32 10, i32 1, i32 5, i32 4, i32 3, i32 6, i32 2, i32 8, i32 7, i32 9]
@.str = [32 x i8] c"Inserire il numero da cercare: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"numero trovato in posizione: %d\00"
@.str.3 = [19 x i8] c"numero non trovato\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 = load i32, i32* %2
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
store i32 %7, i32* %8
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, %7
%14 = add nuw i64 %10, 1
br i1 %13, label %15, label %9
15: ; preds = %9
%16 = trunc i64 %10 to i32
%17 = icmp ult i32 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %22
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = call i32 @putchar(i32 10)
ret i32 0
}