#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__ fabs(scalar_t__);
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 *);
int getNumDataSetOutputs(struct dataSet *);
int getNumDataSetSamples(struct dataSet *);
int /*<<< orphan*/ printf(char *);
double supervisedLearning(struct parameters *params, struct chromosome *chromo,
                          struct dataSet *data) {
  int i, j;
  double error = 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 CGP-Library.\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 CGP-Library.\n");
    exit(0);
  }
  for (i = 0; i < getNumDataSetSamples(data); i++) {
    executeChromosome(chromo, getDataSetSampleInputs(data, i));
    for (j = 0; j < getNumChromosomeOutputs(chromo); j++) {
      error += fabs(getChromosomeOutput(chromo, j) -
                    getDataSetSampleOutput(data, i, j));
    }
  }
  return error;
}


x86 assembly (clang, -O0):
<supervisedLearning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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   1090 <getNumDataSetInputs@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1221 <supervisedLearning+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   10a0 <getNumChromosomeOutputs@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getNumDataSetOutputs@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
je     1262 <supervisedLearning+0xa2>
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <getNumDataSetSamples@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    1322 <supervisedLearning+0x162>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <getDataSetSampleInputs@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   10c0 <executeChromosome@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <getNumChromosomeOutputs@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    130f <supervisedLearning+0x14f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   10e0 <getChromosomeOutput@plt>
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10b0 <getDataSetSampleOutput@plt>
mov    -0x50(%rbp),%rdi
sub    %rax,%rdi
call   1080 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ab <supervisedLearning+0xeb>
jmp    1314 <supervisedLearning+0x154>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1269 <supervisedLearning+0xa9>
movsd  -0x28(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supervisedLearning>:
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   1090 <getNumDataSetInputs@plt>
cmp    %rax,%rbp
jne    12de <supervisedLearning+0x11e>
mov    %r12,%rdi
call   10a0 <getNumChromosomeOutputs@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1070 <getNumDataSetOutputs@plt>
cmp    %eax,%ebp
jne    12e7 <supervisedLearning+0x127>
mov    %r14,%rdi
call   1040 <getNumDataSetSamples@plt>
test   %eax,%eax
jle    12c1 <supervisedLearning+0x101>
xor    %r15d,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1245 <supervisedLearning+0x85>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    %r14,%rdi
call   1040 <getNumDataSetSamples@plt>
cmp    %eax,%r15d
jge    12cb <supervisedLearning+0x10b>
mov    %r14,%rdi
mov    %r15d,%esi
call   1060 <getDataSetSampleInputs@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   10c0 <executeChromosome@plt>
mov    %r12,%rdi
call   10a0 <getNumChromosomeOutputs@plt>
test   %eax,%eax
jle    1230 <supervisedLearning+0x70>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
call   10e0 <getChromosomeOutput@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   10b0 <getDataSetSampleOutput@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
call   1080 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%ebp
mov    %r12,%rdi
call   10a0 <getNumChromosomeOutputs@plt>
cmp    %eax,%ebp
jl     1270 <supervisedLearning+0xb0>
jmp    1230 <supervisedLearning+0x70>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd7e(%rip),%rdi
jmp    12ee <supervisedLearning+0x12e>
lea    0xd12(%rip),%rdi
call   1030 <puts@plt>
lea    0xdca(%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 = [26 x i8] c"Terminating CGP-Library.\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 @supervisedLearning(%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 ([26 x i8], [26 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 = load %struct.dataSet*, %struct.dataSet** %6
%23 = call i32 @getNumDataSetOutputs(%struct.dataSet* %22)
%24 = icmp ne i32 %21, %23
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = call i32 @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %19
store i32 0, i32* %7
br label %30
30: ; preds = %63, %29
%31 = load i32, i32* %7
%32 = load %struct.dataSet*, %struct.dataSet** %6
%33 = call i32 @getNumDataSetSamples(%struct.dataSet* %32)
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %66
35: ; preds = %30
%36 = load %struct.chromosome*, %struct.chromosome** %5
%37 = load %struct.dataSet*, %struct.dataSet** %6
%38 = load i32, i32* %7
%39 = call i32 @getDataSetSampleInputs(%struct.dataSet* %37, i32 %38)
%40 = call i32 @executeChromosome(%struct.chromosome* %36, i32 %39)
store i32 0, i32* %8
br label %41
41: ; preds = %59, %35
%42 = load i32, i32* %8
%43 = load %struct.chromosome*, %struct.chromosome** %5
%44 = call i32 @getNumChromosomeOutputs(%struct.chromosome* %43)
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %62
46: ; preds = %41
%47 = load %struct.chromosome*, %struct.chromosome** %5
%48 = load i32, i32* %8
%49 = call i64 @getChromosomeOutput(%struct.chromosome* %47, i32 %48)
%50 = load %struct.dataSet*, %struct.dataSet** %6
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i64 @getDataSetSampleOutput(%struct.dataSet* %50, i32 %51, i32 %52)
%54 = sub nsw i64 %49, %53
%55 = call i64 @fabs(i64 %54)
%56 = sitofp i64 %55 to double
%57 = load double, double* %9
%58 = fadd double %57, %56
store double %58, double* %9
br label %59
59: ; preds = %46
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %41
62: ; preds = %41
br label %63
63: ; preds = %62
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %30
66: ; preds = %30
%67 = load double, double* %9
ret double %67
}

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 = [25 x i8] c"Terminating CGP-Library.\00"
define double @supervisedLearning(%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 ([25 x i8], [25 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 = tail call i32 @getNumDataSetOutputs(%struct.dataSet* %2)
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = tail call i32 @getNumDataSetSamples(%struct.dataSet* %2)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %22, label %46
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %15, %41
%23 = phi double [ %42, %41 ], [ 0.000000e+00, %15 ]
%24 = phi i32 [ %43, %41 ], [ 0, %15 ]
%25 = tail call i32 @getDataSetSampleInputs(%struct.dataSet* %2, i32 %24)
%26 = tail call i32 @executeChromosome(%struct.chromosome* %1, i32 %25)
%27 = tail call i32 @getNumChromosomeOutputs(%struct.chromosome* %1)
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %22, %29
%30 = phi double [ %37, %29 ], [ %23, %22 ]
%31 = phi i32 [ %38, %29 ], [ 0, %22 ]
%32 = tail call i64 @getChromosomeOutput(%struct.chromosome* %1, i32 %31)
%33 = tail call i64 @getDataSetSampleOutput(%struct.dataSet* %2, i32 %24, i32 %31)
%34 = sub nsw i64 %32, %33
%35 = tail call i64 @fabs(i64 %34)
%36 = sitofp i64 %35 to double
%37 = fadd double %30, %36
%38 = add nuw nsw i32 %31, 1
%39 = tail call i32 @getNumChromosomeOutputs(%struct.chromosome* %1)
%40 = icmp slt i32 %38, %39
br i1 %40, label %29, label %41
41: ; preds = %29, %22
%42 = phi double [ %23, %22 ], [ %37, %29 ]
%43 = add nuw nsw i32 %24, 1
%44 = tail call i32 @getNumDataSetSamples(%struct.dataSet* %2)
%45 = icmp slt i32 %43, %44
br i1 %45, label %22, label %46
46: ; preds = %41, %15
%47 = phi double [ 0.000000e+00, %15 ], [ %42, %41 ]
ret double %47
}