#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int prod;
  int i;
  int n1;
  int n2;
  int k;
  int num;
  do {
    printf("Inserire N2 \n");
    scanf("%d", &n2);
  } while (n2 > 1000 || (n2 % 2) == 0);
  do {
    printf("Inserire N1 \n");
    scanf("%d", &n1);
  } while (n1 >= n2);
  do {
    printf("Inserire k \n");
    scanf("%d", &k);
  } while (k < n1 || k > n2);
  int numeri[k];
  i = 0;
  printf("Inserire num \n");
  scanf("%d", &num);
  while (i < k) {
    printf("Inserire un numero \n");
    scanf("%d", &numeri[i]);
    num = num * numeri[i];
    i++;
  }
  printf("Il totale e' %d", num);
  getchar();
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x3e8,-0x14(%rbp)
mov    %al,-0x31(%rbp)
jg     1183 <main+0x53>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    113f <main+0xf>
jmp    1193 <main+0x63>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <main+0x63>
jmp    11c2 <main+0x92>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%ecx
mov    $0x1,%al
cmp    -0x10(%rbp),%ecx
mov    %al,-0x32(%rbp)
jl     11fd <main+0xcd>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setg   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    11c2 <main+0x92>
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0f(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12a9 <main+0x179>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdd6(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x40(%rbp),%rcx
mov    -0x1c(%rbp),%eax
movslq -0xc(%rbp),%rdx
imul   (%rcx,%rdx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1254 <main+0x124>
mov    -0x1c(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%r14
lea    0xeae(%rip),%r15
lea    -0x34(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
and    $0x1,%eax
cmp    $0x3e8,%ecx
jg     1170 <main+0x30>
test   %eax,%eax
je     1170 <main+0x30>
lea    0xe7f(%rip),%r14
lea    0xe68(%rip),%r15
lea    -0x38(%rbp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11b0 <main+0x70>
lea    0xe58(%rip),%r14
lea    0xe34(%rip),%r15
lea    -0x30(%rbp),%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    -0x30(%rbp),%eax
cmp    -0x38(%rbp),%eax
jl     11e0 <main+0xa0>
cmp    -0x34(%rbp),%eax
jg     11e0 <main+0xa0>
mov    %rsp,%r12
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
lea    0xde2(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1281 <main+0x141>
xor    %ebx,%ebx
lea    0xe01(%rip),%r14
lea    0xdc3(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x0(%r13),%esi
imul   -0x2c(%rbp),%esi
mov    %esi,-0x2c(%rbp)
add    $0x1,%rbx
movslq -0x30(%rbp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1250 <main+0x110>
jmp    1284 <main+0x144>
mov    -0x2c(%rbp),%esi
lea    0xd75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Inserire N2 \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Inserire N1 \0A\00"
@.str.3 = [13 x i8] c"Inserire k \0A\00"
@.str.4 = [15 x i8] c"Inserire num \0A\00"
@.str.5 = [21 x i8] c"Inserire un numero \0A\00"
@.str.6 = [16 x i8] c"Il totale e' %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %1
br label %10
10: ; preds = %20, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %13
13: ; preds = %10
%14 = load i32, i32* %5
%15 = icmp sgt i32 %14, 1000
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* %5
%18 = srem i32 %17, 2
%19 = icmp eq i32 %18, 0
br label %20
20: ; preds = %16, %13
%21 = phi i1 [ true, %13 ], [ %19, %16 ]
br i1 %21, label %10, label %22
22: ; preds = %20
br label %23
23: ; preds = %26, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %26
26: ; preds = %23
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = icmp sge i32 %27, %28
br i1 %29, label %23, label %30
30: ; preds = %26
br label %31
31: ; preds = %42, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %34
34: ; preds = %31
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i32, i32* %6
%40 = load i32, i32* %5
%41 = icmp sgt i32 %39, %40
br label %42
42: ; preds = %38, %34
%43 = phi i1 [ true, %34 ], [ %41, %38 ]
br i1 %43, label %31, label %44
44: ; preds = %42
%45 = load i32, i32* %6
%46 = zext i32 %45 to i64
%47 = call i8* @llvm.stacksave()
store i8* %47, i8** %8
%48 = alloca i32, i64 %46
store i64 %46, i64* %9
store i32 0, i32* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
br label %51
51: ; preds = %55, %44
%52 = load i32, i32* %3
%53 = load i32, i32* %6
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %69
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32, i32* %3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %48, i64 %58
%60 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %59)
%61 = load i32, i32* %7
%62 = load i32, i32* %3
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %48, i64 %63
%65 = load i32, i32* %64
%66 = mul nsw i32 %61, %65
store i32 %66, i32* %7
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %51
69: ; preds = %51
%70 = load i32, i32* %7
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %70)
%72 = call i32 (...) @getchar()
%73 = call i32 (...) @getchar()
%74 = load i8*, i8** %8
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.6 = [16 x i8] c"Il totale e' %d\00"
@str = [13 x i8] c"Inserire N2 \00"
@str.7 = [13 x i8] c"Inserire N1 \00"
@str.8 = [12 x i8] c"Inserire k \00"
@str.9 = [14 x i8] c"Inserire num \00"
@str.10 = [20 x i8] c"Inserire un numero \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %9, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 1000
%14 = and i32 %12, 1
%15 = icmp eq i32 %14, 0
%16 = or i1 %13, %15
br i1 %16, label %9, label %17
17: ; preds = %9, %17
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %17
23: ; preds = %17, %23
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, 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)
%26 = load i32, i32* %3
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
%29 = load i32, i32* %2
%30 = icmp sgt i32 %26, %29
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %23, label %32
32: ; preds = %23
%33 = zext i32 %26 to i64
%34 = call i8* @llvm.stacksave()
%35 = alloca i32, i64 %33
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%38 = load i32, i32* %3
%39 = icmp sgt i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %32
%41 = load i32, i32* %4
br label %54
42: ; preds = %32, %42
%43 = phi i64 [ %50, %42 ], [ 0, %32 ]
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%45 = getelementptr inbounds i32, i32* %35, i64 %43
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %45)
%47 = load i32, i32* %4
%48 = load i32, i32* %45
%49 = mul nsw i32 %48, %47
store i32 %49, i32* %4
%50 = add nuw nsw i64 %43, 1
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %50, %52
br i1 %53, label %42, label %54
54: ; preds = %42, %40
%55 = phi i32 [ %41, %40 ], [ %49, %42 ]
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %55)
%57 = call i32 (...) @getchar()
%58 = call i32 (...) @getchar()
ret i32 0
}