#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 /*<<< orphan*/ system(char *);
int main() {
  int N, elemento, max, posmax, i = 1;
  printf("Inserire numero di valori: ");
  scanf("%d", &N);
  if (N > 0) {
    printf("Inserire il primo valore:");
    scanf("%d", &elemento);
    max = elemento;
    posmax = i;
    while (i < N) {
      printf("Inserire un altro valore:");
      scanf("%d", &elemento);
      i = i + 1;
      if (elemento >= max) {
        max = elemento;
        posmax = i;
      }
    }
    printf("Il massimo e': %d\n", max);
    printf("La posizione del massimo e': %d\n", posmax);
  } else
    printf("Il valore di N non e' accettabile\n");
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    120f <main+0xdf>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e8 <main+0xb8>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11e3 <main+0xb3>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1198 <main+0x68>
mov    -0x10(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121d <main+0xed>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    120d <main+0xcd>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%ebx
mov    $0x1,%r13d
cmpl   $0x2,0x4(%rsp)
jl     11ea <main+0xaa>
mov    $0x1,%ebp
lea    0xe8b(%rip),%r14
lea    0xe67(%rip),%r15
mov    %rsp,%r12
mov    $0x1,%r13d
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
add    $0x1,%ebp
mov    (%rsp),%eax
cmp    %ebx,%eax
cmovge %eax,%ebx
cmovge %ebp,%r13d
cmp    0x4(%rsp),%ebp
jl     11c0 <main+0x80>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe65(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1219 <main+0xd9>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe67(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Inserire numero di valori: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Inserire il primo valore:\00"
@.str.3 = [26 x i8] c"Inserire un altro valore:\00"
@.str.4 = [19 x i8] c"Il massimo e': %d\0A\00"
@.str.5 = [33 x i8] c"La posizione del massimo e': %d\0A\00"
@.str.6 = [35 x i8] c"Il valore di N non e' accettabile\0A\00"
@.str.7 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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* %2)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %37
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
store i32 %14, i32* %4
%15 = load i32, i32* %6
store i32 %15, i32* %5
br label %16
16: ; preds = %31, %11
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp sge i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %20
%29 = load i32, i32* %3
store i32 %29, i32* %4
%30 = load i32, i32* %6
store i32 %30, i32* %5
br label %31
31: ; preds = %28, %20
br label %16
32: ; preds = %16
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %39
37: ; preds = %0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Inserire numero di valori: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Inserire il primo valore:\00"
@.str.3 = [26 x i8] c"Inserire un altro valore:\00"
@.str.4 = [19 x i8] c"Il massimo e': %d\0A\00"
@.str.5 = [33 x i8] c"La posizione del massimo e': %d\0A\00"
@.str.7 = [6 x i8] c"pause\00"
@str = [34 x i8] c"Il valore di N non e' accettabile\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, 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 = load i32, i32* %1
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %28
15: ; preds = %9, %15
%16 = phi i32 [ %21, %15 ], [ 1, %9 ]
%17 = phi i32 [ %25, %15 ], [ 1, %9 ]
%18 = phi i32 [ %24, %15 ], [ %12, %9 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = add nuw nsw i32 %16, 1
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, %18
%24 = select i1 %23, i32 %18, i32 %22
%25 = select i1 %23, i32 %17, i32 %21
%26 = load i32, i32* %1
%27 = icmp slt i32 %21, %26
br i1 %27, label %15, label %28
28: ; preds = %15, %9
%29 = phi i32 [ %12, %9 ], [ %24, %15 ]
%30 = phi i32 [ 1, %9 ], [ %25, %15 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %35
33: ; preds = %0
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}