#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__ pow(double, int);
double sum_residual_error(double scaled_frequencies[26]) {
  register int i;
  double ErrorSum;
  double English_Frequencies[] = {
      8.167, 1.492, 2.782, 4.253, 12.702, 2.228, 2.015, 6.094, 6.996,
      0.153, 0.772, 4.025, 2.406, 6.749,  7.507, 1.929, 0.095, 5.987,
      6.327, 9.056, 2.758, 0.978, 2.360,  0.150, 1.974, 0.074};
  ErrorSum = 0;
  for (i = 0; i < 26; i++)
    ErrorSum += pow((scaled_frequencies[i] - English_Frequencies[i]), 2);
  return ErrorSum;
}


x86 assembly (clang, -O0):
<sum_residual_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xf0(%rbp),%rdi
lea    0xec3(%rip),%rsi
mov    $0xd0,%edx
call   1030 <memcpy@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1a,-0xc(%rbp)
jge    11a1 <sum_residual_error+0x81>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xc(%rbp),%rax
subsd  -0xf0(%rbp,%rax,8),%xmm0
ff ff
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <sum_residual_error+0x36>
movsd  -0x18(%rbp),%xmm0
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_residual_error>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
lea    0xed4(%rip),%r15
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
movsd  -0x8(%r14,%rbx,8),%xmm0
subsd  -0x8(%r15,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%r14,%rbx,8),%xmm0
subsd  (%r15,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%rbx
cmp    $0x1b,%rbx
jne    1130 <sum_residual_error+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.sum_residual_error.English_Frequencies = [26 x double] [double 8.167000e+00, double 1.492000e+00, double 2.782000e+00, double 4.253000e+00, double 1.270200e+01, double 2.228000e+00, double 2.015000e+00, double 6.094000e+00, double 6.996000e+00, double 1.530000e-01, double 7.720000e-01, double 4.025000e+00, double 2.406000e+00, double 6.749000e+00, double 7.507000e+00, double 1.929000e+00, double 9.500000e-02, double 5.987000e+00, double 6.327000e+00, double 9.056000e+00, double 2.758000e+00, double 0x3FEF4BC6A7EF9DB2, double 2.360000e+00, double 1.500000e-01, double 1.974000e+00, double 0x3FB2F1A9FBE76C8B]
define double @sum_residual_error(double* %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca double
%5 = alloca [26 x double]
store double* %0, double** %2
%6 = bitcast [26 x double]* %5 to i8*
store double 0.000000e+00, double* %4
store i32 0, i32* %3
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 26
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load double*, double** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [26 x double], [26 x double]* %5, i64 0, i64 %17
%19 = load double, double* %18
%20 = fsub double %15, %19
%21 = call i64 @pow(double %20, i32 2)
%22 = sitofp i64 %21 to double
%23 = load double, double* %4
%24 = fadd double %23, %22
store double %24, double* %4
br label %25
25: ; preds = %10
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
%29 = load double, double* %4
ret double %29
}

LLVM IR (-O2):
@__const.sum_residual_error.English_Frequencies = [26 x double] [double 8.167000e+00, double 1.492000e+00, double 2.782000e+00, double 4.253000e+00, double 1.270200e+01, double 2.228000e+00, double 2.015000e+00, double 6.094000e+00, double 6.996000e+00, double 1.530000e-01, double 7.720000e-01, double 4.025000e+00, double 2.406000e+00, double 6.749000e+00, double 7.507000e+00, double 1.929000e+00, double 9.500000e-02, double 5.987000e+00, double 6.327000e+00, double 9.056000e+00, double 2.758000e+00, double 0x3FEF4BC6A7EF9DB2, double 2.360000e+00, double 1.500000e-01, double 1.974000e+00, double 0x3FB2F1A9FBE76C8B]
define double @sum_residual_error(double* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %22, %2 ]
%4 = phi double [ 0.000000e+00, %1 ], [ %21, %2 ]
%5 = getelementptr inbounds double, double* %0, i64 %3
%6 = load double, double* %5
%7 = getelementptr inbounds [26 x double], [26 x double]* @__const.sum_residual_error.English_Frequencies, i64 0, i64 %3
%8 = load double, double* %7
%9 = fsub double %6, %8
%10 = tail call i64 @pow(double %9, i32 2)
%11 = sitofp i64 %10 to double
%12 = fadd double %4, %11
%13 = or i64 %3, 1
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = getelementptr inbounds [26 x double], [26 x double]* @__const.sum_residual_error.English_Frequencies, i64 0, i64 %13
%17 = load double, double* %16
%18 = fsub double %15, %17
%19 = tail call i64 @pow(double %18, i32 2)
%20 = sitofp i64 %19 to double
%21 = fadd double %12, %20
%22 = add nuw nsw i64 %3, 2
%23 = icmp eq i64 %22, 26
br i1 %23, label %24, label %2
24: ; preds = %2
ret double %21
}