// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/sort.c
// Function: merge_block_seqs
static struct ptr_list *
merge_block_seqs (struct ptr_list *b1, int n,
		  struct ptr_list *b2, int m,
		  int (*cmp)(const void *, const void *))
{
	int i1 = 0, i2 = 0;
	const void *buffer[2 * LIST_NODE_NR];
	int nbuf = 0;
	struct ptr_list *newhead = b1;

	// printf ("Merging %d blocks at %p with %d blocks at %p\n", n, b1, m, b2);

	// Skip empty blocks in b2.
	while (b2->nr == 0) {
		BEEN_THERE('F');
		b2 = b2->next;
		if (--m == 0) {
			BEEN_THERE('G');
			return newhead;
		}
	}

	// Do a quick skip in case entire blocks from b1 are
	// already less than smallest element in b2.
	while (b1->nr == 0 ||
	       cmp (PTR_ENTRY_NOTAG(b1, b1->nr - 1), PTR_ENTRY_NOTAG(b2,0)) < 0) {
		// printf ("Skipping whole block.\n");
		BEEN_THERE('H');
		b1 = b1->next;
		if (--n == 0) {
			BEEN_THERE('I');
			return newhead;	
		}
	}

	while (1) {
		const void *d1 = PTR_ENTRY_NOTAG(b1,i1);
		const void *d2 = PTR_ENTRY_NOTAG(b2,i2);

		assert (i1 >= 0 && i1 < b1->nr);
		assert (i2 >= 0 && i2 < b2->nr);
		assert (b1 != b2);
		assert (n > 0);
		assert (m > 0);

		if (cmp (d1, d2) <= 0) {
			BEEN_THERE('J');
			buffer[nbuf++] = d1;
			// Element from b1 is smaller
			if (++i1 >= b1->nr) {
				BEEN_THERE('L');
				FLUSH_TO(b1);
				do {
					b1 = b1->next;
					if (--n == 0) {
						BEEN_THERE('O');
						while (b1 != b2) {
							BEEN_THERE('P');
							FLUSH_TO(b1);
							b1 = b1->next;
						}
						assert (nbuf == i2);
						DUMP_TO(b2);
						return newhead;
					}
				} while (b1->nr == 0);
				i1 = 0;
			}
		} else {
			BEEN_THERE('K');
			// Element from b2 is smaller
			buffer[nbuf++] = d2;
			if (++i2 >= b2->nr) {
				struct ptr_list *l = b2;
				BEEN_THERE('M');
				// OK, we finished with b2.  Pull it out
				// and plug it in before b1.

				b2 = b2->next;
				b2->prev = l->prev;
				b2->prev->next = b2;
				l->next = b1;
				l->prev = b1->prev;
				l->next->prev = l;
				l->prev->next = l;

				if (b1 == newhead) {
					BEEN_THERE('N');
					newhead = l;
				}

				FLUSH_TO(l);
				b2 = b2->prev;
				do {
					b2 = b2->next;
					if (--m == 0) {
						BEEN_THERE('Q');
						assert (nbuf == i1);
						DUMP_TO(b1);
						return newhead;
					}
				} while (b2->nr == 0);
				i2 = 0;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x114(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x20(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
jne 0x3d619
jmp 0x3d5e7
jmp 0x3d5e9
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jne 0x3d617
jmp 0x3d605
jmp 0x3d607
movq -0x120(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3dac7
jmp 0x3d5d0
jmp 0x3d61b
movq -0x10(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
movswl %ax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x145(%rbp)
je 0x3d675
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rdx
movw (%rdx), %dx
shlw $0x8, %dx
sarw $0x8, %dx
movswl %dx, %edx
subl $0x1, %edx
movslq %edx, %rdx
movq 0x18(%rcx,%rdx,8), %rdi
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rsi
callq *%rax
cmpl $0x0, %eax
setl %al
movb %al, -0x145(%rbp)
movb -0x145(%rbp), %al
testb $0x1, %al
jne 0x3d681
jmp 0x3d6b8
jmp 0x3d683
jmp 0x3d685
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jne 0x3d6b3
jmp 0x3d6a1
jmp 0x3d6a3
movq -0x120(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3dac7
jmp 0x3d61b
jmp 0x3d6ba
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x128(%rbp)
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x130(%rbp)
movq -0x30(%rbp), %rax
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq *%rax
cmpl $0x0, %eax
jg 0x3d8db
jmp 0x3d701
jmp 0x3d703
movq -0x128(%rbp), %rcx
movl -0x114(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x114(%rbp)
cltq
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jl 0x3d8d6
jmp 0x3d74a
jmp 0x3d74c
jmp 0x3d74e
movq -0x10(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
movl %eax, -0x134(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x110(%rbp), %rsi
movslq -0x134(%rbp), %rdx
shlq $0x3, %rdx
callq 0x111d0
movl -0x134(%rbp), %ecx
movl -0x114(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x114(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movslq -0x134(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movslq -0x114(%rbp), %rdx
shlq $0x3, %rdx
callq 0x11260
jmp 0x3d7c5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jne 0x3d8b4
jmp 0x3d7e5
jmp 0x3d7e7
jmp 0x3d7e9
movq -0x10(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x3d883
jmp 0x3d7f9
jmp 0x3d7fb
jmp 0x3d7fd
movq -0x10(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
movl %eax, -0x138(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x110(%rbp), %rsi
movslq -0x138(%rbp), %rdx
shlq $0x3, %rdx
callq 0x111d0
movl -0x138(%rbp), %ecx
movl -0x114(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x114(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movslq -0x138(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movslq -0x114(%rbp), %rdx
shlq $0x3, %rdx
callq 0x11260
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x3d7e9
jmp 0x3d885
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
leaq -0x110(%rbp), %rsi
movslq -0x114(%rbp), %rdx
shlq $0x3, %rdx
callq 0x111d0
movq -0x120(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3dac7
jmp 0x3d8b6
movq -0x10(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3d7c5
movl $0x0, -0x34(%rbp)
jmp 0x3dac2
jmp 0x3d8dd
jmp 0x3d8df
movq -0x130(%rbp), %rcx
movl -0x114(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x114(%rbp)
cltq
movq %rcx, -0x110(%rbp,%rax,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jl 0x3dac0
movq -0x20(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x3d931
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x140(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq -0x140(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x140(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x140(%rbp), %rcx
movq -0x140(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x140(%rbp), %rcx
movq -0x140(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq -0x120(%rbp), %rax
jne 0x3d9cd
jmp 0x3d9bd
jmp 0x3d9bf
movq -0x140(%rbp), %rax
movq %rax, -0x120(%rbp)
jmp 0x3d9cf
movq -0x140(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
movl %eax, -0x144(%rbp)
movq -0x140(%rbp), %rdi
addq $0x18, %rdi
leaq -0x110(%rbp), %rsi
movslq -0x144(%rbp), %rdx
shlq $0x3, %rdx
callq 0x111d0
movl -0x144(%rbp), %ecx
movl -0x114(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x114(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movslq -0x144(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movslq -0x114(%rbp), %rdx
shlq $0x3, %rdx
callq 0x11260
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jne 0x3daa2
jmp 0x3da72
jmp 0x3da74
jmp 0x3da76
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
leaq -0x110(%rbp), %rsi
movslq -0x114(%rbp), %rdx
shlq $0x3, %rdx
callq 0x111d0
movq -0x120(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3dac7
jmp 0x3daa4
movq -0x20(%rbp), %rax
movw (%rax), %ax
shlw $0x8, %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3da56
movl $0x0, -0x38(%rbp)
jmp 0x3dac2
jmp 0x3d6ba
movq -0x8(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop