#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__ fmod(double, int);
double unpairsAverage(double arr[], int size) {
  int i, counter = 0;
  float sum = 0;
  for (i = 0; i < size; ++i)
    if (fmod(arr[i], 2) != 0) {
      sum += arr[i];
      ++counter;
    }
  return (sum / counter);
}


x86 assembly (clang, -O0):
<unpairsAverage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a1 <unpairsAverage+0x91>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <fmod@plt>
cmp    $0x0,%rax
je     118e <unpairsAverage+0x7e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <unpairsAverage+0x83>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <unpairsAverage+0x25>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpairsAverage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    117c <unpairsAverage+0x6c>
mov    %rdi,%rbx
mov    %esi,%r14d
xor    %ebp,%ebp
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %r15d,%r15d
jmp    1149 <unpairsAverage+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r14
je     1188 <unpairsAverage+0x78>
movsd  (%rbx,%rbp,8),%xmm0
mov    $0x2,%edi
call   1030 <fmod@plt>
test   %rax,%rax
je     1140 <unpairsAverage+0x30>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  (%rbx,%rbp,8),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
add    $0x1,%r15d
jmp    1140 <unpairsAverage+0x30>
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %r15d,%r15d
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @unpairsAverage(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store float 0.000000e+00, float* %7
store i32 0, i32* %5
br label %8
8: ; preds = %33, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = load double*, double** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call i64 @fmod(double %17, i32 2)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %32
20: ; preds = %12
%21 = load double*, double** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load float, float* %7
%27 = fpext float %26 to double
%28 = fadd double %27, %25
%29 = fptrunc double %28 to float
store float %29, float* %7
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %32
32: ; preds = %20, %12
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %8
36: ; preds = %8
%37 = load float, float* %7
%38 = load i32, i32* %6
%39 = sitofp i32 %38 to float
%40 = fdiv float %37, %39
%41 = fpext float %40 to double
ret double %41
}

LLVM IR (-O2):
define double @unpairsAverage(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %20
%7 = phi i64 [ 0, %4 ], [ %23, %20 ]
%8 = phi float [ 0.000000e+00, %4 ], [ %22, %20 ]
%9 = phi i32 [ 0, %4 ], [ %21, %20 ]
%10 = getelementptr inbounds double, double* %0, i64 %7
%11 = load double, double* %10
%12 = tail call i64 @fmod(double %11, i32 2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %6
%15 = load double, double* %10
%16 = fpext float %8 to double
%17 = fadd double %15, %16
%18 = fptrunc double %17 to float
%19 = add nsw i32 %9, 1
br label %20
20: ; preds = %6, %14
%21 = phi i32 [ %19, %14 ], [ %9, %6 ]
%22 = phi float [ %18, %14 ], [ %8, %6 ]
%23 = add nuw nsw i64 %7, 1
%24 = icmp eq i64 %23, %5
br i1 %24, label %25, label %6
25: ; preds = %20, %2
%26 = phi i32 [ 0, %2 ], [ %21, %20 ]
%27 = phi float [ 0.000000e+00, %2 ], [ %22, %20 ]
%28 = sitofp i32 %26 to float
%29 = fdiv float %27, %28
%30 = fpext float %29 to double
ret double %30
}