user: 请从给定的汇编指令推导出C源代码:

```asm
<mlr_bsearch_double_for_insert>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  movsd  %xmm0,-0x38(%rbp)
  movl   $0x0,-0x18(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jne    L42
  mov    $0x0,%eax
  jmp    L17
L42:
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm1
  movsd  -0x38(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L115
  mov    $0x0,%eax
  jmp    L17
L115:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd -0x38(%rbp),%xmm0
  jbe    L165
  mov    -0x2c(%rbp),%eax
  jmp    L17
L165:
  jmp    L183
L104:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x38(%rbp),%xmm0
  ucomisd -0x8(%rbp),%xmm0
  jp     L11
  movsd  -0x38(%rbp),%xmm0
  ucomisd -0x8(%rbp),%xmm0
  jne    L11
  mov    -0x10(%rbp),%eax
  jmp    L17
L11:
  movsd  -0x38(%rbp),%xmm0
  comisd -0x8(%rbp),%xmm0
  jbe    L156
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xc(%rbp)
  jmp    L127
L156:
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xc(%rbp)
L127:
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jne    L161
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x38(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jb     L86
  mov    -0x18(%rbp),%eax
  jmp    L17
L86:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x38(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jb     L170
  mov    -0x14(%rbp),%eax
  jmp    L17
L170:
  mov    -0x14(%rbp),%eax
  add    $0x1,%eax
  jmp    L17
L161:
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x10(%rbp)
L183:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L104
  mov    -0x18(%rbp),%eax
L17:
  pop    %rbp
  ret
```

assistant: ```c
int mlr_bsearch_double_for_insert(double *array, int size, double value) {
  int lo = 0;
  int hi = size - 1;
  int mid = (hi + lo) / 2;
  int newmid;
  if (size == 0)
    return 0;
  if (value > array[0])
    return 0;
  if (value < array[hi])
    return size;
  while (lo < hi) {
    double a = array[mid];
    if (value == a) {
      return mid;
    } else if (value > a) {
      hi = mid;
      newmid = (hi + lo) / 2;
    } else {
      lo = mid;
      newmid = (hi + lo) / 2;
    }
    if (mid == newmid) {
      if (value >= array[lo])
        return lo;
      else if (value >= array[hi])
        return hi;
      else
        return hi + 1;
    }
    mid = newmid;
  }
  return lo;
}
```