#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 */
double fact(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void ex1() {
  int v[10];
  double w[10];
  for (int k = 0; k < 10; k++) {
    printf("Digite um numero: ");
    scanf("%d", &v[k]);
    w[k] = fact(v[k]);
  }
}


x86 assembly (clang, -O0):
<ex1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x84(%rbp)
cmpl   $0xa,-0x84(%rbp)
jge    11ad <ex1+0x7d>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
movslq -0x84(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe9c(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x84(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edi
call   1040 <fact@plt>
movslq -0x84(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1145 <ex1+0x15>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex1>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xec6(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x14(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x18(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x1c(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x20(%rsp),%edi
call   1040 <fact@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x24(%rsp),%edi
call   1040 <fact@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @ex1() {
%1 = alloca [10 x i32]
%2 = alloca [10 x double]
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %21, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %10
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call double @fact(i32 %16)
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x double], [10 x double]* %2, i64 0, i64 %19
store double %17, double* %20
br label %21
21: ; preds = %7
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @ex1() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = load i32, i32* %4
%7 = call double @fact(i32 %6)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%11 = load i32, i32* %9
%12 = call double @fact(i32 %11)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %14
%17 = call double @fact(i32 %16)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %19
%22 = call double @fact(i32 %21)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
%26 = load i32, i32* %24
%27 = call double @fact(i32 %26)
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = load i32, i32* %29
%32 = call double @fact(i32 %31)
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
%36 = load i32, i32* %34
%37 = call double @fact(i32 %36)
%38 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %39)
%41 = load i32, i32* %39
%42 = call double @fact(i32 %41)
%43 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %44)
%46 = load i32, i32* %44
%47 = call double @fact(i32 %46)
%48 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %49)
%51 = load i32, i32* %49
%52 = call double @fact(i32 %51)
ret void
}