// File: /workspace/github_c_makefile_star2_O2/ryancdotorg[P]bloomslice/pcalc.c
// Function: main
int main() {
    int i;
    unsigned char *h;

    uint8_t log2m;
    uint32_t k, inc;
    uint64_t m, n;
    double fp, st;

    uint8_t max_k_by_log2m[49];
    for (i = 0; i <= 48; ++i) {
        if (i < 9) {
            max_k_by_log2m[i] =  10;
        } else if (i < 17) {
            max_k_by_log2m[i] = 190;
        } else if (i < 33) {
            max_k_by_log2m[i] =  45;
        } else {
            max_k_by_log2m[i] = 120;
        }
    }

    n = 0;
    log2m = 8; m = 1<<log2m;
    k = 1;
    inc = 1;

    st = fp = 0;

    for (;;) {
        if (k <= 10 && log2m <= 16) {
            h = "hash1s";
        } else if (k <= 190 && log2m >  8 && log2m <= 16) {
            h = "hash2b";
        } else if (k <=  45 && log2m > 16 && log2m <= 32) {
            h = "hash2s";
        } else if (k <= 120 && log2m > 32 && log2m <= 48) {
            h = "hash3s";
        } else {
            h = "NOHASH";
        }


        if (n > inc<<26) inc <<= 1;

        while (fp <= MAX_FP_RATE && st <= MAX_SATURATION) {
            n += inc;
            st = saturation(k, m, n);
            fp = pow(st, (double)k);
        }

        while (fp > MAX_FP_RATE || st > MAX_SATURATION) {
            if (k >= max_k_by_log2m[log2m]) {
                m <<= 1; ++log2m;
                k = 0;
            }
            ++k;
            st = saturation(k, m, n);
            fp = pow(st, (double)k);
        }

        if ((n > 9999*1000000ULL) || (log2m > 40)) {
            break;
        } else {
            printf("%10zu   %2u   %s   %3u   %4.1f%%   1 in %.2e\n", n, log2m, h, k, st*100, 1/fp);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
xorl %eax, %eax
cmpq $0x31, %rax
je 0x1362
cmpq $0x8, %rax
ja 0x133e
movb $0xa, 0x40(%rsp,%rax)
jmp 0x135d
cmpq $0x10, %rax
ja 0x134b
movb $-0x42, 0x40(%rsp,%rax)
jmp 0x135d
cmpq $0x20, %rax
ja 0x1358
movb $0x2d, 0x40(%rsp,%rax)
jmp 0x135d
movb $0x78, 0x40(%rsp,%rax)
incq %rax
jmp 0x132b
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x100, %r13d           # imm = 0x100
pushq $0x1
popq %rax
movb $0x8, %r14b
xorl %ebx, %ebx
movl %eax, %ebp
movl %eax, %r12d
movsd %xmm0, 0x8(%rsp)
cmpl $0xb, %ebp
setb %al
cmpb $0x11, %r14b
setb %cl
leaq 0xcd7(%rip), %rdx       # 0x2070
testb %cl, %al
jne 0x13ea
cmpl $0xbe, %ebp
ja 0x13b4
leal -0x9(%r14), %eax
leaq 0xcc7(%rip), %rdx       # 0x2077
cmpb $0x8, %al
jb 0x13ea
cmpl $0x2d, %ebp
ja 0x13c8
leal -0x11(%r14), %eax
leaq 0xcba(%rip), %rdx       # 0x207e
cmpb $0x10, %al
jb 0x13ea
leal -0x21(%r14), %eax
cmpb $0x10, %al
leaq 0xcb7(%rip), %rcx       # 0x208c
movq %rcx, %rdx
leaq 0xca6(%rip), %rax       # 0x2085
cmovbq %rax, %rdx
cmpl $0x79, %ebp
cmovaeq %rcx, %rdx
movq %rdx, 0x38(%rsp)
movl %r12d, %eax
shll $0x1a, %eax
cmpq %rax, %rbx
seta %cl
shll %cl, %r12d
movq %r13, %xmm0
punpckldq 0xc05(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc0d(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xc19(%rip), %xmm2      # 0x2040
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
movl %ebp, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm2
movsd 0xbf4(%rip), %xmm0      # 0x2048
ucomisd %xmm2, %xmm0
jb 0x14c6
movsd 0xbee(%rip), %xmm0      # 0x2050
ucomisd 0x8(%rsp), %xmm0
jb 0x14c6
addq %r12, %rbx
movq %rbx, %xmm0
punpckldq 0xb96(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb9e(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x20(%rsp), %xmm0
callq 0x1030
movsd 0xb99(%rip), %xmm1      # 0x2040
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x1030
movapd %xmm0, %xmm2
jmp 0x144c
movq %rbx, %xmm0
punpckldq 0xb3d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb45(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
ucomisd 0xb53(%rip), %xmm2      # 0x2048
movzbl %r14b, %edx
ja 0x150f
movsd 0x8(%rsp), %xmm0
ucomisd 0xb47(%rip), %xmm0      # 0x2050
jbe 0x15a6
movzbl 0x40(%rsp,%rdx), %eax
leal 0x1(%rbp), %r15d
cmpl %eax, %ebp
setae %cl
pushq $0x1
popq %rax
cmovael %eax, %r15d
shlq %cl, %r13
addb %cl, %r14b
movq %r13, %xmm0
punpckldq 0xad9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xae1(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xaed(%rip), %xmm0      # 0x2040
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cvtsi2sd %r15, %xmm2
movsd %xmm2, 0x10(%rsp)
movapd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm1
callq 0x1030
movsd 0xabf(%rip), %xmm1      # 0x2040
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x1030
movapd %xmm0, %xmm2
movl %r15d, %ebp
jmp 0x14ed
movabsq $0x253fca1c0, %rax      # imm = 0x253FCA1C0
cmpq %rax, %rbx
ja 0x15f9
cmpb $0x28, %r14b
ja 0x15f9
movsd 0x8(%rsp), %xmm0
mulsd 0xa8f(%rip), %xmm0      # 0x2058
movsd 0xa6f(%rip), %xmm1      # 0x2040
movsd %xmm2, 0x18(%rsp)
divsd %xmm2, %xmm1
leaq 0xab1(%rip), %rdi       # 0x2093
movq %rbx, %rsi
movq 0x38(%rsp), %rcx
movl %ebp, %r8d
movb $0x2, %al
callq 0x1040
jmp 0x1385
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq