// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x10(%rbp), %xmm0
ja 0x9825
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0x982e
movb $-0x1, -0x1(%rbp)
jmp 0x99d3
movl $0x0, -0x34(%rbp)
cmpl $0x30, -0x34(%rbp)
jg 0x98b4
cmpl $0x9, -0x34(%rbp)
jge 0x9857
leaq 0x4ab2(%rip), %rax      # 0xe2fa
movb (%rax), %cl
movslq -0x34(%rbp), %rax
movb %cl, -0x90(%rbp,%rax)
jmp 0x98a7
cmpl $0x11, -0x34(%rbp)
jge 0x9873
leaq 0x4aa1(%rip), %rax      # 0xe305
movb (%rax), %cl
movslq -0x34(%rbp), %rax
movb %cl, -0x90(%rbp,%rax)
jmp 0x98a5
cmpl $0x21, -0x34(%rbp)
jge 0x988f
leaq 0x4a10(%rip), %rax      # 0xe290
movb (%rax), %cl
movslq -0x34(%rbp), %rax
movb %cl, -0x90(%rbp,%rax)
jmp 0x98a3
leaq 0x48ca(%rip), %rax      # 0xe160
movb (%rax), %cl
movslq -0x34(%rbp), %rax
movb %cl, -0x90(%rbp,%rax)
jmp 0x98a5
jmp 0x98a7
jmp 0x98a9
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9835
movb $0x8, -0x35(%rbp)
movb -0x35(%rbp), %cl
movl $0x1, %eax
shll %cl, %eax
cltq
movq %rax, -0x40(%rbp)
movb $0x1, -0x36(%rbp)
movzbl -0x36(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x9070
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movzbl -0x36(%rbp), %eax
cvtsi2sd %eax, %xmm1
callq 0x1080
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movb $0x1, %al
ucomisd -0x10(%rbp), %xmm0
movb %al, -0x91(%rbp)
ja 0x9920
movsd -0x50(%rbp), %xmm0
ucomisd -0x18(%rbp), %xmm0
seta %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x992c
jmp 0x99a8
movzbl -0x36(%rbp), %eax
movzbl -0x35(%rbp), %ecx
movzbl -0x90(%rbp,%rcx), %ecx
cmpl %ecx, %eax
jl 0x996e
movq -0x40(%rbp), %rax
shlq %rax
movq %rax, -0x40(%rbp)
movb -0x35(%rbp), %al
addb $0x1, %al
movb %al, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
movzbl -0x35(%rbp), %eax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jle 0x996c
movb $-0x1, -0x1(%rbp)
jmp 0x99d3
jmp 0x996e
movb -0x36(%rbp), %al
incb %al
movb %al, -0x36(%rbp)
movzbl -0x36(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x9070
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movzbl -0x36(%rbp), %eax
cvtsi2sd %eax, %xmm1
callq 0x1080
movsd %xmm0, -0x48(%rbp)
jmp 0x98f9
movb -0x35(%rbp), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0x99c1
movb -0x36(%rbp), %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movb -0x35(%rbp), %al
movzbl %al, %edi
movzbl -0x36(%rbp), %esi
callq 0x93c0
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0xa0, %rsp
popq %rbp
retq
nop