// File: mgronhol[P]Ullur/ullur.cpp
// Function: handle_getr[abi:cxx11](double, double, double, double)
std::string handle_getr( double x0, double y0, double x1, double y1 ){
	std::string out;

        std::vector< uint64_t > results_inter, /*results_final,*/ values;
        std::vector< std::pair< uint64_t, uint64_t > > areas;

        double r = sqrt( (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1) );

	int N = -floor( log(r) / log(2) );

	double x = (x0+x1) / 2.0;
	double y = (y0+y1) / 2.0;

        uint64_t test_point_H = compute_hash( x, y );
        std::pair< double, double > test_point( x, y );
        char buffer[256];


        areas = get_near_indices( N, test_point_H );
        results_inter = extract_points( hashes, areas );

        std::pair< double, double > point;
        for( size_t i = 0 ; i < results_inter.size() ; ++i ){
                point = compute_position( results_inter[i] );
		if( point.first >= x0 && point.first <= x1 ){
			if( point.second >= y0 && point.second <= y1 ){
	                        values = multiget( database, results_inter[i] );

                	        for( size_t j = 0 ; j < values.size() ; ++j ){
                        	        memset( buffer, 0, 256 );
                                	sprintf( buffer, "%lu\n", values[j] );
                                	out += std::string( buffer );
                                	}
				}
			}
		}


	return out + "\r\n";
	}

// Assembly:
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movq %rdi, 0x2f0(%rsp)
movsd %xmm0, 0x2e8(%rsp)
movsd %xmm1, 0x2e0(%rsp)
movsd %xmm2, 0x2d8(%rsp)
movsd %xmm3, 0x2d0(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0x23b0
leaq 0x298(%rsp), %rdi
callq 0x4a20
leaq 0x280(%rsp), %rdi
callq 0x4a20
leaq 0x268(%rsp), %rdi
callq 0x4cc0
movsd 0x2e8(%rsp), %xmm0
movsd 0x2d8(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd 0x2e0(%rsp), %xmm1
movsd 0x2d0(%rsp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x2210
movsd %xmm0, 0x260(%rsp)
movsd 0x260(%rsp), %xmm0
callq 0x2220
movsd %xmm0, 0x70(%rsp)
movsd 0x9d5a(%rip), %xmm0     # 0xd020
callq 0x2220
movaps %xmm0, %xmm1
movsd 0x70(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x2420
movaps 0x9d5c(%rip), %xmm1     # 0xd040
pxor %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x25c(%rsp)
movsd 0x2e8(%rsp), %xmm0
movsd 0x2d8(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd 0x9d1f(%rip), %xmm1     # 0xd030
mulsd %xmm1, %xmm0
movsd %xmm0, 0x250(%rsp)
movsd 0x2e0(%rsp), %xmm0
movsd 0x2d0(%rsp), %xmm2
addsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x248(%rsp)
movsd 0x250(%rsp), %xmm0
movsd 0x248(%rsp), %xmm1
callq 0xa5f0
movq %rax, 0x78(%rsp)
jmp 0x335f
movq 0x78(%rsp), %rax
movq %rax, 0x240(%rsp)
leaq 0x220(%rsp), %rdi
leaq 0x250(%rsp), %rsi
leaq 0x248(%rsp), %rdx
callq 0x4cd0
jmp 0x338b
movslq 0x25c(%rsp), %rsi
movq 0x240(%rsp), %rdx
leaq 0x108(%rsp), %rdi
callq 0xa9b0
jmp 0x33aa
leaq 0x268(%rsp), %rdi
movq %rdi, 0x58(%rsp)
leaq 0x108(%rsp), %rsi
movq %rsi, 0x50(%rsp)
callq 0x4d00
movq 0x50(%rsp), %rdi
callq 0x4d40
movq 0x58(%rsp), %rdx
leaq 0xfed9(%rip), %rsi      # 0x132b8
leaq 0xf0(%rsp), %rdi
callq 0xabe0
jmp 0x33ee
leaq 0x298(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
movq %rsi, 0x48(%rsp)
callq 0x4c80
movq 0x48(%rsp), %rdi
callq 0x4b90
leaq 0xe0(%rsp), %rdi
callq 0x4da0
jmp 0x3421
movq $0x0, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x4ae0
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x3752
movq 0xd8(%rsp), %rsi
leaq 0x298(%rsp), %rdi
callq 0x4b70
movq (%rax), %rdi
callq 0xa860
movsd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x38(%rsp)
jmp 0x3483
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movsd %xmm1, 0xc8(%rsp)
movsd %xmm0, 0xd0(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4dc0
movsd 0xe0(%rsp), %xmm0
ucomisd 0x2e8(%rsp), %xmm0
jb 0x3737
movsd 0xe0(%rsp), %xmm1
movsd 0x2d8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3737
movsd 0xe8(%rsp), %xmm0
ucomisd 0x2e0(%rsp), %xmm0
jb 0x3735
movsd 0xe8(%rsp), %xmm1
movsd 0x2d0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3735
movq 0xd8(%rsp), %rsi
leaq 0x298(%rsp), %rdi
callq 0x4b70
movq (%rax), %rdx
leaq 0xfdab(%rip), %rsi      # 0x132e8
leaq 0xb0(%rsp), %rdi
callq 0x26c0
jmp 0x354c
leaq 0x280(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x4c80
leaq 0xb0(%rsp), %rdi
callq 0x4b90
movq $0x0, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x4ae0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x3733
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 0x210(%rsp)
movaps %xmm0, 0x200(%rsp)
movaps %xmm0, 0x1f0(%rsp)
movaps %xmm0, 0x1e0(%rsp)
movaps %xmm0, 0x1d0(%rsp)
movaps %xmm0, 0x1c0(%rsp)
movaps %xmm0, 0x1b0(%rsp)
movaps %xmm0, 0x1a0(%rsp)
movaps %xmm0, 0x190(%rsp)
movaps %xmm0, 0x180(%rsp)
movaps %xmm0, 0x170(%rsp)
movaps %xmm0, 0x160(%rsp)
movaps %xmm0, 0x150(%rsp)
movaps %xmm0, 0x140(%rsp)
movaps %xmm0, 0x130(%rsp)
movaps %xmm0, 0x120(%rsp)
movq 0xa8(%rsp), %rsi
leaq 0x280(%rsp), %rdi
callq 0x4b70
movq (%rax), %rdx
leaq 0x9a1e(%rip), %rsi      # 0xd069
xorl %eax, %eax
leaq 0x120(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x2060
leaq 0x87(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x2450
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x88(%rsp), %rdi
callq 0x2390
jmp 0x368a
leaq 0x2b0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x2360
jmp 0x36a1
leaq 0x88(%rsp), %rdi
callq 0x21c0
leaq 0x87(%rsp), %rdi
callq 0x2300
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x357a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
jmp 0x37ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
jmp 0x3724
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x238(%rsp)
movl %eax, 0x234(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x21c0
leaq 0x87(%rsp), %rdi
callq 0x2300
jmp 0x37ae
jmp 0x3735
jmp 0x3737
jmp 0x3739
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x342d
movq 0x60(%rsp), %rdi
leaq 0x9908(%rip), %rdx      # 0xd066
leaq 0x2b0(%rsp), %rsi
callq 0x4df0
jmp 0x376d
leaq 0x268(%rsp), %rdi
callq 0x4d40
leaq 0x280(%rsp), %rdi
callq 0x4b90
leaq 0x298(%rsp), %rdi
callq 0x4b90
leaq 0x2b0(%rsp), %rdi
callq 0x21c0
movq 0x68(%rsp), %rax
addq $0x2f8, %rsp            # imm = 0x2F8
retq
leaq 0x268(%rsp), %rdi
callq 0x4d40
leaq 0x280(%rsp), %rdi
callq 0x4b90
leaq 0x298(%rsp), %rdi
callq 0x4b90
leaq 0x2b0(%rsp), %rdi
callq 0x21c0
movq 0x238(%rsp), %rdi
callq 0x2440
nop