// File: /workspace/github_c_makefile_star2_O0/imaya[P]zopfli-for-emscripten/blocksplitter.c
// Function: FindMinimum
static size_t FindMinimum(FindMinimumFun f, void* context,
                          size_t start, size_t end) {
  if (end - start < 1024) {
    double best = ZOPFLI_LARGE_FLOAT;
    size_t result = start;
    size_t i;
    for (i = start; i < end; i++) {
      double v = f(i, context);
      if (v < best) {
        best = v;
        result = i;
      }
    }
    return result;
  } else {
    /* Try to find minimum faster by recursively checking multiple points. */
#define NUM 9  /* Good value: 9. */
    size_t i;
    size_t p[NUM];
    double vp[NUM];
    size_t besti;
    double best;
    double lastbest = ZOPFLI_LARGE_FLOAT;
    size_t pos = start;

    for (;;) {
      if (end - start <= NUM) break;

      for (i = 0; i < NUM; i++) {
        p[i] = start + (i + 1) * ((end - start) / (NUM + 1));
        vp[i] = f(p[i], context);
      }
      besti = 0;
      best = vp[0];
      for (i = 1; i < NUM; i++) {
        if (vp[i] < best) {
          best = vp[i];
          besti = i;
        }
      }
      if (best > lastbest) break;

      start = besti == 0 ? start : p[besti - 1];
      end = besti == NUM - 1 ? end : p[besti + 1];

      pos = p[besti];
      lastbest = best;
    }
    return pos;
#undef NUM
  }
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x118(%rsp)
movq %rsi, 0x110(%rsp)
movq %rdx, 0x108(%rsp)
movq %rcx, 0x100(%rsp)
movq 0x100(%rsp), %rax
subq 0x108(%rsp), %rax
cmpq $0x400, %rax            # imm = 0x400
jae 0x16f3
movsd 0xb9dd(%rip), %xmm0     # 0xd008
movsd %xmm0, 0xf8(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
cmpq 0x100(%rsp), %rax
jae 0x16de
movq 0x118(%rsp), %rax
movq 0xe8(%rsp), %rdi
movq 0x110(%rsp), %rsi
callq *%rax
movsd %xmm0, 0xe0(%rsp)
movsd 0xe0(%rsp), %xmm1
movsd 0xf8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x16c3
movsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0xf8(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x16c5
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
jmp 0x1654
movq 0xf0(%rsp), %rax
movq %rax, 0x120(%rsp)
jmp 0x1911
movsd 0xb90d(%rip), %xmm0     # 0xd008
movsd %xmm0, 0x28(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x100(%rsp), %rax
subq 0x108(%rsp), %rax
cmpq $0x9, %rax
ja 0x1729
jmp 0x1904
movq $0x0, 0xd8(%rsp)
cmpq $0x9, 0xd8(%rsp)
jae 0x17df
movq 0x108(%rsp), %rcx
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
movq 0x100(%rsp), %rax
subq 0x108(%rsp), %rax
movl $0xa, %esi
xorl %edx, %edx
divq %rsi
movq %rax, %rdx
movq 0x18(%rsp), %rax
imulq %rdx, %rax
addq %rax, %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x90(%rsp,%rax,8)
movq 0x118(%rsp), %rax
movq 0xd8(%rsp), %rcx
movq 0x90(%rsp,%rcx,8), %rdi
movq 0x110(%rsp), %rsi
callq *%rax
movq 0xd8(%rsp), %rax
movsd %xmm0, 0x40(%rsp,%rax,8)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x1735
movq $0x0, 0x38(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq $0x1, 0xd8(%rsp)
cmpq $0x9, 0xd8(%rsp)
jae 0x185e
movq 0xd8(%rsp), %rax
movsd 0x40(%rsp,%rax,8), %xmm1
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1846
movq 0xd8(%rsp), %rax
movsd 0x40(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x1848
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x1800
movsd 0x30(%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0x1871
jmp 0x1904
cmpq $0x0, 0x38(%rsp)
jne 0x1888
movq 0x108(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x189e
movq 0x38(%rsp), %rax
subq $0x1, %rax
movq 0x90(%rsp,%rax,8), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x108(%rsp)
cmpq $0x8, 0x38(%rsp)
jne 0x18c2
movq 0x100(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x18d4
movq 0x38(%rsp), %rax
movq 0x98(%rsp,%rax,8), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x38(%rsp), %rax
movq 0x90(%rsp,%rax,8), %rax
movq %rax, 0x20(%rsp)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
jmp 0x170e
movq 0x20(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x120(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
retq
nopw %cs:(%rax,%rax)