#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 trovato;
  int pos;
  printf("Inserire il numero da cercare: ");
  scanf("%d", &n);
  i = 0;
  trovato = 0;
  while (i < 10 && !trovato) {
    if (n == v[i]) {
      pos = i;
      trovato = 1;
    }
    i++;
  }
  if (trovato == 1) {
    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>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x8(%rbp)
mov    %al,-0x3d(%rbp)
jge    119b <main+0x6b>
cmpl   $0x0,-0x38(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x7b>
jmp    11d7 <main+0xa7>
mov    -0x34(%rbp),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jne    11c9 <main+0x99>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x50>
cmpl   $0x1,-0x38(%rbp)
jne    11f7 <main+0xc7>
mov    -0x3c(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <main+0xd5>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeec(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf19(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xea3(%rip),%rax
mov    0xc(%rsp),%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%edi
mov    (%rax),%edx
cmp    %edx,%ecx
mov    %ebx,%esi
cmovne %edi,%esi
cmp    $0x8,%rbx
ja     118d <main+0x5d>
add    $0x1,%rbx
add    $0x4,%rax
cmp    %edx,%ecx
jne    1170 <main+0x40>
cmp    %edx,%ecx
jne    11a1 <main+0x71>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11af <main+0x7f>
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i32]* %3 to i8*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
store i32 0, i32* %5
br label %10
10: ; preds = %28, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %19, label %31
19: ; preds = %17
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %20, %24
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i32, i32* %2
store i32 %27, i32* %6
store i32 1, i32* %5
br label %28
28: ; preds = %26, %19
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %10
31: ; preds = %17
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* %1
ret i32 %41
}

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 i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %14, %6 ]
%8 = phi i32 [ undef, %0 ], [ %13, %6 ]
%9 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.main.v, i64 0, i64 %7
%10 = load i32, i32* %9
%11 = icmp eq i32 %5, %10
%12 = trunc i64 %7 to i32
%13 = select i1 %11, i32 %12, i32 %8
%14 = add nuw nsw i64 %7, 1
%15 = icmp ult i64 %7, 9
%16 = xor i1 %11, true
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %6, label %18
18: ; preds = %6
br i1 %11, label %19, label %21
19: ; preds = %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = call i32 @putchar(i32 10)
ret i32 0
}