// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/extract.c
// Function: get_activation_at
void get_activation_at( double x[DIMENSIONS], double r[N_OUTPUTS], struct Extraction_Params *eparams ) {
	int i, read_new=0;
	BinLeaf *b = eparams->root;
	// Check whether x lies within root's bounding box at all
	double w = 1.0 / (1<<(b->level+1));
	for ( i=0; i<DIMENSIONS; i++ ) {
		if ( x[i] > b->x[i]+w || x[i] < b->x[i]-w ) {
			read_new = 1;
			break;
		}
	}
	
	if ( !read_new ) {
		// Drill down into the tree
		while (1) {
			// b is at the requested coordinates, return its readout.
			// No need to check for eparams->outgoing, since the tree was constructed with the same parameters
			if ( ! memcmp(x, b->x, DIMENSIONS*sizeof *x) ) {
				memcpy( r, b->r, N_OUTPUTS*sizeof *r );
				return;
			}
			
			// Determine the appropriate child leaf - 0 for left, 1 for right, dim 0 is right-most bit
			int idx=0;
			for ( i=0; i<DIMENSIONS; i++ ) {
				if ( x[i] > b->x[i] )
					idx |= 1 << i;
			}

			// b has children, c[idx] is closest to the requested coords, check that out
			if ( b->c )
				b = &b->c[idx];

			// b has no children, compute the readout afresh
			else
				break;
		}
	}

	if ( eparams->outgoing )
		read_CPPN( eparams->cppn, eparams->params, eparams->ref, x, r );
	else
		read_CPPN( eparams->cppn, eparams->params, x, eparams->ref, r );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl $0x1, %eax
shll %cl, %eax
cvtsi2sd %eax, %xmm1
movsd 0x3465(%rip), %xmm0     # 0xa068
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jge 0x6c7b
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd 0x10(%rax,%rcx,8), %xmm1
addsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
ja 0x6c65
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd 0x10(%rax,%rcx,8), %xmm0
subsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6c6e
movl $0x1, -0x20(%rbp)
jmp 0x6c7b
jmp 0x6c70
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6c13
cmpl $0x0, -0x20(%rbp)
jne 0x6d3e
jmp 0x6c87
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
movups (%rcx), %xmm1
movups (%rax), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x6cc5
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, (%rax)
jmp 0x6d94
movl $0x0, -0x34(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jge 0x6d13
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
ucomisd 0x10(%rax,%rcx,8), %xmm0
jbe 0x6d06
movl -0x1c(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
orl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x6d08
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6cd3
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x6d35
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x6d37
jmp 0x6d3c
jmp 0x6c87
jmp 0x6d3e
movq -0x18(%rbp), %rax
cmpb $0x0, 0x18(%rax)
je 0x6d6f
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rdx
addq $0x8, %rdx
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %r8
callq 0x3590
jmp 0x6d94
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x8(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x8, %rcx
movq -0x10(%rbp), %r8
callq 0x3590
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)