#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 num;
  int i;
  int t;
  int pos;
  int v[99];
  do {
    printf("inserire il numero di elementi \n");
    scanf("%d", &k);
  } while (k < 0 || k > 99);
  for (i = 0; i < k; i++) {
    printf("inserire un valore \n");
    scanf("%d", &v[i]);
  }
  printf("inserire il numero da cercare \n");
  scanf("%d", &num);
  i = 0;
  while (i < k && t == 0) {
    if (v[i] == num) {
      t = 1;
      pos = i;
    }
    i++;
  }
  if (t == 0) {
    printf("num non trovato");
  } else {
    while (pos < k) {
      v[pos] = v[pos + 1];
      pos++;
    }
    for (i = 0; i < (k - 1); i++) {
      printf("%d", v[i]);
    }
  }
}


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    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x1b1(%rbp)
jl     116f <main+0x4f>
cmpl   $0x63,-0x8(%rbp)
setg   %al
mov    %al,-0x1b1(%rbp)
mov    -0x1b1(%rbp),%al
test   $0x1,%al
jne    1132 <main+0x12>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ca <main+0xaa>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x10(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6a(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1184 <main+0x64>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe42(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x1b2(%rbp)
jge    1210 <main+0xf0>
cmpl   $0x0,-0x14(%rbp)
sete   %al
mov    %al,-0x1b2(%rbp)
mov    -0x1b2(%rbp),%al
test   $0x1,%al
jne    1223 <main+0x103>
jmp    1252 <main+0x132>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
cmp    -0xc(%rbp),%eax
jne    1244 <main+0x124>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ef <main+0xcf>
cmpl   $0x0,-0x14(%rbp)
jne    126f <main+0x14f>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ec <main+0x1cc>
jmp    1274 <main+0x154>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a8 <main+0x188>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x1b0(%rbp,%rax,4),%ecx
movslq -0x18(%rbp),%rax
mov    %ecx,-0x1b0(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1274 <main+0x154>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12e7 <main+0x1c7>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12af <main+0x18f>
jmp    12ec <main+0x1cc>
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    0xebe(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x63,%eax
ja     1160 <main+0x30>
test   %eax,%eax
je     11c5 <main+0x95>
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
lea    0xeb4(%rip),%r14
lea    0xe6b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11a0 <main+0x70>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
lea    0xe28(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x2,0x8(%rsp)
jl     1220 <main+0xf0>
lea    0xe10(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%rbx
jl     1200 <main+0xd0>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"inserire il numero di elementi \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"inserire un valore \0A\00"
@.str.3 = [32 x i8] c"inserire il numero da cercare \0A\00"
@.str.4 = [16 x i8] c"num non trovato\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [99 x i32]
store i32 0, i32* %1
br label %8
8: ; preds = %17, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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* %2)
br label %11
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 99
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %8, label %19
19: ; preds = %17
store i32 0, i32* %4
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [99 x i32], [99 x i32]* %7, i64 0, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %20
33: ; preds = %20
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%35 = 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 %36
36: ; preds = %54, %33
%37 = load i32, i32* %4
%38 = load i32, i32* %2
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 0
br label %43
43: ; preds = %40, %36
%44 = phi i1 [ false, %36 ], [ %42, %40 ]
br i1 %44, label %45, label %57
45: ; preds = %43
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [99 x i32], [99 x i32]* %7, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %3
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %45
store i32 1, i32* %5
%53 = load i32, i32* %4
store i32 %53, i32* %6
br label %54
54: ; preds = %52, %45
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %36
57: ; preds = %43
%58 = load i32, i32* %5
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %94
62: ; preds = %57
br label %63
63: ; preds = %67, %62
%64 = load i32, i32* %6
%65 = load i32, i32* %2
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %78
67: ; preds = %63
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [99 x i32], [99 x i32]* %7, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [99 x i32], [99 x i32]* %7, i64 0, i64 %74
store i32 %72, i32* %75
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %63
78: ; preds = %63
store i32 0, i32* %4
br label %79
79: ; preds = %90, %78
%80 = load i32, i32* %4
%81 = load i32, i32* %2
%82 = sub nsw i32 %81, 1
%83 = icmp slt i32 %80, %82
br i1 %83, label %84, label %93
84: ; preds = %79
%85 = load i32, i32* %4
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [99 x i32], [99 x i32]* %7, i64 0, i64 %86
%88 = load i32, i32* %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %84
%91 = load i32, i32* %4
%92 = add nsw i32 %91, 1
store i32 %92, i32* %4
br label %79
93: ; preds = %79
br label %94
94: ; preds = %93, %60
%95 = load i32, i32* %1
ret i32 %95
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [32 x i8] c"inserire il numero di elementi \00"
@str.5 = [31 x i8] c"inserire il numero da cercare \00"
@str.6 = [20 x i8] c"inserire un valore \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [99 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [99 x i32]* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 @puts(i8* dereferenceable(1) 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* %1)
%10 = load i32, i32* %1
%11 = icmp ugt i32 %10, 99
br i1 %11, label %7, label %12
12: ; preds = %7
%13 = icmp eq i32 %10, 0
br i1 %13, label %23, label %14
14: ; preds = %12, %14
%15 = phi i64 [ %19, %14 ], [ 0, %12 ]
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%17 = getelementptr inbounds [99 x i32], [99 x i32]* %3, i64 0, i64 %15
%18 = call i32 @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* %1
%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 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %38
28: ; preds = %23, %28
%29 = phi i64 [ %33, %28 ], [ 0, %23 ]
%30 = getelementptr inbounds [99 x i32], [99 x i32]* %3, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* %1
%35 = add nsw i32 %34, -1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %33, %36
br i1 %37, label %28, label %38
38: ; preds = %28, %23
ret i32 0
}