// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]kivaloo/bench/mkpairs/main.c
// Function: main
int
main(int argc, char * argv[])
{
	uintmax_t N;
	uint64_t X, Y;
	uint8_t * buf;

	WARNP_INIT;

	/* Check number of arguments. */
	if (argc != 2) {
		fprintf(stderr, "usage: mkpairs N\n");
		exit(1);
	}

	/* Parse N. */
	if (PARSENUM(&N, argv[1])) {
		warnp("Invalid value for N: %s", argv[1]);
		exit(1);
	}

	/* Allocate buffer for 2^16 key-value pairs. */
	if ((buf = malloc(40 * 2 * 65536)) == NULL) {
		warnp("malloc");
		exit(1);
	}

	/* Create groups of key-value pairs. */
	for (X = 0; (X << 16) < N; X++) {
		/* Generate key-value pairs. */
		for (Y = 0; ((X << 16) + Y < N) && (Y < (1 << 16)); Y++) {
			mkkey(X, Y, &buf[Y * 80]);
			mkval(X, Y, &buf[Y * 80 + 40]);
		}

		/* Sort key-value pairs. */
		qsort(buf, (size_t)Y, 80, compar);

		/* Write out key-value pairs. */
		if (fwrite(buf, 80, (size_t)Y, stdout) < Y) {
			warnp("fwrite");
			exit(1);
		}
	}

	/* Free buffer. */
	free(buf);

	/* Success! */
	exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movl %edi, %ebx
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x13cc
callq 0x1598
cmpl $0x2, %ebx
jne 0x1404
callq 0x1060
movl $0x0, (%rax)
movq 0x8(%r15), %rbx
testq %rbx, %rbx
jne 0x142e
leaq 0x3c50(%rip), %rdi      # 0x503c
leaq 0x3c53(%rip), %rsi      # 0x5046
leaq 0x3c6e(%rip), %rcx      # 0x5068
movl $0xbb, %edx
callq 0x1090
movq 0x5bed(%rip), %rax      # 0x6ff8
movq (%rax), %rcx
leaq 0x3bef(%rip), %rdi      # 0x5004
movl $0x11, %esi
movl $0x1, %edx
callq 0x1160
movl $0x1, %edi
callq 0x1150
movq %rax, %r13
leaq 0x10(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1120
movq %rax, %r14
movq (%r12), %rax
cmpq %rbx, %rax
je 0x1454
cmpb $0x0, (%rax)
je 0x145c
movl $0x16, (%r13)
cmpl $0x0, (%r13)
jne 0x1482
movl $0x500000, %edi         # imm = 0x500000
callq 0x1100
testq %rax, %rax
jne 0x149e
leaq 0x3bb5(%rip), %rdi      # 0x502e
xorl %eax, %eax
callq 0x1737
jmp 0x1424
movq 0x8(%r15), %rsi
leaq 0x3b89(%rip), %rdi      # 0x5016
xorl %eax, %eax
callq 0x1618
movl $0x0, (%r13)
jmp 0x1424
movq %rax, %r15
movq %r13, (%rsp)
testq %r14, %r14
je 0x154e
movl $0x1, %ebx
xorl %r12d, %r12d
movq %r15, 0x8(%rsp)
xorl %ebp, %ebp
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x185c
leaq 0x28(%r15), %rdx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x193e
leaq 0x1(%rbp), %r13
cmpq $0xfffe, %rbp           # imm = 0xFFFE
ja 0x14f6
addq %rbx, %rbp
addq $0x50, %r15
cmpq %r14, %rbp
movq %r13, %rbp
jb 0x14bd
movl $0x50, %edx
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq 0x7e(%rip), %rcx        # 0x158b
callq 0x1070
movq 0x5abf(%rip), %rax      # 0x6fd8
movq (%rax), %rcx
movl $0x50, %esi
movq %r15, %rdi
movq %r13, %rdx
callq 0x1160
decq %r13
cmpq %r13, %rax
jbe 0x155d
incq %r12
movq %r12, %rax
shlq $0x10, %rax
addq $0x10000, %rbx          # imm = 0x10000
cmpq %r14, %rax
jb 0x14bb
movq %r15, %rdi
callq 0x1030
xorl %edi, %edi
callq 0x1150
movq (%rsp), %rbx
cmpl $0x0, (%rbx)
jne 0x1572
leaq 0x3ac8(%rip), %rdi      # 0x5035
jmp 0x1479
leaq 0x3abc(%rip), %rdi      # 0x5035
xorl %eax, %eax
callq 0x1618
movl $0x0, (%rbx)
jmp 0x1424