// File: ADAPTLab[P]MuDBSCAN/partition.cpp
// Function: compute_global_bounding_box(interval*, interval*, int)
void compute_global_bounding_box(Interval box, Interval gbox, int nproc)
{
	int i, j, k;

	Interval gather_local_box = (Interval) calloc(DIMENSION * nproc, sizeof(struct interval));
	// assert(gather_local_box != NULL);

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

	for(i = 0; i < DIMENSION; i++)
	{
		gbox[i].lower = gather_local_box[i].lower;
		gbox[i].upper = gather_local_box[i].upper;

		k = i;
		for(j = 0; j < nproc; j++, k += DIMENSION)
		{
			if(gbox[i].lower > gather_local_box[k].lower)
				gbox[i].lower = gather_local_box[k].lower;

			if(gbox[i].upper < gather_local_box[k].upper)
				gbox[i].upper = gather_local_box[k].upper;
		}
	}

	free(gather_local_box);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq 0x1efaa(%rip), %rax     # 0x387d4
movl (%rax), %eax
imull -0x14(%rbp), %eax
movslq %eax, %rdi
movl $0x10, %esi
callq 0x9400
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x1ef88(%rip), %rax     # 0x387d4
movslq (%rax), %rax
shlq $0x4, %rax
movl %eax, %esi
movq -0x28(%rbp), %rcx
leaq 0x1ef74(%rip), %rax     # 0x387d4
movslq (%rax), %rax
shlq $0x4, %rax
movl %eax, %r8d
movq 0x1e71f(%rip), %r9      # 0x37f90
movq 0x1e730(%rip), %rax     # 0x37fa8
movq %r9, %rdx
movq %rax, (%rsp)
callq 0x9070
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
leaq 0x1ef3f(%rip), %rcx     # 0x387d4
cmpl (%rcx), %eax
jge 0x199d7
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x199c7
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
ucomisd (%rax), %xmm0
jbe 0x19952
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x199a8
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x199aa
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
leaq 0x1ee1a(%rip), %rax     # 0x387d4
movl (%rax), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x198f8
jmp 0x199c9
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1988b
movq -0x28(%rbp), %rdi
callq 0x97c0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)