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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jg     119c <main+0x7c>
lea    0xeaa(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1189 <main+0x69>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118e <main+0x6e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <main+0x25>
cvtsi2sdl -0x20(%rbp),%xmm0
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x20(%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   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xeda(%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  0xeaa(%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
movapd %xmm0,0x30(%rsp)
maxsd  0xe7d(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movapd %xmm0,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),%xmm1
movapd 0x40(%rsp),%xmm2
movapd %xmm2,%xmm0
unpcklpd %xmm1,%xmm0
movapd %xmm0,0x50(%rsp)
movaps 0x20(%rsp),%xmm0
unpcklpd 0x30(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0xe1e(%rip),%xmm0
maxsd  %xmm0,%xmm2
addsd  0x10(%rsp),%xmm2
maxsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
xorpd  %xmm0,%xmm0
cmplepd 0x20(%rsp),%xmm0
xorpd  %xmm1,%xmm1
cmplepd 0x50(%rsp),%xmm1
packssdw %xmm1,%xmm0
movmskps %xmm0,%eax
mov    %eax,%ecx
shr    %cl
and    $0x5,%cl
sub    %cl,%al
mov    %eax,%ecx
and    $0x33,%cl
shr    $0x2,%al
and    $0x33,%al
add    %cl,%al
mov    %eax,%ecx
shr    $0x4,%cl
add    %al,%cl
and    $0xf,%cl
xorps  %xmm0,%xmm0
movsd  0x30(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movsd  0xd93(%rip),%xmm1
maxsd  %xmm1,%xmm2
addsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
movzbl %cl,%eax
sbb    $0xffffffff,%eax
ucomisd %xmm0,%xmm3
maxsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x20(%rsp)
sbb    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd60(%rip),%rdi
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
lea    0xd5e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
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 double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store i32 0, i32* %5
store i32 1, i32* %4
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %4
%8 = icmp sle 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* %2)
%11 = load double, double* %2
%12 = fcmp oge double %11, 0.000000e+00
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load double, double* %2
%17 = load double, double* %3
%18 = fadd double %17, %16
store double %18, double* %3
br label %19
19: ; preds = %13, %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %6
%24 = load i32, i32* %5
%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* %3
%28 = load i32, i32* %5
%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 = fcmp ogt double %9, -0.000000e+00
%11 = select i1 %10, double %9, double -0.000000e+00
%12 = fadd double %7, %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%14 = load double, double* %1
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%16 = load double, double* %1
%17 = insertelement <4 x double> poison, double %4, i64 0
%18 = insertelement <4 x double> %17, double %9, i64 1
%19 = insertelement <4 x double> %18, double %14, i64 2
%20 = insertelement <4 x double> %19, double %16, i64 3
%21 = fcmp oge <4 x double> %20, zeroinitializer
%22 = fcmp ogt double %14, -0.000000e+00
%23 = select i1 %22, double %14, double -0.000000e+00
%24 = fadd double %12, %23
%25 = fcmp ogt double %16, -0.000000e+00
%26 = select i1 %25, double %16, 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 oge double %29, 0.000000e+00
%31 = fcmp ogt double %29, -0.000000e+00
%32 = select i1 %31, double %29, double -0.000000e+00
%33 = fadd double %27, %32
%34 = zext i1 %30 to i32
%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 oge double %36, 0.000000e+00
%38 = fcmp ogt double %36, -0.000000e+00
%39 = select i1 %38, double %36, double -0.000000e+00
%40 = fadd double %33, %39
%41 = zext i1 %37 to i32
%42 = bitcast <4 x i1> %21 to i4
%43 = call i4 @llvm.ctpop.i4(i4 %42)
%44 = zext i4 %43 to i32
%45 = add nuw nsw i32 %44, %34
%46 = add nuw nsw i32 %45, %41
%47 = sitofp i32 %46 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 %40, %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
}