#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 */
double pow(int, int);
double calcLikelihoodSum(int *I, int *ind, int numOnes) {
  double likelihoodSum = 0.0;
  int y;
  for (y = 0; y < numOnes; y++)
    likelihoodSum +=
        (pow((I[ind[y]] - 100), 2) - pow((I[ind[y]] - 228), 2)) / 50.0;
  return likelihoodSum;
}


x86 assembly (clang, -O0):
<calcLikelihoodSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <calcLikelihoodSum+0xa6>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%edi
sub    $0x64,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%edi
sub    $0xe4,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xe66(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <calcLikelihoodSum+0x22>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcLikelihoodSum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    119a <calcLikelihoodSum+0x8a>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
mov    $0xffffff1c,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
movslq (%r14,%rbx,4),%rax
mov    (%r12,%rax,4),%edi
add    $0xffffff9c,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movsd  %xmm0,(%rsp)
movslq (%r14,%rbx,4),%rax
mov    (%r12,%rax,4),%edi
add    %ebp,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
divsd  0xe75(%rip),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <calcLikelihoodSum+0x30>
jmp    119e <calcLikelihoodSum+0x8e>
xorpd  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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