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

/* Variables and functions */
int /*<<< orphan*/ addNodeFunction(struct parameters *, char *);
int /*<<< orphan*/ freeChromosome(struct chromosome *);
int /*<<< orphan*/ freeDataSet(struct dataSet *);
int /*<<< orphan*/ freeParameters(struct parameters *);
int /*<<< orphan*/ freeResults(struct results *);
double getAverageFitness(struct results *);
struct chromosome *getChromosome(struct results *, int);
struct dataSet *initialiseDataSetFromFile(char *);
struct parameters *initialiseParameters(int, int, int, int);
int /*<<< orphan*/ printChromosome(struct chromosome *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
struct results *repeatCGP(struct parameters *, struct dataSet *, int, int);
int /*<<< orphan*/ saveResults(struct results *, char *);
int /*<<< orphan*/ setTargetFitness(struct parameters *, double);
int /*<<< orphan*/ setUpdateFrequency(struct parameters *, int);
int main(void) {
  struct parameters *params = NULL;
  struct dataSet *trainingData = NULL;
  struct results *rels = NULL;
  struct chromosome *chromo = NULL;
  int numInputs = 1;
  int numNodes = 15;
  int numOutputs = 1;
  int nodeArity = 2;
  int numGens = 10000;
  int numRuns = 10;
  double targetFitness = 0.1;
  int updateFrequency = 500;
  double averageFitness;
  params = initialiseParameters(numInputs, numNodes, numOutputs, nodeArity);
  addNodeFunction(params, "add,sub,mul,div,sin");
  setTargetFitness(params, targetFitness);
  setUpdateFrequency(params, updateFrequency);
  trainingData = initialiseDataSetFromFile("./dataSets/symbolic.data");
  rels = repeatCGP(params, trainingData, numGens, numRuns);
  averageFitness = getAverageFitness(rels);
  printf("The average chromosome fitness is: %f\n", averageFitness);
  chromo = getChromosome(rels, 4);
  printf("The best chromosome found on run 4:\n");
  printChromosome(chromo, 0);
  saveResults(rels, "results.csv");
  freeDataSet(trainingData);
  freeChromosome(chromo);
  freeResults(rels);
  freeParameters(params);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0xf,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x2,-0x38(%rbp)
movl   $0x2710,-0x3c(%rbp)
movl   $0xa,-0x40(%rbp)
movsd  0xdaf(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x1f4,-0x4c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
call   10c0 <initialiseParameters@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   10a0 <addNodeFunction@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
call   1050 <setTargetFitness@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1090 <setUpdateFrequency@plt>
lea    0xd79(%rip),%rdi
call   1060 <initialiseDataSetFromFile@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
call   1100 <repeatCGP@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <getAverageFitness@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
lea    0xd58(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1040 <getChromosome@plt>
mov    %rax,-0x28(%rbp)
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   10f0 <printChromosome@plt>
mov    -0x20(%rbp),%rdi
lea    0xd67(%rip),%rsi
call   10b0 <saveResults@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <freeDataSet@plt>
mov    -0x28(%rbp),%rdi
call   1110 <freeChromosome@plt>
mov    -0x20(%rbp),%rdi
call   1030 <freeResults@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <freeParameters@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0xf,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   10d0 <initialiseParameters@plt>
mov    %rax,%r15
lea    0xddd(%rip),%rsi
mov    %rax,%rdi
call   10b0 <addNodeFunction@plt>
movsd  0xdc5(%rip),%xmm0
mov    %r15,%rdi
call   1060 <setTargetFitness@plt>
mov    %r15,%rdi
mov    $0x1f4,%esi
call   10a0 <setUpdateFrequency@plt>
lea    0xdc5(%rip),%rdi
call   1070 <initialiseDataSetFromFile@plt>
mov    %rax,%r14
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0x2710,%edx
mov    $0xa,%ecx
call   1110 <repeatCGP@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <getAverageFitness@plt>
lea    0xdaf(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <getChromosome@plt>
mov    %rax,%r12
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %esi,%esi
call   1100 <printChromosome@plt>
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <saveResults@plt>
mov    %r14,%rdi
call   10f0 <freeDataSet@plt>
mov    %r12,%rdi
call   1120 <freeChromosome@plt>
mov    %rbx,%rdi
call   1030 <freeResults@plt>
mov    %r15,%rdi
call   10e0 <freeParameters@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.parameters = type { i32 }
%struct.dataSet = type { i32 }
%struct.results = type { i32 }
%struct.chromosome = type { i32 }
@.str = [20 x i8] c"add,sub,mul,div,sin\00"
@.str.1 = [25 x i8] c"./dataSets/symbolic.data\00"
@.str.2 = [39 x i8] c"The average chromosome fitness is: %f\0A\00"
@.str.3 = [37 x i8] c"The best chromosome found on run 4:\0A\00"
@.str.4 = [12 x i8] c"results.csv\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.parameters*
%3 = alloca %struct.dataSet*
%4 = alloca %struct.results*
%5 = alloca %struct.chromosome*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double
store i32 0, i32* %1
store %struct.parameters* null, %struct.parameters** %2
store %struct.dataSet* null, %struct.dataSet** %3
store %struct.results* null, %struct.results** %4
store %struct.chromosome* null, %struct.chromosome** %5
store i32 1, i32* %6
store i32 15, i32* %7
store i32 1, i32* %8
store i32 2, i32* %9
store i32 10000, i32* %10
store i32 10, i32* %11
store double 1.000000e-01, double* %12
store i32 500, i32* %13
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = call %struct.parameters* @initialiseParameters(i32 %15, i32 %16, i32 %17, i32 %18)
store %struct.parameters* %19, %struct.parameters** %2
%20 = load %struct.parameters*, %struct.parameters** %2
%21 = call i32 @addNodeFunction(%struct.parameters* %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%22 = load %struct.parameters*, %struct.parameters** %2
%23 = load double, double* %12
%24 = call i32 @setTargetFitness(%struct.parameters* %22, double %23)
%25 = load %struct.parameters*, %struct.parameters** %2
%26 = load i32, i32* %13
%27 = call i32 @setUpdateFrequency(%struct.parameters* %25, i32 %26)
%28 = call %struct.dataSet* @initialiseDataSetFromFile(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store %struct.dataSet* %28, %struct.dataSet** %3
%29 = load %struct.parameters*, %struct.parameters** %2
%30 = load %struct.dataSet*, %struct.dataSet** %3
%31 = load i32, i32* %10
%32 = load i32, i32* %11
%33 = call %struct.results* @repeatCGP(%struct.parameters* %29, %struct.dataSet* %30, i32 %31, i32 %32)
store %struct.results* %33, %struct.results** %4
%34 = load %struct.results*, %struct.results** %4
%35 = call double @getAverageFitness(%struct.results* %34)
store double %35, double* %14
%36 = load double, double* %14
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %36)
%38 = load %struct.results*, %struct.results** %4
%39 = call %struct.chromosome* @getChromosome(%struct.results* %38, i32 4)
store %struct.chromosome* %39, %struct.chromosome** %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%41 = load %struct.chromosome*, %struct.chromosome** %5
%42 = call i32 @printChromosome(%struct.chromosome* %41, i32 0)
%43 = load %struct.results*, %struct.results** %4
%44 = call i32 @saveResults(%struct.results* %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%45 = load %struct.dataSet*, %struct.dataSet** %3
%46 = call i32 @freeDataSet(%struct.dataSet* %45)
%47 = load %struct.chromosome*, %struct.chromosome** %5
%48 = call i32 @freeChromosome(%struct.chromosome* %47)
%49 = load %struct.results*, %struct.results** %4
%50 = call i32 @freeResults(%struct.results* %49)
%51 = load %struct.parameters*, %struct.parameters** %2
%52 = call i32 @freeParameters(%struct.parameters* %51)
ret i32 0
}

LLVM IR (-O2):
%struct.parameters = type { i32 }
%struct.dataSet = type { i32 }
%struct.results = type { i32 }
%struct.chromosome = type { i32 }
@.str = [20 x i8] c"add,sub,mul,div,sin\00"
@.str.1 = [25 x i8] c"./dataSets/symbolic.data\00"
@.str.2 = [39 x i8] c"The average chromosome fitness is: %f\0A\00"
@.str.4 = [12 x i8] c"results.csv\00"
@str = [36 x i8] c"The best chromosome found on run 4:\00"
define i32 @main() {
%1 = tail call %struct.parameters* @initialiseParameters(i32 1, i32 15, i32 1, i32 2)
%2 = tail call i32 @addNodeFunction(%struct.parameters* %1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @setTargetFitness(%struct.parameters* %1, double 1.000000e-01)
%4 = tail call i32 @setUpdateFrequency(%struct.parameters* %1, i32 500)
%5 = tail call %struct.dataSet* @initialiseDataSetFromFile(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call %struct.results* @repeatCGP(%struct.parameters* %1, %struct.dataSet* %5, i32 10000, i32 10)
%7 = tail call double @getAverageFitness(%struct.results* %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %7)
%9 = tail call %struct.chromosome* @getChromosome(%struct.results* %6, i32 4)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @printChromosome(%struct.chromosome* %9, i32 0)
%12 = tail call i32 @saveResults(%struct.results* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @freeDataSet(%struct.dataSet* %5)
%14 = tail call i32 @freeChromosome(%struct.chromosome* %9)
%15 = tail call i32 @freeResults(%struct.results* %6)
%16 = tail call i32 @freeParameters(%struct.parameters* %1)
ret i32 0
}