#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 */
scalar_t__ fun(int);
int /*<<< orphan*/ printf(char *, float);
void main() {
  int n, s = 0, m = 0;
  float ave;
  for (n = 1; n <= 100; n++) {
    if (fun(n)) {
      s = s + n;
      m++;
    }
  }
  ave = 1.0 * s / m;
  printf("%f", ave);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jg     117e <main+0x5e>
mov    -0x4(%rbp),%edi
call   1030 <fun@plt>
cmp    $0x0,%rax
je     116b <main+0x4b>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1170 <main+0x50>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113d <main+0x1d>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe75(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
mov    $0x1,%ebx
xor    %r15d,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1030 <fun@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ebx,%eax
cmove  %r14d,%eax
add    %eax,%ebp
add    %ecx,%r15d
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1140 <main+0x20>
cvtsi2sd %ebp,%xmm0
cvtsi2sd %r15d,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xe86(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define void @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %12, %1 ]
%3 = phi i32 [ 0, %0 ], [ %11, %1 ]
%4 = phi i32 [ 0, %0 ], [ %8, %1 ]
%5 = tail call i64 @fun(i32 %2)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i32 0, i32 %2
%8 = add nuw nsw i32 %7, %4
%9 = xor i1 %6, true
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %3, %10
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 101
br i1 %13, label %14, label %1
14: ; preds = %1
%15 = sitofp i32 %8 to double
%16 = sitofp i32 %11 to double
%17 = fdiv double %15, %16
%18 = fptrunc double %17 to float
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %18)
ret void
}