// File: /workspace/github_c_makefile_star2_O2/kernfel[P]fNEAT/main.c
// Function: run_trial
int run_trial( pNetwork *controller_structure, struct NEAT_Params *n_params, struct Robot_Params *r_params, TileMaze *maze, int *behaviour ) {
	int err=0;

	struct Implementation_Params i_params = {3};

	eNetwork controller;
	if (( err = create_eNetwork( &controller ) ))
		return err;
	if (( err = build_eNetwork( &controller, controller_structure, n_params, &i_params ) )) {
		delete_eNetwork( &controller );
		return err;
	}

	Robot bot = { 1, 1, 0 };
/*	double sensors[NUM_SENSORS+1], motors[NUM_MOTORS];*/
/*	sensors[NUM_SENSORS] = 1;*/
	double sensors[NUM_SENSORS], motors[NUM_MOTORS];
	int i, tile_counter=0, tile=0, prev_tile;
	for ( i=0; i<20000 && tile_counter < 400; i++ ) {
		get_sensor_readings_in_tilemaze( &bot, maze, r_params, sensors );
		activate( &controller, sensors, motors );
		move_robot_in_tilemaze( &bot, maze, r_params, motors );
		
		prev_tile = tile;
		tile = (int)(bot.x / maze->tile_width) + maze->x*(int)(bot.y / maze->tile_width);
		tile_counter++;
		if ( tile != prev_tile )
			tile_counter = 0;

		++behaviour[tile];
	}
	
	if ( i==tile_counter && bot.x == 1 && bot.y == 1 )
		behaviour[tile] = 0;

	delete_eNetwork( &controller );

	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movabsq $0x4008000000000000, %rax # imm = 0x4008000000000000
movq %rax, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x5b24
movl %eax, %ebp
testl %eax, %eax
jne 0x1584
leaq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rcx
movq %r13, %rsi
movq %r12, %rdx
callq 0x5b7f
testl %eax, %eax
je 0x145f
movl %eax, %ebp
leaq 0x38(%rsp), %rdi
callq 0x5b3e
jmp 0x1584
movq %rbx, 0x10(%rsp)
movups 0x4cbd(%rip), %xmm0     # 0x6128
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movsd 0x4c90(%rip), %xmm0     # 0x6110
movapd %xmm0, %xmm1
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
cmpl $0x4e1f, %r12d          # imm = 0x4E1F
ja 0x154d
cmpl $0x18f, %r13d           # imm = 0x18F
jg 0x154d
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r15, %rbx
leaq 0x90(%rsp), %r15
movq %r15, %rcx
callq 0x5887
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %r15
leaq 0x70(%rsp), %rbx
movq %rbx, %rdx
callq 0x5e34
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x5268
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
movsd (%r14), %xmm2
movapd %xmm1, %xmm3
divsd %xmm2, %xmm3
cvttsd2si %xmm3, %eax
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
cvttsd2si %xmm3, %ecx
imull 0x8(%r14), %ecx
addl %eax, %ecx
incl %r13d
cmpl 0xc(%rsp), %ecx
movl $0x0, %eax
cmovnel %eax, %r13d
movslq %ecx, %rax
movq 0x10(%rsp), %rdx
incl (%rdx,%rax,4)
incl %r12d
movl %ecx, 0xc(%rsp)
jmp 0x1492
cmpl %r13d, %r12d
jne 0x1578
ucomisd 0x4bb6(%rip), %xmm1     # 0x6110
jne 0x1578
jp 0x1578
ucomisd 0x4baa(%rip), %xmm0     # 0x6110
jne 0x1578
jp 0x1578
movslq 0xc(%rsp), %rax
movq 0x10(%rsp), %rcx
andl $0x0, (%rcx,%rax,4)
leaq 0x38(%rsp), %rdi
callq 0x5b3e
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq