// File: /workspace/github_c_makefile_star2_O1/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 $0x8, %rax
ja 0x133b
movb $0xa, 0x40(%rsp,%rax)
jmp 0x135a
cmpq $0x10, %rax
ja 0x1348
movb $-0x42, 0x40(%rsp,%rax)
jmp 0x135a
cmpq $0x20, %rax
ja 0x1355
movb $0x2d, 0x40(%rsp,%rax)
jmp 0x135a
movb $0x78, 0x40(%rsp,%rax)
incq %rax
cmpq $0x31, %rax
jne 0x132e
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x100, %r13d           # imm = 0x100
movl $0x1, %ebp
movb $0x8, %r14b
xorl %ebx, %ebx
movl $0x1, %r15d
movl $0x1, %esi
movsd %xmm0, 0x8(%rsp)
cmpl $0xb, %r15d
setb %al
cmpb $0x11, %r14b
setb %cl
leaq 0xccd(%rip), %rdx       # 0x2070
testb %cl, %al
jne 0x13f7
cmpl $0xbe, %r15d
ja 0x13bf
leal -0x9(%r14), %eax
leaq 0xcbc(%rip), %rdx       # 0x2077
cmpb $0x8, %al
jb 0x13f7
cmpl $0x2d, %r15d
ja 0x13d4
leal -0x11(%r14), %eax
leaq 0xcae(%rip), %rdx       # 0x207e
cmpb $0x10, %al
jb 0x13f7
leal -0x21(%r14), %eax
cmpb $0x10, %al
leaq 0xcab(%rip), %rcx       # 0x208c
movq %rcx, %rdx
leaq 0xc9a(%rip), %rax       # 0x2085
cmovbq %rax, %rdx
cmpl $0x79, %r15d
cmovaeq %rcx, %rdx
movl %esi, %eax
shll $0x1a, %eax
cmpq %rax, %rbx
seta %cl
shll %cl, %esi
movsd 0xc3c(%rip), %xmm0      # 0x2048
movsd 0x10(%rsp), %xmm2
ucomisd %xmm2, %xmm0
movl %esi, 0x1c(%rsp)
movq %rdx, 0x38(%rsp)
jb 0x150e
movsd 0xc23(%rip), %xmm0      # 0x2050
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x1516
movl %esi, %r12d
movq %r13, %xmm0
punpckldq 0xbc3(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xbcb(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xbd7(%rip), %xmm2      # 0x2040
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
movl %r15d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
addq %r12, %rbx
movq %rbx, %xmm0
punpckldq 0xb74(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb7c(%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 0xb77(%rip), %xmm1      # 0x2040
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x1030
movapd %xmm0, %xmm2
movsd 0xb5a(%rip), %xmm0      # 0x2048
ucomisd %xmm2, %xmm0
jb 0x150e
movsd 0xb54(%rip), %xmm0      # 0x2050
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movapd %xmm1, %xmm0
jae 0x148c
jmp 0x151a
movsd 0x8(%rsp), %xmm0
jmp 0x151a
movapd %xmm1, %xmm0
ucomisd 0xb26(%rip), %xmm2      # 0x2048
ja 0x1532
ucomisd 0xb24(%rip), %xmm0      # 0x2050
jbe 0x1613
movq %rbx, %xmm0
punpckldq 0xad1(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xad9(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movzbl %r14b, %r14d
movzbl 0x40(%rsp,%r14), %eax
cmpl %eax, %r15d
leal 0x1(%r15), %eax
setae %cl
movl %eax, %r15d
cmovael %ebp, %r15d
shlq %cl, %r13
addb %cl, %r14b
movq %r13, %xmm0
punpckldq 0xa89(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xa91(%rip), %xmm0      # 0x2020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xa9d(%rip), %xmm0      # 0x2040
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
subsd %xmm2, %xmm0
xorps %xmm2, %xmm2
cvtsi2sd %r15, %xmm2
movsd %xmm2, 0x10(%rsp)
movapd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm1
callq 0x1030
movsd 0xa6c(%rip), %xmm1      # 0x2040
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x1030
movapd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
ucomisd 0xa49(%rip), %xmm2      # 0x2048
ja 0x1559
ucomisd 0xa43(%rip), %xmm0      # 0x2050
ja 0x1559
movabsq $0x253fca1c0, %rax      # imm = 0x253FCA1C0
cmpq %rax, %rbx
ja 0x166e
cmpb $0x28, %r14b
ja 0x166e
movzbl %r14b, %edx
movsd %xmm0, 0x8(%rsp)
mulsd 0xa1e(%rip), %xmm0      # 0x2058
movsd 0x9fe(%rip), %xmm1      # 0x2040
movsd %xmm2, 0x10(%rsp)
divsd %xmm2, %xmm1
leaq 0xa40(%rip), %rdi       # 0x2093
movq %rbx, %rsi
movq 0x38(%rsp), %rcx
movl %r15d, %r8d
movb $0x2, %al
callq 0x1040
movl 0x1c(%rsp), %esi
jmp 0x138e
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq