#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 *, float);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
void ex1() {
  int n;
  do {
    puts("Informe o numero de valores:");
    scanf("%d", &n);
  } while (n <= 0);
  float array[n];
  for (int x = 0; x < n; x++) {
    printf("Informe o %d valor:\n", x + 1);
    scanf("%f", &array[x]);
  }
  for (int x = 0; x < n; x++) {
    printf("%f\n", array[x]);
  }
}


x86 assembly (clang, -O0):
<ex1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1138 <ex1+0x8>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11db <ex1+0xab>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118e <ex1+0x5e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1215 <ex1+0xe5>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e2 <ex1+0xb2>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex1>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%r14
lea    0xece(%rip),%r15
lea    -0x2c(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    1160 <ex1+0x30>
mov    %rsp,%r15
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    121c <ex1+0xec>
mov    %r15,-0x38(%rbp)
lea    0xe77(%rip),%r14
lea    0xe85(%rip),%r15
mov    %r13,%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
xorps  %xmm0,%xmm0
cvtsi2ss %r12d,%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     11c0 <ex1+0x90>
test   %eax,%eax
mov    -0x38(%rbp),%r15
jle    121c <ex1+0xec>
xor    %ebx,%ebx
lea    0xe39(%rip),%r14
nop
movss  0x0(%r13,%rbx,4),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1200 <ex1+0xd0>
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Informe o numero de valores:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Informe o %d valor:\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [4 x i8] c"%f\0A\00"
define void @ex1() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
br label %6
6: ; preds = %9, %0
%7 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %6
%10 = load i32, i32* %1
%11 = icmp sle i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %9
%13 = load i32, i32* %1
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %2
%16 = alloca float, i64 %14
store i64 %14, i64* %3
store i32 0, i32* %4
br label %17
17: ; preds = %30, %12
%18 = load i32, i32* %4
%19 = load i32, i32* %1
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
%24 = sitofp i32 %23 to float
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), float %24)
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %16, i64 %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %28)
br label %30
30: ; preds = %21
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %17
33: ; preds = %17
store i32 0, i32* %5
br label %34
34: ; preds = %44, %33
%35 = load i32, i32* %5
%36 = load i32, i32* %1
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %16, i64 %40
%42 = load float, float* %41
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %34
47: ; preds = %34
%48 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Informe o numero de valores:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Informe o %d valor:\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [4 x i8] c"%f\0A\00"
define void @ex1() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = zext i32 %6 to i64
%10 = call i8* @llvm.stacksave()
%11 = alloca float, i64 %9
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %16, label %27
14: ; preds = %16
%15 = icmp sgt i32 %24, 0
br i1 %15, label %28, label %27
16: ; preds = %8, %16
%17 = phi i64 [ %18, %16 ], [ 0, %8 ]
%18 = add nuw nsw i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to float
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), float %20)
%22 = getelementptr inbounds float, float* %11, i64 %17
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %22)
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %18, %25
br i1 %26, label %16, label %14
27: ; preds = %28, %8, %14
ret void
28: ; preds = %14, %28
%29 = phi i64 [ %33, %28 ], [ 0, %14 ]
%30 = getelementptr inbounds float, float* %11, i64 %29
%31 = load float, float* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %31)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %27
}