#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 *, double);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  int i, q = 0;
  double numero, soma = 0.0;
  for (i = 0; i < 6; i++) {
    scanf("%lf", &numero);
    if (numero > 0.0) {
      soma += numero;
      q++;
    }
  }
  printf("%d valores positivos\n", q);
  printf("%.1f\n", soma / q);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    119c <main+0x7c>
lea    0xeaa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1189 <main+0x69>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118e <main+0x6e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1145 <main+0x25>
cvtsi2sdl -0xc(%rbp),%xmm0
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xee1(%rip),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
movapd %xmm0,%xmm1
maxsd  0xea9(%rip),%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movaps %xmm0,0x40(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm1
movapd 0x30(%rsp),%xmm3
movapd %xmm3,%xmm0
unpcklpd %xmm1,%xmm0
movapd %xmm0,0x50(%rsp)
movapd 0x20(%rsp),%xmm0
movapd 0x40(%rsp),%xmm2
unpcklpd %xmm2,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0xe2c(%rip),%xmm0
maxsd  %xmm0,%xmm2
addsd  0x10(%rsp),%xmm2
maxsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
maxsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm1,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xor    %ebp,%ebp
ucomisd 0xdf9(%rip),%xmm0
seta   %bpl
maxsd  0xde5(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm1
xor    %eax,%eax
ucomisd 0xdc6(%rip),%xmm1
seta   %al
xorpd  %xmm0,%xmm0
cmpltpd 0x20(%rsp),%xmm0
xorpd  %xmm2,%xmm2
cmpltpd 0x50(%rsp),%xmm2
packssdw %xmm2,%xmm0
movmskps %xmm0,%ecx
mov    %ecx,%edx
shr    %dl
and    $0x5,%dl
sub    %dl,%cl
mov    %ecx,%edx
and    $0x33,%dl
shr    $0x2,%cl
and    $0x33,%cl
add    %dl,%cl
mov    %ecx,%edx
shr    $0x4,%dl
add    %cl,%dl
and    $0xf,%dl
movzbl %dl,%ecx
add    %ebp,%ecx
add    %eax,%ecx
maxsd  0xd6f(%rip),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd63(%rip),%rdi
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
lea    0xd61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [22 x i8] c"%d valores positivos\0A\00"
@.str.2 = [6 x i8] c"%.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store i32 0, i32* %3
store double 0.000000e+00, double* %5
store i32 0, i32* %2
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %4)
%11 = load double, double* %4
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fadd double %15, %14
store double %16, double* %5
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %13, %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %6
23: ; preds = %6
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to double
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = load double, double* %5
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fdiv double %27, %29
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [22 x i8] c"%d valores positivos\0A\00"
@.str.2 = [6 x i8] c"%.1f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fcmp ogt double %4, -0.000000e+00
%6 = select i1 %5, double %4, double -0.000000e+00
%7 = fadd double %6, 0.000000e+00
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%9 = load double, double* %1
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%11 = load double, double* %1
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%13 = load double, double* %1
%14 = insertelement <4 x double> poison, double %4, i64 0
%15 = insertelement <4 x double> %14, double %9, i64 1
%16 = insertelement <4 x double> %15, double %11, i64 2
%17 = insertelement <4 x double> %16, double %13, i64 3
%18 = fcmp ogt <4 x double> %17, zeroinitializer
%19 = fcmp ogt double %9, -0.000000e+00
%20 = select i1 %19, double %9, double -0.000000e+00
%21 = fadd double %7, %20
%22 = fcmp ogt double %11, -0.000000e+00
%23 = select i1 %22, double %11, double -0.000000e+00
%24 = fadd double %21, %23
%25 = fcmp ogt double %13, -0.000000e+00
%26 = select i1 %25, double %13, double -0.000000e+00
%27 = fadd double %24, %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%29 = load double, double* %1
%30 = fcmp ogt double %29, 0.000000e+00
%31 = zext i1 %30 to i32
%32 = fcmp ogt double %29, -0.000000e+00
%33 = select i1 %32, double %29, double -0.000000e+00
%34 = fadd double %27, %33
%35 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%36 = load double, double* %1
%37 = fcmp ogt double %36, 0.000000e+00
%38 = zext i1 %37 to i32
%39 = bitcast <4 x i1> %18 to i4
%40 = call i4 @llvm.ctpop.i4(i4 %39)
%41 = zext i4 %40 to i32
%42 = add nuw nsw i32 %41, %31
%43 = add nuw nsw i32 %42, %38
%44 = fcmp ogt double %36, -0.000000e+00
%45 = select i1 %44, double %36, double -0.000000e+00
%46 = fadd double %34, %45
%47 = sitofp i32 %43 to double
%48 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %47)
%49 = fdiv double %46, %47
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %49)
ret i32 0
}