// File: attractivechaos[P]udb2/khashl/./../common-block.c
// Function: main
int main(int argc, char *argv[])
{
	uint32_t test_int(uint32_t n, uint32_t x0);
	int c;
	double t, t0;
	uint32_t i, m = 5, max = 50000000, n = 10000000, x0 = 1, step;
	uint64_t sum;
	long m0;

	while ((c = getopt(argc, argv, "n:x:0:k:")) >= 0) {
		if (c == 'n') n = atol(optarg);
		else if (c == 'x') max = atol(optarg);
		else if (c == '0') x0 = atol(optarg);
		else if (c == 'k') m = atoi(optarg);
	}

	t = cputime();
	sum = traverse_rng(n, x0);
	t0 = cputime() - t;
	fprintf(stderr, "CPU time spent on RNG: %.3f sec; total sum: %lu\n", t0, (unsigned long)sum);
	m0 = peakrss();

	step = (max - n) / m;
	for (i = 0; i <= m; ++i, n += step) {
		double t, mem;
		uint32_t size;
		t = cputime();
		size = test_int(n, x0);
		t = cputime() - t;
		mem = (peakrss() - m0) / 1024.0 / 1024.0;
		printf("%d\t%d\t%.3f\t%.3f\t%.4f\t%.4f\n", i, n, t, mem, t * 1e6 / n, mem * 1e6 / size);
	}
	return 0;
}

// Assembly:
subq $0x68, %rsp
movl $0x0, 0x64(%rsp)
movl %edi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movl $0x5, 0x38(%rsp)
movl $0x2faf080, 0x34(%rsp)  # imm = 0x2FAF080
movl $0x989680, 0x30(%rsp)   # imm = 0x989680
movl $0x1, 0x2c(%rsp)
movl 0x60(%rsp), %edi
movq 0x58(%rsp), %rsi
leaq 0x1afb(%rip), %rdx      # 0x3020
callq 0x10e0
movl %eax, 0x54(%rsp)
cmpl $0x0, %eax
jl 0x15ac
cmpl $0x6e, 0x54(%rsp)
jne 0x154f
movq 0x3a97(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10c0
movl %eax, 0x30(%rsp)
jmp 0x15a7
cmpl $0x78, 0x54(%rsp)
jne 0x156b
movq 0x3a7b(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10c0
movl %eax, 0x34(%rsp)
jmp 0x15a5
cmpl $0x30, 0x54(%rsp)
jne 0x1587
movq 0x3a5f(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10c0
movl %eax, 0x2c(%rsp)
jmp 0x15a3
cmpl $0x6b, 0x54(%rsp)
jne 0x15a1
movq 0x3a43(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x10f0
movl %eax, 0x38(%rsp)
jmp 0x15a3
jmp 0x15a5
jmp 0x15a7
jmp 0x1515
callq 0x1700
movsd %xmm0, 0x48(%rsp)
movl 0x30(%rsp), %edi
movl 0x2c(%rsp), %esi
callq 0x1200
movq %rax, 0x20(%rsp)
callq 0x1700
subsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x3a17(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movsd 0x40(%rsp), %xmm0
movq 0x20(%rsp), %rdx
leaq 0x1a33(%rip), %rsi      # 0x3029
movb $0x1, %al
callq 0x1080
callq 0x1750
movq %rax, 0x18(%rsp)
movl 0x34(%rsp), %eax
subl 0x30(%rsp), %eax
xorl %edx, %edx
divl 0x38(%rsp)
movl %eax, 0x28(%rsp)
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x38(%rsp), %eax
ja 0x16f4
callq 0x1700
movsd %xmm0, 0x10(%rsp)
movl 0x30(%rsp), %edi
movl 0x2c(%rsp), %esi
callq 0x1780
movl %eax, 0x4(%rsp)
callq 0x1700
movsd 0x10(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x1750
movq 0x18(%rsp), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd 0x198e(%rip), %xmm1     # 0x3008
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x3c(%rsp), %esi
movl 0x30(%rsp), %eax
movl %eax, %edx
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movsd 0x196a(%rip), %xmm4     # 0x3010
movaps %xmm0, %xmm2
mulsd %xmm4, %xmm2
cvtsi2sd %rax, %xmm3
divsd %xmm3, %xmm2
movaps %xmm1, %xmm3
mulsd %xmm4, %xmm3
movl 0x4(%rsp), %eax
cvtsi2sd %rax, %xmm4
divsd %xmm4, %xmm3
leaq 0x1989(%rip), %rdi      # 0x305a
movb $0x4, %al
callq 0x1040
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
movl 0x28(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x1621
xorl %eax, %eax
addq $0x68, %rsp
retq
nopl (%rax,%rax)