#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*/ addNodeFunction(struct parameters *, char *);
int /*<<< orphan*/ copyChromosome(struct chromosome *, struct chromosome *);
int /*<<< orphan*/ executeChromosome(struct chromosome *, double *);
int /*<<< orphan*/ freeChromosome(struct chromosome *);
int /*<<< orphan*/ freeDataSet(struct dataSet *);
int /*<<< orphan*/ freeParameters(struct parameters *);
double getChromosomeOutput(struct chromosome *, int /*<<< orphan*/);
struct chromosome *initialiseChromosome(struct parameters *);
struct chromosome *initialiseChromosomeFromFile(char *);
struct dataSet *initialiseDataSetFromFile(char *);
struct parameters *initialiseParameters(int, int, int, int);
int /*<<< orphan*/ mutateChromosome(struct parameters *, struct chromosome *);
int /*<<< orphan*/ printChromosome(struct chromosome *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ removeInactiveNodes(struct chromosome *);
int /*<<< orphan*/ saveChromosome(struct chromosome *, char *);
int /*<<< orphan*/ setChromosomeFitness(struct parameters *,
                                        struct chromosome *, struct dataSet *);
int main(void) {
  struct parameters *params = NULL;
  struct chromosome *chromoA = NULL;
  struct chromosome *chromoB = NULL;
  struct chromosome *chromoC = NULL;
  struct dataSet *trainingData = NULL;
  double testInputs[1];
  params = initialiseParameters(1, 8, 1, 2);
  addNodeFunction(params, "add,sub,mul,sq,cube,sin");
  trainingData = initialiseDataSetFromFile("./dataSets/symbolic.data");
  chromoA = initialiseChromosome(params);
  chromoB = initialiseChromosome(params);
  setChromosomeFitness(params, chromoA, trainingData);
  mutateChromosome(params, chromoA);
  copyChromosome(chromoB, chromoA);
  removeInactiveNodes(chromoB);
  printf("chromoA with inactive nodes.\n");
  printChromosome(chromoA, 0);
  printf("chromoB without inactive nodes.\n");
  printChromosome(chromoB, 0);
  saveChromosome(chromoB, "chromoB.chromo");
  chromoC = initialiseChromosomeFromFile("chromoB.chromo");
  testInputs[0] = 3;
  executeChromosome(chromoC, testInputs);
  printf("Applied input: %f\n", testInputs[0]);
  printf("Generated output: %f\n", getChromosomeOutput(chromoC, 0));
  freeChromosome(chromoA);
  freeChromosome(chromoB);
  freeChromosome(chromoC);
  freeDataSet(trainingData);
  freeParameters(params);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x1,%edx
mov    $0x8,%esi
mov    $0x2,%ecx
mov    %edx,%edi
call   10d0 <initialiseParameters@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1090 <addNodeFunction@plt>
lea    0xda8(%rip),%rdi
call   1050 <initialiseDataSetFromFile@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <initialiseChromosome@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <initialiseChromosome@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <setChromosomeFitness@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <mutateChromosome@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <copyChromosome@plt>
mov    -0x20(%rbp),%rdi
call   1030 <removeInactiveNodes@plt>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1110 <printChromosome@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1110 <printChromosome@plt>
mov    -0x20(%rbp),%rdi
lea    0xd6c(%rip),%rsi
call   10a0 <saveChromosome@plt>
lea    0xd60(%rip),%rdi
call   1040 <initialiseChromosomeFromFile@plt>
mov    %rax,-0x28(%rbp)
movsd  0xcd7(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1100 <executeChromosome@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xd40(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1120 <getChromosomeOutput@plt>
lea    0xd3a(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1130 <freeChromosome@plt>
mov    -0x20(%rbp),%rdi
call   1130 <freeChromosome@plt>
mov    -0x28(%rbp),%rdi
call   1130 <freeChromosome@plt>
mov    -0x30(%rbp),%rdi
call   10f0 <freeDataSet@plt>
mov    -0x10(%rbp),%rdi
call   10e0 <freeParameters@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   10e0 <initialiseParameters@plt>
mov    %rax,%r15
lea    0xdb0(%rip),%rsi
mov    %rax,%rdi
call   10a0 <addNodeFunction@plt>
lea    0xdb9(%rip),%rdi
call   1060 <initialiseDataSetFromFile@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   10d0 <initialiseChromosome@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   10d0 <initialiseChromosome@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1090 <setChromosomeFitness@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <mutateChromosome@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   10c0 <copyChromosome@plt>
mov    %r13,%rdi
call   1030 <removeInactiveNodes@plt>
lea    0xdb9(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %esi,%esi
call   1120 <printChromosome@plt>
lea    0xdc0(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
xor    %esi,%esi
call   1120 <printChromosome@plt>
lea    0xd55(%rip),%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   10b0 <saveChromosome@plt>
mov    %rbx,%rdi
call   1050 <initialiseChromosomeFromFile@plt>
mov    %rax,%rbx
movabs $0x4008000000000000,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1110 <executeChromosome@plt>
movsd  0x8(%rsp),%xmm0
lea    0xd25(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1130 <getChromosomeOutput@plt>
lea    0xd20(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r12,%rdi
call   1140 <freeChromosome@plt>
mov    %r13,%rdi
call   1140 <freeChromosome@plt>
mov    %rbx,%rdi
call   1140 <freeChromosome@plt>
mov    %r14,%rdi
call   1100 <freeDataSet@plt>
mov    %r15,%rdi
call   10f0 <freeParameters@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
%struct.dataSet = type { i32 }
@.str = [24 x i8] c"add,sub,mul,sq,cube,sin\00"
@.str.1 = [25 x i8] c"./dataSets/symbolic.data\00"
@.str.2 = [30 x i8] c"chromoA with inactive nodes.\0A\00"
@.str.3 = [33 x i8] c"chromoB without inactive nodes.\0A\00"
@.str.4 = [15 x i8] c"chromoB.chromo\00"
@.str.5 = [19 x i8] c"Applied input: %f\0A\00"
@.str.6 = [22 x i8] c"Generated output: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.parameters*
%3 = alloca %struct.chromosome*
%4 = alloca %struct.chromosome*
%5 = alloca %struct.chromosome*
%6 = alloca %struct.dataSet*
%7 = alloca [1 x double]
store i32 0, i32* %1
store %struct.parameters* null, %struct.parameters** %2
store %struct.chromosome* null, %struct.chromosome** %3
store %struct.chromosome* null, %struct.chromosome** %4
store %struct.chromosome* null, %struct.chromosome** %5
store %struct.dataSet* null, %struct.dataSet** %6
%8 = call %struct.parameters* @initialiseParameters(i32 1, i32 8, i32 1, i32 2)
store %struct.parameters* %8, %struct.parameters** %2
%9 = load %struct.parameters*, %struct.parameters** %2
%10 = call i32 @addNodeFunction(%struct.parameters* %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call %struct.dataSet* @initialiseDataSetFromFile(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store %struct.dataSet* %11, %struct.dataSet** %6
%12 = load %struct.parameters*, %struct.parameters** %2
%13 = call %struct.chromosome* @initialiseChromosome(%struct.parameters* %12)
store %struct.chromosome* %13, %struct.chromosome** %3
%14 = load %struct.parameters*, %struct.parameters** %2
%15 = call %struct.chromosome* @initialiseChromosome(%struct.parameters* %14)
store %struct.chromosome* %15, %struct.chromosome** %4
%16 = load %struct.parameters*, %struct.parameters** %2
%17 = load %struct.chromosome*, %struct.chromosome** %3
%18 = load %struct.dataSet*, %struct.dataSet** %6
%19 = call i32 @setChromosomeFitness(%struct.parameters* %16, %struct.chromosome* %17, %struct.dataSet* %18)
%20 = load %struct.parameters*, %struct.parameters** %2
%21 = load %struct.chromosome*, %struct.chromosome** %3
%22 = call i32 @mutateChromosome(%struct.parameters* %20, %struct.chromosome* %21)
%23 = load %struct.chromosome*, %struct.chromosome** %4
%24 = load %struct.chromosome*, %struct.chromosome** %3
%25 = call i32 @copyChromosome(%struct.chromosome* %23, %struct.chromosome* %24)
%26 = load %struct.chromosome*, %struct.chromosome** %4
%27 = call i32 @removeInactiveNodes(%struct.chromosome* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%29 = load %struct.chromosome*, %struct.chromosome** %3
%30 = call i32 @printChromosome(%struct.chromosome* %29, i32 0)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%32 = load %struct.chromosome*, %struct.chromosome** %4
%33 = call i32 @printChromosome(%struct.chromosome* %32, i32 0)
%34 = load %struct.chromosome*, %struct.chromosome** %4
%35 = call i32 @saveChromosome(%struct.chromosome* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%36 = call %struct.chromosome* @initialiseChromosomeFromFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store %struct.chromosome* %36, %struct.chromosome** %5
%37 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
store double 3.000000e+00, double* %37
%38 = load %struct.chromosome*, %struct.chromosome** %5
%39 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%40 = call i32 @executeChromosome(%struct.chromosome* %38, double* %39)
%41 = getelementptr inbounds [1 x double], [1 x double]* %7, i64 0, i64 0
%42 = load double, double* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %42)
%44 = load %struct.chromosome*, %struct.chromosome** %5
%45 = call double @getChromosomeOutput(%struct.chromosome* %44, i32 0)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %45)
%47 = load %struct.chromosome*, %struct.chromosome** %3
%48 = call i32 @freeChromosome(%struct.chromosome* %47)
%49 = load %struct.chromosome*, %struct.chromosome** %4
%50 = call i32 @freeChromosome(%struct.chromosome* %49)
%51 = load %struct.chromosome*, %struct.chromosome** %5
%52 = call i32 @freeChromosome(%struct.chromosome* %51)
%53 = load %struct.dataSet*, %struct.dataSet** %6
%54 = call i32 @freeDataSet(%struct.dataSet* %53)
%55 = load %struct.parameters*, %struct.parameters** %2
%56 = call i32 @freeParameters(%struct.parameters* %55)
ret i32 0
}

LLVM IR (-O2):
%struct.parameters = type { i32 }
%struct.chromosome = type { i32 }
%struct.dataSet = type { i32 }
@.str = [24 x i8] c"add,sub,mul,sq,cube,sin\00"
@.str.1 = [25 x i8] c"./dataSets/symbolic.data\00"
@.str.4 = [15 x i8] c"chromoB.chromo\00"
@.str.5 = [19 x i8] c"Applied input: %f\0A\00"
@.str.6 = [22 x i8] c"Generated output: %f\0A\00"
@str = [29 x i8] c"chromoA with inactive nodes.\00"
@str.7 = [32 x i8] c"chromoB without inactive nodes.\00"
define i32 @main() {
%1 = alloca [1 x double]
%2 = bitcast [1 x double]* %1 to i8*
%3 = tail call %struct.parameters* @initialiseParameters(i32 1, i32 8, i32 1, i32 2)
%4 = tail call i32 @addNodeFunction(%struct.parameters* %3, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%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.chromosome* @initialiseChromosome(%struct.parameters* %3)
%7 = tail call %struct.chromosome* @initialiseChromosome(%struct.parameters* %3)
%8 = tail call i32 @setChromosomeFitness(%struct.parameters* %3, %struct.chromosome* %6, %struct.dataSet* %5)
%9 = tail call i32 @mutateChromosome(%struct.parameters* %3, %struct.chromosome* %6)
%10 = tail call i32 @copyChromosome(%struct.chromosome* %7, %struct.chromosome* %6)
%11 = tail call i32 @removeInactiveNodes(%struct.chromosome* %7)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @printChromosome(%struct.chromosome* %6, i32 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%15 = tail call i32 @printChromosome(%struct.chromosome* %7, i32 0)
%16 = tail call i32 @saveChromosome(%struct.chromosome* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call %struct.chromosome* @initialiseChromosomeFromFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%18 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
store double 3.000000e+00, double* %18
%19 = call i32 @executeChromosome(%struct.chromosome* %17, double* %18)
%20 = load double, double* %18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), double %20)
%22 = call double @getChromosomeOutput(%struct.chromosome* %17, i32 0)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %22)
%24 = call i32 @freeChromosome(%struct.chromosome* %6)
%25 = call i32 @freeChromosome(%struct.chromosome* %7)
%26 = call i32 @freeChromosome(%struct.chromosome* %17)
%27 = call i32 @freeDataSet(%struct.dataSet* %5)
%28 = call i32 @freeParameters(%struct.parameters* %3)
ret i32 0
}