main() {
  int vettore[100];
  int x;
  int K;
  int trovato;
  int pos;
  int NUM;
  do {
    printf("\n inserire il numero di elementi del vettore  ");
    scanf("%d", &K);
  } while (K > 100);
  x = 0;
  while (x < K) {
    printf("\n inserire un numero  ");
    scanf("%d", &vettore[x]);
    x++;
  }
  printf("\n inserire il numero da cercare");
  scanf("%d", &NUM);
  trovato = 0;
  pos = 0;
  x = 0;
  while ((pos < K) && (trovato == 1)) {
    if (vettore[x] == NUM) {
      trovato = 1;
    }
    pos++;
    x++;
  }
  if (trovato == 0) {
    printf(NUM, "\n %d non è presente nella lista");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x64,-0x1a8(%rbp)
jg     1132 <main+0x12>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    11c3 <main+0xa3>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    116c <main+0x4c>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
lea    -0x1b4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1ac(%rbp)
movl   $0x0,-0x1b0(%rbp)
movl   $0x0,-0x1a4(%rbp)
mov    -0x1b0(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1a8(%rbp),%ecx
mov    %al,-0x1b5(%rbp)
jge    122e <main+0x10e>
cmpl   $0x1,-0x1ac(%rbp)
sete   %al
mov    %al,-0x1b5(%rbp)
mov    -0x1b5(%rbp),%al
test   $0x1,%al
jne    1241 <main+0x121>
jmp    1288 <main+0x168>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
cmp    -0x1b4(%rbp),%eax
jne    1265 <main+0x145>
movl   $0x1,-0x1ac(%rbp)
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1204 <main+0xe4>
cmpl   $0x0,-0x1ac(%rbp)
jne    12aa <main+0x18a>
movslq -0x1b4(%rbp),%rdi
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xecb(%rip),%r14
lea    0xef3(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x64,%eax
jg     1150 <main+0x30>
test   %eax,%eax
jle    11b9 <main+0x99>
lea    0x10(%rsp),%r12
lea    0xeb2(%rip),%r14
lea    0xea8(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1190 <main+0x70>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rdi
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0A inserire il numero di elementi del vettore \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"\0A inserire un numero \00"
@.str.3 = [32 x i8] c"\0A inserire il numero da cercare\00"
@.str.4 = [33 x i8] c"\0A %d non \C3\A8 presente nella lista\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %11, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %11
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 100
br i1 %13, label %8, label %14
14: ; preds = %11
store i32 0, i32* %3
br label %15
15: ; preds = %19, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %22
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %15
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %3
br label %30
30: ; preds = %47, %27
%31 = load i32, i32* %6
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 1
br label %37
37: ; preds = %34, %30
%38 = phi i1 [ false, %30 ], [ %36, %34 ]
br i1 %38, label %39, label %52
39: ; preds = %37
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %7
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %47
46: ; preds = %39
store i32 1, i32* %5
br label %47
47: ; preds = %46, %39
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %30
52: ; preds = %37
%53 = load i32, i32* %5
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i8*
%59 = call i32 (i8*, ...) @printf(i8* %58, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %55, %52
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [47 x i8] c"\0A inserire il numero di elementi del vettore \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"\0A inserire un numero \00"
@.str.3 = [32 x i8] c"\0A inserire il numero da cercare\00"
@.str.4 = [33 x i8] c"\0A %d non \C3\A8 presente nella lista\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [100 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 100
br i1 %11, label %7, label %12
12: ; preds = %7
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %23
14: ; preds = %12, %14
%15 = phi i64 [ %19, %14 ], [ 0, %12 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %15
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %15, 1
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %14, label %23
23: ; preds = %14, %12
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i8*
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}