user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<charts_fixmax>:
  endbr64
  mov    %rdi,%rax
  mov    %rsi,%rdi
  mov    %rdx,%rsi
  movabs $0xdcef33a6f838000,%rdx
  cmp    %rdx,%rax
  jbe    L202
  movabs $0x6f05b59d3b1ffff,%rdx
  add    %rax,%rdx
  shr    $0x11,%rdx
  movabs $0x49c97747490f,%r8
  mov    %rdx,%rax
  mul    %r8
  shr    $0x18,%rdx
  mov    %rdx,(%rcx)
  movabs $0x6f05b59d3b20000,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L83
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L355:
  movl   $0x1,(%rsi)
  addl   $0x6,(%rdi)
  ret
L83:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L355
L202:
  movabs $0x1617eb90b26c000,%rdx
  cmp    %rdx,%rax
  jbe    L35
  movabs $0x11c37937e07fff,%rdx
  movabs $0x39a5652fb1137857,%r8
  lea    (%rdx,%rax,1),%rax
  mul    %r8
  shr    $0x32,%rdx
  mov    %rdx,(%rcx)
  movabs $0x11c37937e08000,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L50
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L379:
  movl   $0x0,(%rsi)
  addl   $0x5,(%rdi)
  ret
L50:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L379
L35:
  movabs $0x388f27d8d3000,%rdx
  cmp    %rdx,%rax
  jbe    L122
  movabs $0x1c6bf52633fff,%rdx
  add    %rax,%rdx
  shr    $0xe,%rdx
  movabs $0x24075f3dceac3,%r8
  mov    %rdx,%rax
  mul    %r8
  shr    $0x14,%rdx
  mov    %rdx,(%rcx)
  movabs $0x1c6bf52634000,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L210
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L218:
  movl   $0x1,(%rsi)
  addl   $0x5,(%rdi)
  ret
L210:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L218
L122:
  movabs $0x5a7ea627b800,%rdx
  cmp    %rdx,%rax
  jbe    L352
  movabs $0x48c27394fff,%rdx
  movabs $0x384b84d092ed0385,%r8
  lea    (%rdx,%rax,1),%rax
  mul    %r8
  shr    $0x28,%rdx
  mov    %rdx,(%rcx)
  movabs $0x48c27395000,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L228
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L187:
  movl   $0x0,(%rsi)
  addl   $0x4,(%rdi)
  ret
L228:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L187
L352:
  movabs $0xe7aa9f1e00,%rdx
  cmp    %rdx,%rax
  jbe    L208
  movabs $0x746a5287ff,%rdx
  movabs $0x232f33025bd42233,%r8
  lea    (%rdx,%rax,1),%rax
  mul    %r8
  shr    $0x24,%rdx
  mov    %rdx,(%rcx)
  movabs $0x746a528800,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L11
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L28:
  movl   $0x1,(%rsi)
  addl   $0x4,(%rdi)
  ret
L11:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L28
L208:
  movabs $0x172aa98300,%rdx
  cmp    %rdx,%rax
  jbe    L241
  movabs $0x12a05f1ff,%rdx
  movabs $0xdbe6fecebdedd5bf,%r8
  lea    (%rdx,%rax,1),%rax
  mul    %r8
  shr    $0x20,%rdx
  mov    %rdx,(%rcx)
  movabs $0x12a05f200,%rax
  imul   %rax,%rdx
  test   %rdx,%rdx
  js     L173
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
L111:
  movl   $0x0,(%rsi)
  addl   $0x3,(%rdi)
  ret
L173:
  shr    %rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L111
L241:
  cmp    $0x3b4e7ec0,%rax
  jbe    L145
  lea    0x1dcd64ff(%rax),%rdx
  shr    $0x8,%rdx
  movabs $0x44b82fa09b5a53,%r8
  mov    %rdx,%rax
  mul    %r8
  shr    $0xb,%rdx
  mov    %rdx,(%rcx)
  imul   $0x1dcd6500,%rdx,%rax
  test   %rax,%rax
  js     L311
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L85:
  movl   $0x1,(%rsi)
  addl   $0x3,(%rdi)
  ret
L311:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L85
L145:
  cmp    $0x5ee3fe0,%rax
  jbe    L321
  add    $0x4c4b3f,%rax
  movabs $0xd6bf94d5e57a42bd,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    $0x16,%rax
  mov    %rax,(%rcx)
  imul   $0x4c4b40,%rax,%rax
  test   %rax,%rax
  js     L266
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L56:
  movl   $0x0,(%rsi)
  addl   $0x2,(%rdi)
  ret
L266:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L56
L321:
  cmp    $0xf2eb8,%rax
  jbe    L274
  add    $0x7a11f,%rax
  movabs $0x431bde82d7b634db,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    $0x11,%rax
  mov    %rax,(%rcx)
  imul   $0x7a120,%rax,%rax
  test   %rax,%rax
  js     L275
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L324:
  movl   $0x1,(%rsi)
  addl   $0x2,(%rdi)
  ret
L275:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L324
L274:
  cmp    $0x184ac,%rax
  jbe    L42
  add    $0x1387,%rax
  mov    $0x1388,%r8d
  mov    $0x0,%edx
  div    %r8
  mov    %rax,(%rcx)
  imul   $0x1388,%rax,%rax
  test   %rax,%rax
  js     L79
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L353:
  movl   $0x0,(%rsi)
  addl   $0x1,(%rdi)
  ret
L79:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L353
L42:
  cmp    $0x3e3,%rax
  jbe    L362
  add    $0x1f3,%rax
  mov    $0x1f4,%r8d
  mov    $0x0,%edx
  div    %r8
  mov    %rax,(%rcx)
  imul   $0x1f4,%rax,%rax
  test   %rax,%rax
  js     L99
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L260:
  movl   $0x1,(%rsi)
  addl   $0x1,(%rdi)
  ret
L99:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L260
L362:
  cmp    $0x63,%rax
  jbe    L179
  add    $0x4,%rax
  mov    $0x5,%edi
  mov    $0x0,%edx
  div    %rdi
  mov    %rax,(%rcx)
  imul   $0x5,%rax,%rax
  test   %rax,%rax
  js     L359
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L272:
  movl   $0x0,(%rsi)
  ret
L359:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L272
L179:
  test   %rax,%rax
  mov    $0x1,%edx
  cmove  %rdx,%rax
  lea    (%rax,%rax,1),%rdx
  mov    %rdx,(%rcx)
  imul   $0xa,%rax,%rax
  test   %rax,%rax
  js     L190
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
L349:
  divsd  D0(%rip),%xmm0
  movl   $0x1,(%rsi)
  ret
L190:
  shr    %rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm0
  jmp    L349
```

tool_calls: name: unpack_data
arguments: data_tag: D0
type: f64

tool: D0: 10

assistant: ```c
double charts_fixmax(uint64_t max, uint8_t *scale, uint8_t *mode, uint16_t *base) {
  double rmax;
  if (max > 995000000000000000ULL) {
    (*base) = (max + 499999999999999999ULL) / 500000000000000000ULL;
    rmax = (*base) * 500000000000000000ULL;
    (*mode) = 1;
    (*scale) += 6;
  } else if (max > 99500000000000000ULL) {
    (*base) = (max + 4999999999999999ULL) / 5000000000000000ULL;
    rmax = (*base) * 5000000000000000ULL;
    (*mode) = 0;
    (*scale) += 5;
  } else if (max > 995000000000000ULL) {
    (*base) = (max + 499999999999999ULL) / 500000000000000ULL;
    rmax = (*base) * 500000000000000ULL;
    (*mode) = 1;
    (*scale) += 5;
  } else if (max > 99500000000000ULL) {
    (*base) = (max + 4999999999999ULL) / 5000000000000ULL;
    rmax = (*base) * 5000000000000ULL;
    (*mode) = 0;
    (*scale) += 4;
  } else if (max > 995000000000ULL) {
    (*base) = (max + 499999999999ULL) / 500000000000ULL;
    rmax = (*base) * 500000000000ULL;
    (*mode) = 1;
    (*scale) += 4;
  } else if (max > 99500000000ULL) {
    (*base) = (max + 4999999999ULL) / 5000000000ULL;
    rmax = (*base) * 5000000000ULL;
    (*mode) = 0;
    (*scale) += 3;
  } else if (max > 995000000ULL) {
    (*base) = (max + 499999999ULL) / 500000000ULL;
    rmax = (*base) * 500000000ULL;
    (*mode) = 1;
    (*scale) += 3;
  } else if (max > 99500000ULL) {
    (*base) = (max + 4999999ULL) / 5000000ULL;
    rmax = (*base) * 5000000ULL;
    (*mode) = 0;
    (*scale) += 2;
  } else if (max > 995000ULL) {
    (*base) = (max + 499999ULL) / 500000ULL;
    rmax = (*base) * 500000ULL;
    (*mode) = 1;
    (*scale) += 2;
  } else if (max > 99500ULL) {
    (*base) = (max + 4999ULL) / 5000ULL;
    rmax = (*base) * 5000ULL;
    (*mode) = 0;
    (*scale) += 1;
  } else if (max > 995ULL) {
    (*base) = (max + 499ULL) / 500ULL;
    rmax = (*base) * 500ULL;
    (*mode) = 1;
    (*scale) += 1;
  } else if (max > 99ULL) {
    (*base) = (max + 4ULL) / 5ULL;
    rmax = (*base) * 5ULL;
    (*mode) = 0;
  } else {
    if (max == 0) {
      max = 1;
    }
    (*base) = max * 2;
    rmax = ((*base) * 5) / 10.0;
    (*mode) = 1;
  }
  return rmax;
}
```