user: Translate the below assembly code into C programming language:

```asm
<charts_fixmax>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  movabs $0xdcef33a6f838000,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L44
  movabs $0x6f05b59d3b1ffff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  shr    $0x11,%rax
  movabs $0x49c97747490f,%rdx
  mul    %rdx
  shr    $0x18,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x6f05b59d3b20000,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L311
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L292
L311:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L292:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x6(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L44:
  movabs $0x1617eb90b26c000,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L409
  movabs $0x11c37937e07fff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movabs $0x39a5652fb1137857,%rdx
  mul    %rdx
  shr    $0x32,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x11c37937e08000,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L389
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L102
L389:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L102:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x5(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L409:
  movabs $0x388f27d8d3000,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L430
  movabs $0x1c6bf52633fff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  shr    $0xe,%rax
  movabs $0x24075f3dceac3,%rdx
  mul    %rdx
  shr    $0x14,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x1c6bf52634000,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L369
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L498
L369:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L498:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x5(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L430:
  movabs $0x5a7ea627b800,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L308
  movabs $0x48c27394fff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movabs $0x384b84d092ed0385,%rdx
  mul    %rdx
  shr    $0x28,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x48c27395000,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L176
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L33
L176:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L33:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x4(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L308:
  movabs $0xe7aa9f1e00,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L209
  movabs $0x746a5287ff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movabs $0x232f33025bd42233,%rdx
  mul    %rdx
  shr    $0x24,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x746a528800,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L359
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L32
L359:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L32:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x4(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L209:
  movabs $0x172aa98300,%rax
  cmp    %rax,-0x18(%rbp)
  jbe    L271
  movabs $0x12a05f1ff,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movabs $0xdbe6fecebdedd5bf,%rdx
  mul    %rdx
  shr    $0x20,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movabs $0x12a05f200,%rdx
  imul   %rdx,%rax
  test   %rax,%rax
  js     L195
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L381
L195:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L381:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x3(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L271:
  cmpq   $0x3b4e7ec0,-0x18(%rbp)
  jbe    L149
  mov    -0x18(%rbp),%rax
  add    $0x1dcd64ff,%rax
  shr    $0x8,%rax
  movabs $0x44b82fa09b5a53,%rdx
  mul    %rdx
  shr    $0xb,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  imul   $0x1dcd6500,%rax,%rax
  test   %rax,%rax
  js     L482
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L294
L482:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L294:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x3(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L149:
  cmpq   $0x5ee3fe0,-0x18(%rbp)
  jbe    L16
  mov    -0x18(%rbp),%rax
  add    $0x4c4b3f,%rax
  movabs $0xd6bf94d5e57a42bd,%rdx
  mul    %rdx
  shr    $0x16,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  imul   $0x4c4b40,%rax,%rax
  test   %rax,%rax
  js     L280
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L473
L280:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L473:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x2(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L16:
  cmpq   $0xf2eb8,-0x18(%rbp)
  jbe    L193
  mov    -0x18(%rbp),%rax
  add    $0x7a11f,%rax
  movabs $0x431bde82d7b634db,%rdx
  mul    %rdx
  shr    $0x11,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  imul   $0x7a120,%rax,%rax
  test   %rax,%rax
  js     L350
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L293
L350:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L293:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x2(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L193:
  cmpq   $0x184ac,-0x18(%rbp)
  jbe    L171
  mov    -0x18(%rbp),%rax
  add    $0x1387,%rax
  movabs $0x346dc5d63886594b,%rdx
  mul    %rdx
  shr    $0xa,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  imul   $0x1388,%rax,%rax
  test   %rax,%rax
  js     L387
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L475
L387:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L475:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L171:
  cmpq   $0x3e3,-0x18(%rbp)
  jbe    L396
  mov    -0x18(%rbp),%rax
  add    $0x1f3,%rax
  shr    $0x2,%rax
  movabs $0x20c49ba5e353f7cf,%rdx
  mul    %rdx
  shr    $0x4,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  imul   $0x1f4,%rax,%rax
  test   %rax,%rax
  js     L400
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L188
L400:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L188:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L178
L396:
  cmpq   $0x63,-0x18(%rbp)
  jbe    L426
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  movabs $0xcccccccccccccccd,%rdx
  mul    %rdx
  shr    $0x2,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  test   %rax,%rax
  js     L316
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L416
L316:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L416:
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L178
L426:
  cmpq   $0x0,-0x18(%rbp)
  jne    L29
  movq   $0x1,-0x18(%rbp)
L29:
  mov    -0x18(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  test   %rax,%rax
  js     L60
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L26
L60:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L26:
  movsd  D5(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x1,(%rax)
L178:
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbp
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D5
type_guessed: f64

tool: D5: 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;
}
```