#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*/ escribeVector(int, double *);
int /*<<< orphan*/ leerVector(int, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sumaPositivos(int, double *, double *);
int main() {
  int nEle;
  double suma = 0;
  printf("Introduzca el numero de elementos del vector: ");
  scanf("%d", &nEle);
  double vector[nEle];
  leerVector(nEle, vector);
  escribeVector(nEle, vector);
  sumaPositivos(nEle, vector, &suma);
  printf("Suma de todos los elemetos positivos del vecto → %lf\n", suma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <leerVector@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1070 <escribeVector@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rdx
call   1040 <sumaPositivos@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xe56(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%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   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,-0x20(%rbp)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,%r14
mov    -0x14(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1030 <leerVector@plt>
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1070 <escribeVector@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    %rbx,%rsi
call   1040 <sumaPositivos@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Introduzca el numero de elementos del vector: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"Suma de todos los elemetos positivos del vecto \E2\86\92 %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
store double 0.000000e+00, double* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca double, i64 %9
store i64 %9, i64* %5
%12 = load i32, i32* %2
%13 = call i32 @leerVector(i32 %12, double* %11)
%14 = load i32, i32* %2
%15 = call i32 @escribeVector(i32 %14, double* %11)
%16 = load i32, i32* %2
%17 = call i32 @sumaPositivos(i32 %16, double* %11, double* %3)
%18 = load double, double* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), double %18)
store i32 0, i32* %1
%20 = load i8*, i8** %4
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [47 x i8] c"Introduzca el numero de elementos del vector: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"Suma de todos los elemetos positivos del vecto \E2\86\92 %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 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 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca double, i64 %8
%11 = load i32, i32* %1
%12 = call i32 @leerVector(i32 %11, double* %10)
%13 = load i32, i32* %1
%14 = call i32 @escribeVector(i32 %13, double* %10)
%15 = load i32, i32* %1
%16 = call i32 @sumaPositivos(i32 %15, double* %10, double* %2)
%17 = load double, double* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), double %17)
ret i32 0
}