// File: ADAPTLab[P]MuDBSCAN/partition.cpp
// Function: get_extra_points(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, int*, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, vectorc*, vectorc*, int*)
void get_extra_points(vector< vector<double> >& objects, int* num_points, vector< vector<double> >& remote_objects, vectorc* remote_PrIDs, vectorc* remote_Indices, int* remote_number)
{

#ifdef _DEBUG_GP
	MPI_Barrier(MPI_COMM_WORLD);
	double end, start = MPI_Wtime();
#endif

	int k, rank, nproc, i, j;
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &nproc);

#ifdef _DEBUG
	if(rank == proc_of_interest) cout << "extra point time part 0 strating " << endl;
#endif

	interval* local_box = new interval[DIMENSION];
	compute_local_bounding_box(objects, num_points, local_box);
	double eps = EPS;

	for(i = 0; i < DIMENSION; i++)
	{
		local_box[i].upper += eps;
		local_box[i].lower -= eps; 
	}

	interval* gather_local_box = new interval[DIMENSION * nproc];

	MPI_Allgather(local_box, sizeof(interval) * DIMENSION, MPI_BYTE, gather_local_box,
			sizeof(interval) * DIMENSION, MPI_BYTE, MPI_COMM_WORLD);

	bool if_inside, overlap;
	int count = 0, gcount;

	vector <double> empty;
	vector <vector <double> > send_buf;
	vector <vector <double> > recv_buf;
	send_buf.resize(nproc, empty);
	recv_buf.resize(nproc, empty);

	vector <int> empty_i;
	vector <vector <int> > send_buf_ind;
	vector <vector <int> > recv_buf_ind;
	send_buf_ind.resize(nproc, empty_i);
	recv_buf_ind.resize(nproc, empty_i);

#ifdef _DEBUG_GP
	MPI_Barrier(MPI_COMM_WORLD);
	end = MPI_Wtime();
#ifdef _DEBUG
	if(rank == proc_of_interest) cout << "extra point time part 1: " << end - start << endl;	
#endif
	start = end;
#endif

	for(k = 0; k < nproc; k++)
	{
		if (k == rank) // self
			continue;

		overlap = true;
		for(j = 0; j < DIMENSION; j++)
		{
			if(gather_local_box[rank * DIMENSION + j].lower < gather_local_box[k * DIMENSION +j].lower)
			{
				if(gather_local_box[rank * DIMENSION + j].upper - gather_local_box[k * DIMENSION + j].lower < eps)	
				{
					overlap = false;
					break;
				}
			}
			else
			{
				if(gather_local_box[k * DIMENSION + j].upper - gather_local_box[rank * DIMENSION + j].lower < eps)
				{
					overlap = false;
					break;
				}
			}
		}

		if(overlap == false)
			continue;

		// printf("EXTRA POINTS \t %d\n", send_buf[0].size());
		for(i = 0; i < *num_points; i++)
		{
			if_inside = true;
			for(j = 0; j < DIMENSION; j++)
			{
				if(objects[i][j] < gather_local_box[k * DIMENSION + j].lower || 
						objects[i][j] > gather_local_box[k * DIMENSION + j].upper)
				{
					if_inside = false;
					break;
				}
			}

			if(if_inside == true)
			{

				for(j = 0; j < DIMENSION; j++)
				{
					// printf("%lf ", objects[i][j]);
					send_buf[k].push_back(objects[i][j]);
				}

				// printf("\t%d\n", rank);
				send_buf_ind[k].push_back(i);
				count++;
			}
		}
	}

#ifdef _DEBUG_GP
	MPI_Barrier(MPI_COMM_WORLD);
	end = MPI_Wtime();
#ifdef _DEBUG
	if(rank == proc_of_interest) cout << "extra point time part 2: " << end - start << endl;        
#endif
	start = end;
#endif

	vector <int> send_buf_size, recv_buf_size;
	send_buf_size.resize(nproc, 0);
	recv_buf_size.resize(nproc, 0);

	for(i = 0; i < nproc; i++)
		send_buf_size[i] = send_buf[i].size();

	MPI_Alltoall(&send_buf_size[0], 1, MPI_INT, &recv_buf_size[0], 1, MPI_INT, MPI_COMM_WORLD);

	int tag = 200, send_count, recv_count;
	MPI_Request req_send[2 * nproc], req_recv[2 * nproc];
	MPI_Status stat_send[2 * nproc], stat_recv;

	recv_count = 0;
	for(i = 0; i < nproc; i++)
	{
		if(recv_buf_size[i] > 0)
		{
			recv_buf[i].resize(recv_buf_size[i], 0);
			recv_buf_ind[i].resize(recv_buf_size[i] / DIMENSION, -1);

			MPI_Irecv(&recv_buf[i][0], recv_buf_size[i], MPI_DOUBLE, i, tag, MPI_COMM_WORLD, &req_recv[recv_count++]);
			MPI_Irecv(&recv_buf_ind[i][0], recv_buf_size[i] / DIMENSION, MPI_INT, i, tag + 1, MPI_COMM_WORLD, &req_recv[recv_count++]);
		}
	}

	send_count = 0;

	for(i = 0; i < nproc; i++)
	{
		if(send_buf_size[i] > 0)
		{
			MPI_Isend(&send_buf[i][0], send_buf_size[i], MPI_DOUBLE, i, tag, MPI_COMM_WORLD, &req_send[send_count++]);
			MPI_Isend(&send_buf_ind[i][0], send_buf_size[i] / DIMENSION, MPI_INT, i, tag + 1, MPI_COMM_WORLD, &req_send[send_count++]);
		}
	}

	int rtag, rsource, rpos;


	for(i = 0; i < recv_count; i++)
	{
		MPI_Waitany(recv_count, &req_recv[0], &rpos, &stat_recv);

		rtag = stat_recv.MPI_TAG;
		rsource = stat_recv.MPI_SOURCE;

		if(rtag == tag)
		{
			// #if _GET_EXTRA_POINT_STAT == 0  // WHY THIS IS HERE??????????????????????????????????????????????????????????????
			addPoints(rsource, recv_buf_size[rsource], DIMENSION, recv_buf[rsource], remote_objects, remote_PrIDs, remote_number);
			// #endif
			recv_buf[rsource].clear();
		}
		else if(rtag == tag + 1)
		{
			// postpond this computation and call update points later
			// processing immediately might lead to invalid computation
		}
	}	

	if(send_count > 0)
		MPI_Waitall(send_count, &req_send[0], &stat_send[0]);

#ifdef _DEBUG_GP
	MPI_Barrier(MPI_COMM_WORLD);
	end = MPI_Wtime();
#ifdef _DEBUG
	if(rank == proc_of_interest) cout << "extra point time part 3: " << end - start << endl;        
#endif
	start = end;
#endif

	updatePoints(recv_buf_ind, remote_Indices, remote_PrIDs, *remote_number);

	MPI_Reduce(&count, &gcount, 1, MPI_INT, MPI_SUM, proc_of_interest, MPI_COMM_WORLD);

#ifdef _DEBUG
	if(rank == proc_of_interest)
	{
		cout << "Total extra point " << gcount << endl;
		cout << "Extra point per processor " << gcount/nproc << endl;
	}
#endif

#ifdef _DEBUG_GP
	MPI_Barrier(MPI_COMM_WORLD);
	end = MPI_Wtime();
#ifdef _DEBUG

	if(rank == proc_of_interest) cout << "extra point time part 4: " << end - start << endl;        
#endif
	start = end;
#endif


	empty.clear();
	send_buf.clear();
	recv_buf.clear();
	send_buf_size.clear();
	recv_buf_size.clear();
	send_buf_ind.clear();
	recv_buf_ind.clear();

	delete [] gather_local_box;
	delete [] local_box;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq 0x1d04e(%rip), %rdi     # 0x37fa8
leaq -0x38(%rbp), %rsi
callq 0x99e0
movq 0x1d03e(%rip), %rdi     # 0x37fa8
leaq -0x3c(%rbp), %rsi
callq 0x9790
leaq 0x1d85a(%rip), %rax     # 0x387d4
movslq (%rax), %rax
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x9030
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x19640
leaq 0x1d80e(%rip), %rax     # 0x387c8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
leaq 0x1d800(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x1b021
movsd -0x58(%rbp), %xmm0
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movsd -0x58(%rbp), %xmm1
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1afca
leaq 0x1d7ac(%rip), %rax     # 0x387d4
movq %rax, -0x1c0(%rbp)
movl (%rax), %eax
movl -0x3c(%rbp), %ecx
imull %ecx, %eax
cltq
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x9030
movq %rax, %rcx
movq -0x1c0(%rbp), %rax
movq %rcx, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movl (%rax), %r8d
shll $0x4, %r8d
movq -0x60(%rbp), %rcx
subq $0x10, %rsp
movq 0x1cf2c(%rip), %rdx     # 0x37fa8
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1cf07(%rip), %r9      # 0x37f90
movl %r8d, %esi
movq %r9, %rdx
callq 0x9070
addq $0x10, %rsp
movl $0x0, -0x68(%rbp)
leaq -0x88(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0xf890
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0xf970
leaq -0xb8(%rbp), %rdi
callq 0xf970
movq -0x1b8(%rbp), %rdi
movq -0x1b0(%rbp), %rdx
movslq -0x3c(%rbp), %rsi
callq 0x1c3b0
jmp 0x1b0ea
movslq -0x3c(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x1c3b0
jmp 0x1b103
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x1c260
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x1c460
leaq -0x110(%rbp), %rdi
callq 0x1c460
movq -0x1d0(%rbp), %rdi
movq -0x1c8(%rbp), %rdx
movslq -0x3c(%rbp), %rsi
callq 0x1c480
jmp 0x1b14e
movslq -0x3c(%rbp), %rsi
leaq -0x110(%rbp), %rdi
leaq -0xe0(%rbp), %rdx
callq 0x1c480
jmp 0x1b167
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1b479
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x1b1b5
jmp 0x1b46b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1bc7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1bc5b
movb $0x1, -0x62(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
leaq 0x1d60a(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x1b2dc
movq -0x60(%rbp), %rax
movl -0x38(%rbp), %ecx
leaq 0x1d5f4(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
leaq 0x1d5d2(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1b274
movq -0x60(%rbp), %rax
movl -0x38(%rbp), %ecx
leaq 0x1d5aa(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
leaq 0x1d587(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
subsd (%rax), %xmm1
movsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1b272
movb $0x0, -0x62(%rbp)
jmp 0x1b2dc
jmp 0x1b2cc
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
leaq 0x1d552(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x60(%rbp), %rax
movl -0x38(%rbp), %ecx
leaq 0x1d52f(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
subsd (%rax), %xmm1
movsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1b2ca
movb $0x0, -0x62(%rbp)
jmp 0x1b2dc
jmp 0x1b2cc
jmp 0x1b2ce
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1b1c0
movb -0x62(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1b2ee
jmp 0x1b46b
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1b469
movb $0x1, -0x61(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
leaq 0x1d4bb(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x1b3be
movq -0x8(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0xf850
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0xf870
movsd (%rax), %xmm1
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
leaq 0x1d488(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x1b3a8
movq -0x8(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0xf850
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0xf870
movsd (%rax), %xmm0
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
leaq 0x1d443(%rip), %rdx     # 0x387d4
imull (%rdx), %ecx
addl -0x44(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x1b3ae
movb $0x0, -0x61(%rbp)
jmp 0x1b3be
jmp 0x1b3b0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1b30f
movb -0x61(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1b459
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
leaq 0x1d3f4(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x1b432
movslq -0x34(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xf850
movq %rax, -0x1d8(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x40(%rbp), %rsi
callq 0xf850
movq %rax, %rdi
movslq -0x44(%rbp), %rsi
callq 0xf870
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x1c1d0
jmp 0x1b425
jmp 0x1b427
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1b3d6
movslq -0x34(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x11a90
movq %rax, %rdi
leaq -0x40(%rbp), %rsi
callq 0x11ab0
jmp 0x1b450
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1b45b
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1b2f5
jmp 0x1b46b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b16e
leaq -0x128(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x1c260
leaq -0x140(%rbp), %rdi
callq 0x1c260
movq -0x1e0(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
movl $0x0, -0x144(%rbp)
leaq -0x144(%rbp), %rdx
callq 0x1c100
jmp 0x1b4bb
movslq -0x3c(%rbp), %rsi
movl $0x0, -0x148(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0x148(%rbp), %rdx
callq 0x1c100
jmp 0x1b4de
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1b55d
movslq -0x40(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xf850
movq %rax, %rdi
callq 0x1c240
movl %eax, -0x1e4(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
movl -0x1e4(%rbp), %ecx
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1b4e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x1c350
leaq -0x128(%rbp), %rdi
callq 0x1c350
jmp 0x1bc5b
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x1f8(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
movq -0x1f8(%rbp), %rsi
movq %rax, -0x1f0(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
subq $0x10, %rsp
movq 0x1ca05(%rip), %rdx     # 0x37fa8
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1ca20(%rip), %r9      # 0x37fd0
movl $0x1, %r8d
movl %r8d, %esi
movq %r9, %rdx
callq 0x92f0
addq $0x10, %rsp
jmp 0x1b5c7
movl $0xc8, -0x14c(%rbp)
movl -0x3c(%rbp), %eax
addl %eax, %eax
movq %rsp, %rcx
movq %rcx, -0x160(%rbp)
movq %rax, %rdx
shlq $0x3, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x210(%rbp)
movq %rcx, %rsp
movq %rax, -0x168(%rbp)
movl -0x3c(%rbp), %eax
addl %eax, %eax
movq %rax, %rdx
shlq $0x3, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x208(%rbp)
movq %rcx, %rsp
movq %rax, -0x170(%rbp)
movl -0x3c(%rbp), %eax
addl %eax, %eax
movq %rax, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x200(%rbp)
movq %rcx, %rsp
movq %rax, -0x178(%rbp)
movl $0x0, -0x154(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1b855
movslq -0x40(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
cmpl $0x0, (%rax)
jle 0x1b845
movslq -0x40(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xf850
movq %rax, -0x218(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movq -0x218(%rbp), %rdi
movslq (%rax), %rsi
movq $0x0, -0x198(%rbp)
leaq -0x198(%rbp), %rdx
callq 0x1c280
jmp 0x1b6c8
movslq -0x40(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x11a90
movq %rax, -0x220(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movq -0x220(%rbp), %rdi
movl (%rax), %eax
leaq 0x1d0d5(%rip), %rcx     # 0x387d4
movl (%rcx), %ecx
cltd
idivl %ecx
movslq %eax, %rsi
movl $0xffffffff, -0x19c(%rbp) # imm = 0xFFFFFFFF
leaq -0x19c(%rbp), %rdx
callq 0x1c100
jmp 0x1b71f
movslq -0x40(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xf850
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf870
movq %rax, -0x228(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movq -0x228(%rbp), %rdi
movq %rax, %rcx
movq -0x208(%rbp), %rax
movl (%rcx), %esi
movl -0x40(%rbp), %ecx
movl -0x14c(%rbp), %r8d
movslq -0x154(%rbp), %rdx
movl %edx, %r9d
incl %r9d
movl %r9d, -0x154(%rbp)
leaq (%rax,%rdx,8), %rdx
subq $0x10, %rsp
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1c820(%rip), %rdx     # 0x37fb8
movq 0x1c809(%rip), %r9      # 0x37fa8
callq 0x9970
addq $0x10, %rsp
jmp 0x1b7aa
movslq -0x40(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x11a90
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c1b0
movq %rax, -0x230(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movq -0x230(%rbp), %rdi
movl (%rax), %eax
leaq 0x1cfe7(%rip), %rcx     # 0x387d4
movl (%rcx), %ecx
cltd
idivl %ecx
movl %eax, %esi
movq -0x208(%rbp), %rax
movl -0x40(%rbp), %ecx
movl -0x14c(%rbp), %r8d
incl %r8d
movslq -0x154(%rbp), %rdx
movl %edx, %r9d
incl %r9d
movl %r9d, -0x154(%rbp)
leaq (%rax,%rdx,8), %rdx
subq $0x10, %rsp
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1c79f(%rip), %rdx     # 0x37fd0
movq 0x1c770(%rip), %r9      # 0x37fa8
callq 0x9970
addq $0x10, %rsp
jmp 0x1b843
jmp 0x1b845
jmp 0x1b847
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1b659
movl $0x0, -0x150(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1b9c1
movslq -0x40(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
cmpl $0x0, (%rax)
jle 0x1b9b1
movslq -0x40(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0xf850
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf870
movq %rax, -0x238(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
movq -0x238(%rbp), %rdi
movq %rax, %rcx
movq -0x210(%rbp), %rax
movl (%rcx), %esi
movl -0x40(%rbp), %ecx
movl -0x14c(%rbp), %r8d
movslq -0x150(%rbp), %rdx
movl %edx, %r9d
incl %r9d
movl %r9d, -0x150(%rbp)
leaq (%rax,%rdx,8), %rdx
subq $0x10, %rsp
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1c6b4(%rip), %rdx     # 0x37fb8
movq 0x1c69d(%rip), %r9      # 0x37fa8
callq 0x9290
addq $0x10, %rsp
jmp 0x1b916
movslq -0x40(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x11a90
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1c1b0
movq %rax, -0x240(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x1c1b0
movq -0x240(%rbp), %rdi
movl (%rax), %eax
leaq 0x1ce7b(%rip), %rcx     # 0x387d4
movl (%rcx), %ecx
cltd
idivl %ecx
movl %eax, %esi
movq -0x210(%rbp), %rax
movl -0x40(%rbp), %ecx
movl -0x14c(%rbp), %r8d
incl %r8d
movslq -0x150(%rbp), %rdx
movl %edx, %r9d
incl %r9d
movl %r9d, -0x150(%rbp)
leaq (%rax,%rdx,8), %rdx
subq $0x10, %rsp
movq %rsp, %rax
movq %rdx, (%rax)
movq 0x1c633(%rip), %rdx     # 0x37fd0
movq 0x1c604(%rip), %r9      # 0x37fa8
callq 0x9290
addq $0x10, %rsp
jmp 0x1b9af
jmp 0x1b9b1
jmp 0x1b9b3
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1b866
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x154(%rbp), %eax
jge 0x1bae2
movq -0x208(%rbp), %rsi
movl -0x154(%rbp), %edi
leaq -0x1a8(%rbp), %rdx
leaq -0x190(%rbp), %rcx
callq 0x9900
jmp 0x1b9f9
movl -0x18c(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movl -0x1a0(%rbp), %eax
cmpl -0x14c(%rbp), %eax
jne 0x1babb
movl -0x1a4(%rbp), %eax
movl %eax, -0x24c(%rbp)
movslq %eax, %rsi
leaq -0x140(%rbp), %rdi
callq 0x1c1b0
movl (%rax), %eax
movl %eax, -0x248(%rbp)
leaq 0x1cd87(%rip), %rax     # 0x387d4
movl (%rax), %eax
movl %eax, -0x244(%rbp)
movslq -0x1a4(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xf850
movl -0x24c(%rbp), %edi
movl -0x248(%rbp), %esi
movl -0x244(%rbp), %edx
movq %rax, %rcx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x30(%rbp), %r10
subq $0x10, %rsp
movq %rsp, %rax
movq %r10, (%rax)
callq 0x1acd0
addq $0x10, %rsp
jmp 0x1ba9e
movslq -0x1a4(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0xf850
movq %rax, %rdi
callq 0x1c330
jmp 0x1bad2
movl -0x1a0(%rbp), %eax
movl -0x14c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1bad0
jmp 0x1bad0
jmp 0x1bad2
jmp 0x1bad4
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1b9c8
cmpl $0x0, -0x150(%rbp)
jle 0x1bb08
movq -0x200(%rbp), %rdx
movq -0x210(%rbp), %rsi
movl -0x150(%rbp), %edi
callq 0x97e0
jmp 0x1bb06
jmp 0x1bb08
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rax
movl (%rax), %ecx
leaq -0x110(%rbp), %rdi
callq 0x1ae50
jmp 0x1bb24
subq $0x10, %rsp
movq 0x1c479(%rip), %rcx     # 0x37fa8
movq %rsp, %rax
movq %rcx, (%rax)
movq 0x1c494(%rip), %rcx     # 0x37fd0
movq 0x1c445(%rip), %r8      # 0x37f88
leaq -0x68(%rbp), %rdi
leaq -0x6c(%rbp), %rsi
movl $0x1, %edx
xorl %r9d, %r9d
callq 0x98e0
addq $0x10, %rsp
jmp 0x1bb5e
leaq -0x88(%rbp), %rdi
callq 0x1c330
leaq -0xa0(%rbp), %rdi
callq 0x1c530
leaq -0xb8(%rbp), %rdi
callq 0x1c530
leaq -0x128(%rbp), %rdi
callq 0x1c0e0
leaq -0x140(%rbp), %rdi
callq 0x1c0e0
leaq -0xf8(%rbp), %rdi
callq 0x1c550
leaq -0x110(%rbp), %rdi
callq 0x1c550
movq -0x60(%rbp), %rax
movq %rax, -0x258(%rbp)
cmpq $0x0, %rax
je 0x1bbcf
movq -0x258(%rbp), %rdi
callq 0x98a0
movq -0x50(%rbp), %rax
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x1bbec
movq -0x260(%rbp), %rdi
callq 0x98a0
movq -0x160(%rbp), %rax
movq %rax, %rsp
leaq -0x140(%rbp), %rdi
callq 0x1c350
leaq -0x128(%rbp), %rdi
callq 0x1c350
leaq -0x110(%rbp), %rdi
callq 0x1c570
leaq -0xf8(%rbp), %rdi
callq 0x1c570
leaq -0xe0(%rbp), %rdi
callq 0x1c350
leaq -0xb8(%rbp), %rdi
callq 0xf9f0
leaq -0xa0(%rbp), %rdi
callq 0xf9f0
leaq -0x88(%rbp), %rdi
callq 0xf910
movq %rbp, %rsp
popq %rbp
retq
leaq -0x110(%rbp), %rdi
callq 0x1c570
leaq -0xf8(%rbp), %rdi
callq 0x1c570
leaq -0xe0(%rbp), %rdi
callq 0x1c350
leaq -0xb8(%rbp), %rdi
callq 0xf9f0
leaq -0xa0(%rbp), %rdi
callq 0xf9f0
leaq -0x88(%rbp), %rdi
callq 0xf910
movq -0xc0(%rbp), %rdi
callq 0x9c70
nop