#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 */
float exp(double);
scalar_t__ pow(float, int);
float likelihood(float *f_obs, float *f_mod) {
  float suma = 0;
  int i;
  for (i = 0; i < 4141; i++) {
    suma += pow(f_obs[i] - f_mod[i], 2);
  }
  return exp(-(1.0 / 2.0) * suma);
}


x86 assembly (clang, -O0):
<likelihood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x102d,-0x18(%rbp)
jge    118d <likelihood+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2ss %rax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113f <likelihood+0x1f>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe62(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<likelihood>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x1,%ebx
nopl   (%rax)
movss  -0x4(%r15,%rbx,4),%xmm0
subss  -0x4(%r14,%rbx,4),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
cmp    $0x102d,%rbx
je     11a9 <likelihood+0x89>
movss  %xmm0,0xc(%rsp)
movss  (%r15,%rbx,4),%xmm0
subss  (%r14,%rbx,4),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
add    $0x2,%rbx
movss  %xmm1,0xc(%rsp)
jmp    1140 <likelihood+0x20>
cvtss2sd %xmm0,%xmm0
mulsd  0xe4b(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <exp@plt>

LLVM IR (-O0):
define float @likelihood(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca i32
store float* %0, float** %3
store float* %1, float** %4
store float 0.000000e+00, float* %5
store i32 0, i32* %6
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 4141
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = load float*, float** %3
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds float, float* %11, i64 %13
%15 = load float, float* %14
%16 = load float*, float** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %16, i64 %18
%20 = load float, float* %19
%21 = fsub float %15, %20
%22 = call i64 @pow(float %21, i32 2)
%23 = sitofp i64 %22 to float
%24 = load float, float* %5
%25 = fadd float %24, %23
store float %25, float* %5
br label %26
26: ; preds = %10
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %7
29: ; preds = %7
%30 = load float, float* %5
%31 = fpext float %30 to double
%32 = fmul double -5.000000e-01, %31
%33 = call float @exp(double %32)
ret float %33
}

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