// File: mgronhol[P]Ullur/ullur.cpp
// Function: handle_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int)
std::string handle_message( std::string& message, int sock ){
	std::string out = message.substr( message.find_first_of( '\r' ) + 1 );
	char command[32], dummy[32];
	float x, y, r, x0, y0, x1, y1;
	uint64_t id;
	sscanf( message.c_str(), "%s ", command );
	std::string cmd = std::string( command );
	std::string response;
	

	
	if( cmd == "PUT" ){
		sscanf( message.c_str(), "%s %f %f %lu", dummy, &x, &y, &id );

		response = handle_put( x, y, id );
		if( sock > 0 ){ fprintf( append_log, "PUT %f %f %lu\r\n", x, y, id ); }

		}
	if( cmd == "GEO-PUT" ){
		sscanf( message.c_str(), "%s %f %f %lu", dummy, &x, &y, &id );
		response = handle_geo_put( x, y, id );
		}
	
	if( cmd == "GET" ){
		sscanf( message.c_str(), "%s %f %f %f", dummy, &x, &y, &r );
		response = handle_get( x, y, r );
		}

	if( cmd == "GEO-GET" ){
		sscanf( message.c_str(), "%s %f %f %f", dummy, &x, &y, &r );
		response = handle_geo_get( x, y, r);
		}

	if( cmd == "GETR" ){
		sscanf( message.c_str(), "%s %f %f %f %f", dummy, &x0, &y0, &x1, &y1 );
		response = handle_getr( x0, y0, x1, y1 );
		}

	if( cmd == "GEO-GETR" ){
		sscanf( message.c_str(), "%s %f %f %f %f", dummy, &x0, &y0, &x1, &y1 );
		response = handle_geo_getr( x0, y0, x1, y1 );
		}

	if( cmd == "DEL" ){
		sscanf( message.c_str(), "%s %lu", dummy, &id );
		response = handle_del( id );
		if( sock > 0 ){ fprintf( append_log, "DEL %lu\r\n", id ); }
		}

//	std::cerr << "Response: '"<<response<<"'" << std::endl;
//	response = "response\r\n";
//	sleep( 1 );
	if( sock > 0 ){
		send_string( sock, response );
		}
	//return out;
	return std::string();
	}

// Assembly:
subq $0x248, %rsp            # imm = 0x248
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0x240(%rsp)
movq %rsi, 0x238(%rsp)
movl %edx, 0x234(%rsp)
movq 0x238(%rsp), %rdi
movq %rdi, 0x30(%rsp)
xorl %eax, %eax
movl %eax, 0x3c(%rsp)
movl %eax, %edx
movl $0xd, %esi
callq 0x21d0
movq 0x30(%rsp), %rsi
movq %rax, %rdx
incq %rdx
leaq 0x210(%rsp), %rdi
movq $-0x1, %rcx
callq 0x22c0
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
movl 0x3c(%rsp), %eax
leaq 0x962a(%rip), %rsi      # 0xd06e
leaq 0x1f0(%rsp), %rdx
movq %rdx, 0x40(%rsp)
callq 0x2280
leaq 0x187(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x2450
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x188(%rsp), %rdi
callq 0x2390
jmp 0x3a81
leaq 0x187(%rsp), %rdi
callq 0x2300
leaq 0x150(%rsp), %rdi
callq 0x23b0
leaq 0x95f1(%rip), %rsi      # 0xd093
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1f(%rsp)
jmp 0x3ab5
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x3ac2
jmp 0x3bd7
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
leaq 0x9599(%rip), %rsi      # 0xd072
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1cc(%rsp), %rcx
leaq 0x1c8(%rsp), %r8
leaq 0x1a8(%rsp), %r9
callq 0x2280
movss 0x1cc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1c8(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movq 0x1a8(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x2950
jmp 0x3b31
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x2350
leaq 0x130(%rsp), %rdi
callq 0x21c0
cmpl $0x0, 0x234(%rsp)
jle 0x3bd5
movq 0xf7bc(%rip), %rdi      # 0x13320
movss 0x1cc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1c8(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movq 0x1a8(%rsp), %rdx
leaq 0x94f2(%rip), %rsi      # 0xd07f
movb $0x2, %al
callq 0x23c0
jmp 0x3bd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x187(%rsp), %rdi
callq 0x2300
jmp 0x4124
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x410a
jmp 0x3bd7
leaq 0x94b1(%rip), %rsi      # 0xd08f
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1e(%rsp)
jmp 0x3bf1
movb 0x1e(%rsp), %al
testb $0x1, %al
jne 0x3bfe
jmp 0x3c8f
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
leaq 0x945d(%rip), %rsi      # 0xd072
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1cc(%rsp), %rcx
leaq 0x1c8(%rsp), %r8
leaq 0x1a8(%rsp), %r9
callq 0x2280
movss 0x1cc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1c8(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movq 0x1a8(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x2b80
jmp 0x3c6d
leaq 0x150(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x2350
leaq 0x110(%rsp), %rdi
callq 0x21c0
leaq 0x9411(%rip), %rsi      # 0xd0a7
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1d(%rsp)
jmp 0x3ca9
movb 0x1d(%rsp), %al
testb $0x1, %al
jne 0x3cb6
jmp 0x3d4c
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
leaq 0x93ca(%rip), %rsi      # 0xd097
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1cc(%rsp), %rcx
leaq 0x1c8(%rsp), %r8
leaq 0x1c4(%rsp), %r9
callq 0x2280
movss 0x1cc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1c8(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x1c4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xf0(%rsp), %rdi
callq 0x2c00
jmp 0x3d2a
leaq 0x150(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x2350
leaq 0xf0(%rsp), %rdi
callq 0x21c0
leaq 0x9350(%rip), %rsi      # 0xd0a3
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1c(%rsp)
jmp 0x3d66
movb 0x1c(%rsp), %al
testb $0x1, %al
jne 0x3d73
jmp 0x3e09
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
leaq 0x930d(%rip), %rsi      # 0xd097
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1cc(%rsp), %rcx
leaq 0x1c8(%rsp), %r8
leaq 0x1c4(%rsp), %r9
callq 0x2280
movss 0x1cc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1c8(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x1c4(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xd0(%rsp), %rdi
callq 0x3150
jmp 0x3de7
leaq 0x150(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x2350
leaq 0xd0(%rsp), %rdi
callq 0x21c0
leaq 0x92ae(%rip), %rsi      # 0xd0be
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1b(%rsp)
jmp 0x3e23
movb 0x1b(%rsp), %al
testb $0x1, %al
jne 0x3e30
jmp 0x3ee1
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
movq %rsp, %rax
leaq 0x1b4(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x9256(%rip), %rsi      # 0xd0ab
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1c0(%rsp), %rcx
leaq 0x1bc(%rsp), %r8
leaq 0x1b8(%rsp), %r9
callq 0x2280
movss 0x1c0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1bc(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x1b8(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x1b4(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
leaq 0xb0(%rsp), %rdi
callq 0x31f0
jmp 0x3ebf
leaq 0x150(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x2350
leaq 0xb0(%rsp), %rdi
callq 0x21c0
leaq 0x91d2(%rip), %rsi      # 0xd0ba
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x1a(%rsp)
jmp 0x3efb
movb 0x1a(%rsp), %al
testb $0x1, %al
jne 0x3f08
jmp 0x3fb9
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
movq %rsp, %rax
leaq 0x1b4(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x917e(%rip), %rsi      # 0xd0ab
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1c0(%rsp), %rcx
leaq 0x1bc(%rsp), %r8
leaq 0x1b8(%rsp), %r9
callq 0x2280
movss 0x1c0(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x1bc(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0x1b8(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0x1b4(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
leaq 0x90(%rsp), %rdi
callq 0x37f0
jmp 0x3f97
leaq 0x150(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2350
leaq 0x90(%rsp), %rdi
callq 0x21c0
leaq 0x9103(%rip), %rsi      # 0xd0c3
leaq 0x188(%rsp), %rdi
callq 0x4ef0
movb %al, 0x19(%rsp)
jmp 0x3fd3
movb 0x19(%rsp), %al
testb $0x1, %al
jne 0x3fe0
jmp 0x4067
movq 0x238(%rsp), %rdi
callq 0x2130
movq %rax, %rdi
leaq 0x90d0(%rip), %rsi      # 0xd0c7
xorl %eax, %eax
leaq 0x1d0(%rsp), %rdx
leaq 0x1a8(%rsp), %rcx
callq 0x2280
movq 0x1a8(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x38c0
jmp 0x4022
leaq 0x150(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x2350
leaq 0x70(%rsp), %rdi
callq 0x21c0
cmpl $0x0, 0x234(%rsp)
jle 0x4065
movq 0xf2d1(%rip), %rdi      # 0x13320
movq 0x1a8(%rsp), %rdx
leaq 0x9070(%rip), %rsi      # 0xd0ce
movb $0x0, %al
callq 0x23c0
jmp 0x4067
cmpl $0x0, 0x234(%rsp)
jle 0x40cc
movl 0x234(%rsp), %eax
movl %eax, 0x14(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x2140
jmp 0x4090
movl 0x14(%rsp), %edi
leaq 0x50(%rsp), %rsi
callq 0x2800
jmp 0x40a0
leaq 0x50(%rsp), %rdi
callq 0x21c0
jmp 0x40cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x21c0
jmp 0x410a
movq 0x20(%rsp), %rdi
callq 0x23b0
leaq 0x150(%rsp), %rdi
callq 0x21c0
leaq 0x188(%rsp), %rdi
callq 0x21c0
leaq 0x210(%rsp), %rdi
callq 0x21c0
movq 0x28(%rsp), %rax
addq $0x248, %rsp            # imm = 0x248
retq
leaq 0x150(%rsp), %rdi
callq 0x21c0
leaq 0x188(%rsp), %rdi
callq 0x21c0
leaq 0x210(%rsp), %rdi
callq 0x21c0
movq 0x178(%rsp), %rdi
callq 0x2440
nop