#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int promptValue();
int main() {
  int *arr;
  printf("Longeur?\n");
  int size = promptValue();
  arr = malloc(sizeof(int) * size);
  for (int i = 0; i < size; i++) {
    printf("Valeur?\n");
    arr[i] = promptValue();
  }
  printf("Sortie:\n");
  int sum = 0;
  for (int i = 0; i < size; i++) {
    printf("%d (%d)\n", arr[i], sum += arr[i]);
  }
  free(arr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <promptValue@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bd <main+0x7d>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <promptValue@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <main+0x41>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121d <main+0xdd>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    -0x1c(%rbp),%edx
mov    %edx,-0x1c(%rbp)
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d9 <main+0x99>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <promptValue@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    11ed <main+0x9d>
mov    %r14d,%r12d
lea    0xe8d(%rip),%rbp
xor    %ebx,%ebx
nop
mov    %rbp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <promptValue@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1190 <main+0x40>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
jle    11f9 <main+0xa9>
lea    0xe3c(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
add    %esi,%ebp
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <main+0x80>
jmp    11f9 <main+0xa9>
lea    0xe1e(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Longeur?\0A\00"
@.str.1 = [9 x i8] c"Valeur?\0A\00"
@.str.2 = [9 x i8] c"Sortie:\0A\00"
@.str.3 = [9 x i8] c"%d (%d)\0A\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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @promptValue()
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = mul i64 4, %10
%12 = trunc i64 %11 to i32
%13 = call i32* @malloc(i32 %12)
store i32* %13, i32** %2
store i32 0, i32* %4
br label %14
14: ; preds = %25, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (...) @promptValue()
%21 = load i32*, i32** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %14
28: ; preds = %14
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
store i32 0, i32* %6
br label %30
30: ; preds = %48, %28
%31 = load i32, i32* %6
%32 = load i32, i32* %3
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %51
34: ; preds = %30
%35 = load i32*, i32** %2
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = load i32*, i32** %2
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, %44
store i32 %46, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %39, i32 %46)
br label %48
48: ; preds = %34
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %30
51: ; preds = %30
%52 = load i32*, i32** %2
%53 = call i32 @free(i32* %52)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [9 x i8] c"%d (%d)\0A\00"
@str = [9 x i8] c"Longeur?\00"
@str.4 = [8 x i8] c"Sortie:\00"
@str.5 = [8 x i8] c"Valeur?\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @promptValue()
%3 = shl i32 %2, 2
%4 = tail call i32* @malloc(i32 %3)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br label %21
8: ; preds = %0
%9 = zext i32 %2 to i64
br label %14
10: ; preds = %14
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
br i1 %5, label %12, label %21
12: ; preds = %10
%13 = zext i32 %2 to i64
br label %23
14: ; preds = %8, %14
%15 = phi i64 [ 0, %8 ], [ %19, %14 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%17 = tail call i32 (...) @promptValue()
%18 = getelementptr inbounds i32, i32* %4, i64 %15
store i32 %17, i32* %18
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %10, label %14
21: ; preds = %23, %6, %10
%22 = tail call i32 @free(i32* %4)
ret i32 0
23: ; preds = %12, %23
%24 = phi i64 [ 0, %12 ], [ %30, %23 ]
%25 = phi i32 [ 0, %12 ], [ %28, %23 ]
%26 = getelementptr inbounds i32, i32* %4, i64 %24
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %25
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28)
%30 = add nuw nsw i64 %24, 1
%31 = icmp eq i64 %30, %13
br i1 %31, label %21, label %23
}