// File: /workspace/github_c_makefile_star2_O2/ryancdotorg[P]bloomslice/bloomutl.c
// Function: bloom_pick_hash_es
uint8_t bloom_pick_hash_es(double max_error, double max_bloom_saturation, uint64_t n, uint8_t *max_w, uint8_t *new_k) {
  if (max_error < 0 || max_bloom_saturation < 0) return 255;

  int i;

  uint8_t w, k;
  uint64_t m;

  double e, s;

  uint8_t max_k_by_w[49];
  for (i = 0; i <= 48; ++i) {
    if (i < 9) {
      max_k_by_w[i] = hash1sN;
    } else if (i < 17) {
      max_k_by_w[i] = hash2bN;
    } else if (i < 33) {
      max_k_by_w[i] = hash2sN;
    } else {
      max_k_by_w[i] = hash3sN;
    }
  }

  w = 8; m = 1<<w; k = 1;

  s = bloom_saturation(k, m, n);
  e = pow(s, k);

  while (e > max_error || s > max_bloom_saturation) {
    if (k >= max_k_by_w[w]) {
      m <<= 1; ++w; k = 0;
      if (w > *max_w) return 255;
    }
    ++k;
    s = bloom_saturation(k, m, n);
    e = pow(s, (double)k);
  }

  *max_w = w;

  if (new_k) *new_k = k;

  return bloom_pick_hash_wk(w, k);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
xorpd %xmm2, %xmm2
movsd %xmm0, 0x10(%rsp)
ucomisd %xmm0, %xmm2
movb $-0x1, %al
ja 0x598d
ucomisd %xmm1, %xmm2
ja 0x598d
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x3951(%rip), %rax      # 0x9160
movb (%rax), %al
leaq 0x3a78(%rip), %rcx      # 0x9290
movb (%rcx), %cl
leaq 0x3ae4(%rip), %rdx      # 0x9305
movb (%rdx), %dl
leaq 0x3ad0(%rip), %rsi      # 0x92fa
movb (%rsi), %sil
xorl %r8d, %r8d
cmpq $0x31, %r8
je 0x5867
cmpq $0x8, %r8
ja 0x5843
movb %sil, 0x30(%rsp,%r8)
jmp 0x5862
cmpq $0x10, %r8
ja 0x5850
movb %dl, 0x30(%rsp,%r8)
jmp 0x5862
cmpq $0x20, %r8
ja 0x585d
movb %cl, 0x30(%rsp,%r8)
jmp 0x5862
movb %al, 0x30(%rsp,%r8)
incq %r8
jmp 0x5830
movsd %xmm1, 0x8(%rsp)
movq %rdi, %xmm0
punpckldq 0x7b6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7be(%rip), %xmm0      # 0x6040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x181a(%rip), %xmm0     # 0x70b0
movapd %xmm1, 0x20(%rsp)
callq 0x1090
movapd %xmm0, %xmm1
movsd 0x773(%rip), %xmm0      # 0x6020
subsd %xmm1, %xmm0
movl $0x100, %r15d           # imm = 0x100
movb $0x1, %bpl
movb $0x8, %r12b
movsd %xmm0, (%rsp)
ucomisd 0x10(%rsp), %xmm0
movzbl %r12b, %edi
movsd 0x8(%rsp), %xmm0
ja 0x58e3
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5975
cmpb 0x30(%rsp,%rdi), %bpl
jb 0x58fb
incb %r12b
cmpb (%r14), %r12b
ja 0x598b
addq %r15, %r15
xorl %ebp, %ebp
incb %bpl
movq %r15, %xmm0
punpckldq 0x725(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x72d(%rip), %xmm0      # 0x6040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x6f9(%rip), %xmm0      # 0x6020
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movzbl %bpl, %eax
cvtsi2sd %eax, %xmm2
movsd %xmm2, 0x18(%rsp)
movapd 0x20(%rsp), %xmm1
mulsd %xmm2, %xmm1
callq 0x1090
movsd 0x6c8(%rip), %xmm1      # 0x6020
subsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd %xmm1, %xmm0
movsd 0x18(%rsp), %xmm1
callq 0x1090
jmp 0x58c2
movb %r12b, (%r14)
testq %rbx, %rbx
je 0x5980
movb %bpl, (%rbx)
movzbl %bpl, %esi
callq 0x562b
jmp 0x598d
movb $-0x1, %al
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop