// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x12cc
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1750
jmp 0x12ce
cmpl $0x2, -0x8(%rbp)
je 0x12f6
movq 0xbd1d(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x8d3b(%rip), %rsi      # 0xa020
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1160
callq 0x1070
movl $0x0, (%rax)
movq $0x1, -0x18(%rbp)
movq -0x18(%rbp), %rax
shrq %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jbe 0x1365
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movsd 0x8cde(%rip), %xmm0     # 0xa008
movsd 0x8cde(%rip), %xmm1     # 0xa010
xorl %esi, %esi
callq 0x15b0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x8cc8(%rip), %xmm1     # 0xa018
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x18(%rbp)
jmp 0x13cd
movq $-0x1, -0x18(%rbp)
movb $0x1, %al
testb $0x1, %al
jne 0x1375
jmp 0x139a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rdx
movq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x1660
movq %rax, -0x18(%rbp)
jmp 0x13cb
movq 0xbc57(%rip), %rax      # 0xcff8
movq (%rax), %rdi
leaq 0x8c87(%rip), %rsi      # 0xa032
leaq 0x8cee(%rip), %rdx      # 0xa0a0
leaq 0x8cec(%rip), %rcx      # 0xa0a5
movl $0x23, %r8d
movb $0x0, %al
callq 0x10f0
callq 0x1060
jmp 0x13cd
callq 0x1070
cmpl $0x0, (%rax)
je 0x1428
jmp 0x13d9
callq 0x1070
cmpl $0x0, (%rax)
je 0x1406
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x8cba(%rip), %rdi      # 0xa0ac
movb $0x0, %al
callq 0x1810
callq 0x1070
movl $0x0, (%rax)
jmp 0x141c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x8c97(%rip), %rdi      # 0xa0ac
movb $0x0, %al
callq 0x1a60
jmp 0x141e
movl $0x1, %edi
callq 0x1160
movl $0x500000, %edi         # imm = 0x500000
callq 0x1110
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x147d
jmp 0x143e
callq 0x1070
cmpl $0x0, (%rax)
je 0x1463
leaq 0x8c75(%rip), %rdi      # 0xa0c4
movb $0x0, %al
callq 0x1810
callq 0x1070
movl $0x0, (%rax)
jmp 0x1471
leaq 0x8c5a(%rip), %rdi      # 0xa0c4
movb $0x0, %al
callq 0x1a60
jmp 0x1473
movl $0x1, %edi
callq 0x1160
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
shlq $0x10, %rax
cmpq -0x18(%rbp), %rax
jae 0x15a0
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rcx
shlq $0x10, %rcx
addq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq -0x18(%rbp), %rcx
movb %al, -0x31(%rbp)
jae 0x14c4
cmpq $0x10000, -0x28(%rbp)   # imm = 0x10000
setb %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x14cd
jmp 0x1511
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
imulq $0x50, -0x28(%rbp), %rax
addq %rax, %rdx
callq 0x1ca0
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
imulq $0x50, -0x28(%rbp), %rax
addq $0x28, %rax
addq %rax, %rdx
callq 0x1e00
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x149f
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x50, %edx
leaq 0x1fb(%rip), %rcx       # 0x1720
callq 0x1080
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq 0xba9f(%rip), %rax      # 0xcfd8
movq (%rax), %rcx
movl $0x50, %esi
callq 0x1170
cmpq -0x28(%rbp), %rax
jae 0x158d
jmp 0x154e
callq 0x1070
cmpl $0x0, (%rax)
je 0x1573
leaq 0x8b6c(%rip), %rdi      # 0xa0cb
movb $0x0, %al
callq 0x1810
callq 0x1070
movl $0x0, (%rax)
jmp 0x1581
leaq 0x8b51(%rip), %rdi      # 0xa0cb
movb $0x0, %al
callq 0x1a60
jmp 0x1583
movl $0x1, %edi
callq 0x1160
jmp 0x158f
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1485
movq -0x30(%rbp), %rdi
callq 0x1030
xorl %edi, %edi
callq 0x1160