#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 K;
  int I;
  int v[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int n;
  int trovato;
  int pos;
  printf("\n Inserire n ");
  scanf("%d", &n);
  I = 0;
  trovato = 0;
  while (I < 10 && !trovato) {
    if (n == v[I]) {
      pos = I;
      trovato = 1;
    }
    I++;
  }
  if (trovato == 1) {
    printf("\n Numero in posizione: %d", pos);
  } else {
    printf("\n Il numero non si trova nell'array");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%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    0xee4(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x48(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0xc(%rbp)
mov    %al,-0x4d(%rbp)
jge    119b <main+0x6b>
cmpl   $0x0,-0x48(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x7b>
jmp    11d7 <main+0xa7>
mov    -0x44(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
jne    11c9 <main+0x99>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <main+0x50>
cmpl   $0x1,-0x48(%rbp)
jne    11f7 <main+0xc7>
mov    -0x4c(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <main+0xd5>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xefc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xeb3(%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     117d <main+0x5d>
add    $0x1,%rbx
add    $0x4,%rax
cmp    %edx,%ecx
jne    1160 <main+0x40>
cmp    %edx,%ecx
jne    1191 <main+0x71>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    119f <main+0x7f>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.v = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [14 x i8] c"\0A Inserire n \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0A Numero in posizione: %d\00"
@.str.3 = [36 x i8] c"\0A Il numero non si trova nell'array\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [10 x i32]* %4 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 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* %5)
store i32 0, i32* %3
store i32 0, i32* %6
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br label %18
18: ; preds = %14, %11
%19 = phi i1 [ false, %11 ], [ %17, %14 ]
br i1 %19, label %20, label %32
20: ; preds = %18
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %21, %25
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = load i32, i32* %3
store i32 %28, i32* %7
store i32 1, i32* %6
br label %29
29: ; preds = %27, %20
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %11
32: ; preds = %18
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@__const.main.v = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [14 x i8] c"\0A Inserire n \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0A Numero in posizione: %d\00"
@.str.3 = [36 x i8] c"\0A Il numero non si trova nell'array\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 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 ([26 x i8], [26 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 ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
ret i32 0
}