// File: /workspace/github_c_makefile_star2_O1/stefpant[P]TCPserver/PantoulasStefanosProject2/jobExec/child.c
// Function: mergeNodeInfo
void mergeNodeInfo(int ***A,int *Ac,int **B,int Bc){
	if((*A) == NULL){//copy B array to A
		(*A) = malloc(Bc*sizeof(int*));
		for(int i=0;i<Bc;i++){
			(*A)[i] = malloc(2*sizeof(int));
			(*A)[i][0] = B[i][0];
			(*A)[i][1] = B[i][1];
		}
		*Ac = Bc;
		return;
	}
	else if(Bc == 0) return;
	int p1=0,p2=0;
	int fcounter=0;
	int **final = malloc((*Ac + Bc)*sizeof(int*));//allocate for max elements
	while(1){
		if(flagUSR1 == 1) break;//reached deadline stop
		if(p1==*Ac){
			while(p2!=Bc){
				final[fcounter] = malloc(2*sizeof(int));
				final[fcounter][0] = B[p2][0];
				final[fcounter][1] = B[p2][1];
				p2++;fcounter++;
			}
			break;
		}
		if(p2==Bc){
			while(p1!=*Ac){
				final[fcounter] = malloc(2*sizeof(int));
				final[fcounter][0] = (*A)[p1][0];
				final[fcounter][1] = (*A)[p1][1];
				p1++;fcounter++;
			}
			break;
		}
		final[fcounter] = malloc(2*sizeof(int));
		if((*A)[p1][0]<B[p2][0]){//insert in final sorted
			final[fcounter][0] = (*A)[p1][0];
			final[fcounter++][1] = (*A)[p1++][1];
		}
		else if((*A)[p1][0]>B[p2][0]){
			final[fcounter][0] = B[p2][0];
			final[fcounter++][1] = B[p2++][1];
		}
		else{//now lets check second member of array
			if((*A)[p1][1]<B[p2][1]){
				final[fcounter][0] = (*A)[p1][0];
				final[fcounter++][1] = (*A)[p1++][1];
			}
			else if((*A)[p1][1]>B[p2][1]){
				final[fcounter][0] = B[p2][0];
				final[fcounter++][1] = B[p2++][1];
			}
			else{
				final[fcounter][0] = (*A)[p1][0];
				final[fcounter++][1] = (*A)[p1++][1];
				p2++;
			}
		}
	}
	if(flagUSR1 == 1){//reached deadline free(final) and return
		for(int i=0;i<fcounter;i++)
			free(final[i]);
		free(final);
		return;//and in childs main check flag and stop!
	}
	if(!fcounter) return;
	for(int h=0;h<*Ac;h++) free((*A)[h]);
	if(*Ac!=0) free(*A);
	*A = realloc(final,fcounter*sizeof(int*));//in the end resize the array
	*Ac = fcounter;
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r15d
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r14
movq (%rdi), %rax
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x42b6
testl %r15d, %r15d
je 0x4441
movslq (%r12), %rax
movslq %r15d, %rdi
addq %rax, %rdi
shlq $0x3, %rdi
callq 0x2210
movq %rax, -0x40(%rbp)
movl 0x5fb3(%rip), %eax      # 0xa1c0
xorl %ebx, %ebx
cmpl $0x1, %eax
je 0x43b5
movq %r15, -0x30(%rbp)
movq %r12, -0x38(%rbp)
movl (%r12), %eax
movl %eax, -0x44(%rbp)
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpl -0x44(%rbp), %r15d
je 0x4310
cmpl %r12d, -0x30(%rbp)
je 0x4364
movl $0x8, %edi
callq 0x2210
movq -0x40(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
movslq %r15d, %rcx
movq -0x50(%rbp), %rdx
movq (%rdx,%rcx,8), %rcx
movl (%rcx), %esi
movslq %r12d, %rdx
movq (%r13,%rdx,8), %rdx
movl (%rdx), %edi
cmpl %edi, %esi
jge 0x427a
movl %esi, (%rax)
incl %r15d
movl 0x4(%rcx), %ecx
jmp 0x4284
jle 0x429a
movl %edi, (%rax)
incl %r12d
movl 0x4(%rdx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
movl 0x5f30(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x422f
jmp 0x43b1
movl 0x4(%rdx), %r8d
cmpl %r8d, 0x4(%rcx)
jl 0x4270
jg 0x427c
movl %esi, (%rax)
incl %r15d
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incl %r12d
jmp 0x4287
movslq %r15d, %rdi
shlq $0x3, %rdi
callq 0x2210
movq %rax, (%r14)
movq %r15, -0x30(%rbp)
testl %r15d, %r15d
jle 0x4303
movl -0x30(%rbp), %ebx
xorl %r15d, %r15d
movl $0x8, %edi
callq 0x2210
movq (%r14), %rcx
movq %rax, (%rcx,%r15,8)
movq (%r13,%r15,8), %rax
movl (%rax), %ecx
movq (%r14), %rdx
movq (%rdx,%r15,8), %rdx
movl %ecx, (%rdx)
movl 0x4(%rax), %eax
movl %eax, 0x4(%rdx)
incq %r15
cmpq %r15, %rbx
jne 0x42d4
movq -0x30(%rbp), %rax
movl %eax, (%r12)
jmp 0x4441
movq -0x30(%rbp), %r15
subl %r12d, %r15d
je 0x43b1
movslq %r12d, %rax
leaq (,%rax,8), %rax
addq %r13, %rax
movq %rax, -0x30(%rbp)
xorl %r12d, %r12d
movq -0x40(%rbp), %r13
movl $0x8, %edi
callq 0x2210
movq %rax, (%r13,%rbx,8)
movq -0x30(%rbp), %rcx
movq (%rcx,%r12,8), %rcx
movl (%rcx), %edx
movl %edx, (%rax)
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
incq %r12
cmpl %r12d, %r15d
jne 0x4336
jmp 0x43b1
movq -0x38(%rbp), %rax
movl (%rax), %r12d
subl %r15d, %r12d
je 0x43b1
movslq %r15d, %rax
movq -0x50(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0x30(%rbp)
xorl %r13d, %r13d
movq -0x40(%rbp), %r15
movl $0x8, %edi
callq 0x2210
movq %rax, (%r15,%rbx,8)
movq -0x30(%rbp), %rcx
movq (%rcx,%r13,8), %rcx
movl (%rcx), %edx
movl %edx, (%rax)
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
incq %r13
cmpl %r13d, %r12d
jne 0x4386
movq -0x38(%rbp), %r12
movl 0x5e05(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x43f4
testl %ebx, %ebx
movq -0x40(%rbp), %r15
jle 0x43de
movl %ebx, %ebx
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x2030
incq %r14
cmpq %r14, %rbx
jne 0x43cd
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
testl %ebx, %ebx
je 0x4441
movl (%r12), %eax
testl %eax, %eax
movq -0x40(%rbp), %r13
jle 0x441f
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x2030
incq %r15
movslq (%r12), %rax
cmpq %rax, %r15
jl 0x4407
testl %eax, %eax
je 0x442b
movq (%r14), %rdi
callq 0x2030
movslq %ebx, %rsi
shlq $0x3, %rsi
movq %r13, %rdi
callq 0x2230
movq %rax, (%r14)
movl %ebx, (%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq