#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 array[100], cerca, c, n, count = 0;
  printf("inserisci il numero di elementi dell'array\n");
  scanf("%d", &n);
  printf("inserisci %d numeri\n", n);
  for (c = 0; c < n; c++)
    scanf("%d", &array[c]);
  printf("inserisci il numero da cercare\n");
  scanf("%d", &cerca);
  for (c = 0; c < n; c++) {
    if (array[c] == cerca) {
      printf("%d è presente in posizione %d.\n", cerca, c + 1);
      count++;
    }
  }
  if (count == 0)
    printf("%d non e' presente nell'array'.\n", cerca);
  else
    printf("%d e' presente %d volte nell'array.\n", cerca, count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1b0(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1ac(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    11c2 <main+0xa2>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    117b <main+0x5b>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    125e <main+0x13e>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
cmp    -0x1a4(%rbp),%eax
jne    1245 <main+0x125>
mov    -0x1a4(%rbp),%esi
mov    -0x1a8(%rbp),%edx
add    $0x1,%edx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    124a <main+0x12a>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11ed <main+0xcd>
cmpl   $0x0,-0x1b0(%rbp)
jne    1284 <main+0x164>
mov    -0x1a4(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129e <main+0x17e>
mov    -0x1a4(%rbp),%esi
mov    -0x1b0(%rbp),%edx
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    119d <main+0x6d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe81(%rip),%r14
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1180 <main+0x50>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    1219 <main+0xe9>
lea    0xe4f(%rip),%r14
xor    %edx,%edx
xor    %ebp,%ebp
jmp    11db <main+0xab>
nop
movslq %eax,%rcx
mov    %rbx,%rdx
cmp    %rcx,%rbx
jge    11ff <main+0xcf>
mov    0x10(%rsp,%rdx,4),%esi
lea    0x1(%rdx),%rbx
cmp    0xc(%rsp),%esi
jne    11d0 <main+0xa0>
add    $0x1,%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
jmp    11d0 <main+0xa0>
test   %ebp,%ebp
je     1219 <main+0xe9>
mov    0xc(%rsp),%esi
lea    0xe4c(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122b <main+0xfb>
mov    0xc(%rsp),%esi
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"inserisci %d numeri\0A\00"
@.str.4 = [33 x i8] c"%d \C3\A8 presente in posizione %d.\0A\00"
@.str.5 = [33 x i8] c"%d non e' presente nell'array'.\0A\00"
@.str.6 = [37 x i8] c"%d e' presente %d volte nell'array.\0A\00"
@str = [43 x i8] c"inserisci il numero di elementi dell'array\00"
@str.7 = [31 x i8] c"inserisci il numero da cercare\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*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 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* %3)
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.7, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %47
26: ; preds = %21, %40
%27 = phi i32 [ %41, %40 ], [ %24, %21 ]
%28 = phi i64 [ %34, %40 ], [ 0, %21 ]
%29 = phi i32 [ %42, %40 ], [ 0, %21 ]
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %28
%31 = load i32, i32* %30
%32 = load i32, i32* %2
%33 = icmp eq i32 %31, %32
%34 = add nuw nsw i64 %28, 1
br i1 %33, label %35, label %40
35: ; preds = %26
%36 = trunc i64 %34 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %36)
%38 = add nsw i32 %29, 1
%39 = load i32, i32* %3
br label %40
40: ; preds = %26, %35
%41 = phi i32 [ %39, %35 ], [ %27, %26 ]
%42 = phi i32 [ %38, %35 ], [ %29, %26 ]
%43 = sext i32 %41 to i64
%44 = icmp slt i64 %34, %43
br i1 %44, label %26, label %45
45: ; preds = %40
%46 = icmp eq i32 %42, 0
br i1 %46, label %47, label %50
47: ; preds = %21, %45
%48 = load i32, i32* %2
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %48)
br label %53
50: ; preds = %45
%51 = load i32, i32* %2
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %51, i32 %42)
br label %53
53: ; preds = %50, %47
ret i32 0
}