#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 */
struct parameters {
  int dummy;
};
struct dataSet {
  int dummy;
};
struct chromosome {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ executeChromosome(struct chromosome *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ getChromosomeOutput(struct chromosome *, int);
int /*<<< orphan*/ getDataSetSampleInputs(struct dataSet *, int);
scalar_t__ getDataSetSampleOutput(struct dataSet *, int, int);
scalar_t__ getNumChromosomeInputs(struct chromosome *);
int getNumChromosomeOutputs(struct chromosome *);
scalar_t__ getNumDataSetInputs(struct dataSet *);
double getNumDataSetOutputs(struct dataSet *);
double getNumDataSetSamples(struct dataSet *);
scalar_t__ pow(scalar_t__, int);
int /*<<< orphan*/ printf(char *);
double meanSquareError(struct parameters *params, struct chromosome *chromo,
                       struct dataSet *data) {
  int i, j;
  double squareError = 0;
  if (getNumChromosomeInputs(chromo) != getNumDataSetInputs(data)) {
    printf("Error: the number of chromosome inputs must match the number of "
           "inputs specified in the dataSet.\n");
    printf("Terminating.\n");
    exit(0);
  }
  if (getNumChromosomeOutputs(chromo) != getNumDataSetOutputs(data)) {
    printf("Error: the number of chromosome outputs must match the number of "
           "outputs specified in the dataSet.\n");
    printf("Terminating.\n");
    exit(0);
  }
  for (i = 0; i < getNumDataSetSamples(data); i++) {
    executeChromosome(chromo, getDataSetSampleInputs(data, i));
    for (j = 0; j < getNumChromosomeOutputs(chromo); j++) {
      squareError += pow(getDataSetSampleOutput(data, i, j) -
                             getChromosomeOutput(chromo, j),
                         2);
    }
  }
  return squareError /
         (getNumDataSetSamples(data) * getNumDataSetOutputs(data));
}


x86 assembly (clang, -O0):
<meanSquareError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getNumChromosomeInputs@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <getNumDataSetInputs@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1221 <meanSquareError+0x61>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1090 <getNumChromosomeOutputs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getNumDataSetOutputs@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    1259 <meanSquareError+0x99>
jp     1259 <meanSquareError+0x99>
jmp    1278 <meanSquareError+0xb8>
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
lea    0xdf6(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <getNumDataSetSamples@plt>
movsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1343 <meanSquareError+0x183>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <getDataSetSampleInputs@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   10b0 <executeChromosome@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getNumChromosomeOutputs@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
jge    1330 <meanSquareError+0x170>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10a0 <getDataSetSampleOutput@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   10e0 <getChromosomeOutput@plt>
mov    -0x58(%rbp),%rdi
sub    %rax,%rdi
mov    $0x2,%esi
call   10c0 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12c7 <meanSquareError+0x107>
jmp    1335 <meanSquareError+0x175>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    127f <meanSquareError+0xbf>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <getNumDataSetSamples@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getNumDataSetOutputs@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<meanSquareError>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rsi,%rdi
call   1050 <getNumChromosomeInputs@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   1080 <getNumDataSetInputs@plt>
cmp    %rax,%rbp
jne    132a <meanSquareError+0x16a>
mov    %r12,%rdi
call   1090 <getNumChromosomeOutputs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1070 <getNumDataSetOutputs@plt>
ucomisd (%rsp),%xmm0
jne    1333 <meanSquareError+0x173>
jp     1333 <meanSquareError+0x173>
mov    %r14,%rdi
call   1040 <getNumDataSetSamples@plt>
xorpd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
ucomisd %xmm2,%xmm0
jbe    12f4 <meanSquareError+0x134>
xor    %r15d,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    1276 <meanSquareError+0xb6>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15d
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1040 <getNumDataSetSamples@plt>
ucomisd 0x8(%rsp),%xmm0
jbe    12f4 <meanSquareError+0x134>
mov    %r14,%rdi
mov    %r15d,%esi
call   1060 <getDataSetSampleInputs@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   10b0 <executeChromosome@plt>
mov    %r12,%rdi
call   1090 <getNumChromosomeOutputs@plt>
test   %eax,%eax
jle    1250 <meanSquareError+0x90>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   10a0 <getDataSetSampleOutput@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %ebp,%esi
call   10e0 <getChromosomeOutput@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
call   10c0 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%ebp
mov    %r12,%rdi
call   1090 <getNumChromosomeOutputs@plt>
cmp    %eax,%ebp
jl     12a0 <meanSquareError+0xe0>
jmp    1250 <meanSquareError+0x90>
mov    %r14,%rdi
call   1040 <getNumDataSetSamples@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1070 <getNumDataSetOutputs@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd32(%rip),%rdi
jmp    133a <meanSquareError+0x17a>
lea    0xcc6(%rip),%rdi
call   1030 <puts@plt>
lea    0xd7e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
%struct.dataSet = type { i32 }
@.str = [98 x i8] c"Error: the number of chromosome inputs must match the number of inputs specified in the dataSet.\0A\00"
@.str.1 = [14 x i8] c"Terminating.\0A\00"
@.str.2 = [100 x i8] c"Error: the number of chromosome outputs must match the number of outputs specified in the dataSet.\0A\00"
define double @meanSquareError(%struct.parameters* %0, %struct.chromosome* %1, %struct.dataSet* %2) {
%4 = alloca %struct.parameters*
%5 = alloca %struct.chromosome*
%6 = alloca %struct.dataSet*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store %struct.parameters* %0, %struct.parameters** %4
store %struct.chromosome* %1, %struct.chromosome** %5
store %struct.dataSet* %2, %struct.dataSet** %6
store double 0.000000e+00, double* %9
%10 = load %struct.chromosome*, %struct.chromosome** %5
%11 = call i64 @getNumChromosomeInputs(%struct.chromosome* %10)
%12 = load %struct.dataSet*, %struct.dataSet** %6
%13 = call i64 @getNumDataSetInputs(%struct.dataSet* %12)
%14 = icmp ne i64 %11, %13
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %3
%20 = load %struct.chromosome*, %struct.chromosome** %5
%21 = call i32 @getNumChromosomeOutputs(%struct.chromosome* %20)
%22 = sitofp i32 %21 to double
%23 = load %struct.dataSet*, %struct.dataSet** %6
%24 = call double @getNumDataSetOutputs(%struct.dataSet* %23)
%25 = fcmp une double %22, %24
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %19
store i32 0, i32* %7
br label %31
31: ; preds = %65, %30
%32 = load i32, i32* %7
%33 = sitofp i32 %32 to double
%34 = load %struct.dataSet*, %struct.dataSet** %6
%35 = call double @getNumDataSetSamples(%struct.dataSet* %34)
%36 = fcmp olt double %33, %35
br i1 %36, label %37, label %68
37: ; preds = %31
%38 = load %struct.chromosome*, %struct.chromosome** %5
%39 = load %struct.dataSet*, %struct.dataSet** %6
%40 = load i32, i32* %7
%41 = call i32 @getDataSetSampleInputs(%struct.dataSet* %39, i32 %40)
%42 = call i32 @executeChromosome(%struct.chromosome* %38, i32 %41)
store i32 0, i32* %8
br label %43
43: ; preds = %61, %37
%44 = load i32, i32* %8
%45 = load %struct.chromosome*, %struct.chromosome** %5
%46 = call i32 @getNumChromosomeOutputs(%struct.chromosome* %45)
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %64
48: ; preds = %43
%49 = load %struct.dataSet*, %struct.dataSet** %6
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i64 @getDataSetSampleOutput(%struct.dataSet* %49, i32 %50, i32 %51)
%53 = load %struct.chromosome*, %struct.chromosome** %5
%54 = load i32, i32* %8
%55 = call i64 @getChromosomeOutput(%struct.chromosome* %53, i32 %54)
%56 = sub nsw i64 %52, %55
%57 = call i64 @pow(i64 %56, i32 2)
%58 = sitofp i64 %57 to double
%59 = load double, double* %9
%60 = fadd double %59, %58
store double %60, double* %9
br label %61
61: ; preds = %48
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %43
64: ; preds = %43
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %31
68: ; preds = %31
%69 = load double, double* %9
%70 = load %struct.dataSet*, %struct.dataSet** %6
%71 = call double @getNumDataSetSamples(%struct.dataSet* %70)
%72 = load %struct.dataSet*, %struct.dataSet** %6
%73 = call double @getNumDataSetOutputs(%struct.dataSet* %72)
%74 = fmul double %71, %73
%75 = fdiv double %69, %74
ret double %75
}

LLVM IR (-O2):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
%struct.dataSet = type { i32 }
@str = [99 x i8] c"Error: the number of chromosome outputs must match the number of outputs specified in the dataSet.\00"
@str.4 = [97 x i8] c"Error: the number of chromosome inputs must match the number of inputs specified in the dataSet.\00"
@str.5 = [13 x i8] c"Terminating.\00"
define double @meanSquareError(%struct.parameters* nocapture readnone %0, %struct.chromosome* %1, %struct.dataSet* %2) {
%4 = tail call i64 @getNumChromosomeInputs(%struct.chromosome* %1)
%5 = tail call i64 @getNumDataSetInputs(%struct.dataSet* %2)
%6 = icmp eq i64 %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %3
%12 = tail call i32 @getNumChromosomeOutputs(%struct.chromosome* %1)
%13 = sitofp i32 %12 to double
%14 = tail call double @getNumDataSetOutputs(%struct.dataSet* %2)
%15 = fcmp une double %14, %13
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = tail call double @getNumDataSetSamples(%struct.dataSet* %2)
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %23, label %48
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %16, %42
%24 = phi double [ %43, %42 ], [ 0.000000e+00, %16 ]
%25 = phi i32 [ %44, %42 ], [ 0, %16 ]
%26 = tail call i32 @getDataSetSampleInputs(%struct.dataSet* %2, i32 %25)
%27 = tail call i32 @executeChromosome(%struct.chromosome* %1, i32 %26)
%28 = tail call i32 @getNumChromosomeOutputs(%struct.chromosome* %1)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %42
30: ; preds = %23, %30
%31 = phi double [ %38, %30 ], [ %24, %23 ]
%32 = phi i32 [ %39, %30 ], [ 0, %23 ]
%33 = tail call i64 @getDataSetSampleOutput(%struct.dataSet* %2, i32 %25, i32 %32)
%34 = tail call i64 @getChromosomeOutput(%struct.chromosome* %1, i32 %32)
%35 = sub nsw i64 %33, %34
%36 = tail call i64 @pow(i64 %35, i32 2)
%37 = sitofp i64 %36 to double
%38 = fadd double %31, %37
%39 = add nuw nsw i32 %32, 1
%40 = tail call i32 @getNumChromosomeOutputs(%struct.chromosome* %1)
%41 = icmp slt i32 %39, %40
br i1 %41, label %30, label %42
42: ; preds = %30, %23
%43 = phi double [ %24, %23 ], [ %38, %30 ]
%44 = add nuw nsw i32 %25, 1
%45 = sitofp i32 %44 to double
%46 = tail call double @getNumDataSetSamples(%struct.dataSet* %2)
%47 = fcmp ogt double %46, %45
br i1 %47, label %23, label %48
48: ; preds = %42, %16
%49 = phi double [ 0.000000e+00, %16 ], [ %43, %42 ]
%50 = tail call double @getNumDataSetSamples(%struct.dataSet* %2)
%51 = tail call double @getNumDataSetOutputs(%struct.dataSet* %2)
%52 = fmul double %50, %51
%53 = fdiv double %49, %52
ret double %53
}