// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movl %ecx, %ebx
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r12
movq (%rdi), %rax
movq %rax, -0x50(%rbp)
testq %rax, %rax
je 0x4278
movq %r12, -0x58(%rbp)
testl %ebx, %ebx
je 0x42d4
movl (%r14), %eax
movq %rax, -0x48(%rbp)
addl %ebx, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x2210
movq %rax, %r15
movl 0x5f5d(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x42e3
movl 0x5f52(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x42d4
jmp 0x4431
movq %r14, -0x40(%rbp)
movslq %ebx, %rdi
shlq $0x3, %rdi
callq 0x2210
movq %rax, (%r12)
movq %rbx, -0x30(%rbp)
testl %ebx, %ebx
jle 0x42ca
movq %rax, %r15
movl -0x30(%rbp), %ebx
xorl %r14d, %r14d
movl $0x8, %edi
callq 0x2210
movq %rax, (%r15,%r14,8)
movq (%r13,%r14,8), %rax
movl (%rax), %ecx
movq (%r12), %r15
movq (%r15,%r14,8), %rdx
movl %ecx, (%rdx)
movl 0x4(%rax), %eax
movl %eax, 0x4(%rdx)
incq %r14
cmpq %r14, %rbx
jne 0x429d
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movl %eax, (%rcx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, -0x30(%rbp)
movq %r15, -0x38(%rbp)
movq %r14, -0x40(%rbp)
xorl %ebx, %ebx
xorl %r9d, %r9d
xorl %r15d, %r15d
movq -0x48(%rbp), %r14
subl %r15d, %r14d
je 0x4387
movslq %r15d, %r12
cmpl %r9d, -0x30(%rbp)
je 0x43ce
movl $0x8, %edi
movl %r9d, %r14d
callq 0x2210
movl %r14d, %r9d
movq -0x38(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
movq -0x50(%rbp), %rcx
movq (%rcx,%r12,8), %rcx
movl (%rcx), %esi
movslq %r14d, %rdx
movq (%r13,%rdx,8), %rdx
movl (%rdx), %edi
cmpl %edi, %esi
jge 0x434b
movl %esi, (%rax)
incl %r15d
movl 0x4(%rcx), %ecx
jmp 0x4355
jle 0x436b
movl %edi, (%rax)
incl %r9d
movl 0x4(%rdx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
movl 0x5e5f(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x42f7
jmp 0x4404
movl 0x4(%rdx), %r8d
cmpl %r8d, 0x4(%rcx)
jl 0x4341
jg 0x434d
movl %esi, (%rax)
incl %r15d
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incl %r9d
jmp 0x4358
movq -0x30(%rbp), %r12
subl %r9d, %r12d
je 0x4404
movslq %r9d, %rax
leaq (,%rax,8), %r14
addq %r13, %r14
xorl %r15d, %r15d
movl $0x8, %edi
callq 0x2210
movq -0x38(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
movq (%r14,%r15,8), %rcx
movl (%rcx), %edx
movl %edx, (%rax)
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
incq %r15
cmpl %r15d, %r12d
jne 0x43a1
jmp 0x4404
movq -0x50(%rbp), %rax
leaq (%rax,%r12,8), %r15
xorl %r12d, %r12d
movl $0x8, %edi
callq 0x2210
movq -0x38(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
movq (%r15,%r12,8), %rcx
movl (%rcx), %edx
movl %edx, (%rax)
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
incq %rbx
incq %r12
cmpl %r12d, %r14d
jne 0x43d9
movl 0x5db6(%rip), %eax      # 0xa1c0
cmpl $0x1, %eax
jne 0x4447
testl %ebx, %ebx
movq -0x38(%rbp), %r15
jle 0x4431
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x2030
incq %r14
cmpq %r14, %rbx
jne 0x4420
movq %r15, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
testl %ebx, %ebx
movq -0x40(%rbp), %r15
je 0x42d4
movq -0x48(%rbp), %rax
testl %eax, %eax
movq -0x58(%rbp), %r12
jle 0x447a
xorl %r14d, %r14d
movq (%r12), %rax
movq (%rax,%r14,8), %rdi
callq 0x2030
incq %r14
movslq (%r15), %rax
cmpq %rax, %r14
jl 0x4462
testl %eax, %eax
je 0x4487
movq (%r12), %rdi
callq 0x2030
movslq %ebx, %rsi
shlq $0x3, %rsi
movq -0x38(%rbp), %rdi
callq 0x2230
movq %rax, (%r12)
movl %ebx, (%r15)
jmp 0x42d4
nop