user: What is the c source code of the assembly code below:

```asm
<set_rgb16_lum_from_rgb16>:
  endbr64
  mov    %edi,%ecx
  mov    %edi,%eax
  pxor   %xmm0,%xmm0
  push   %r15
  sar    $0x10,%ecx
  push   %r14
  pxor   %xmm2,%xmm2
  pxor   %xmm4,%xmm4
  movzbl %cl,%ecx
  push   %r13
  mov    %esi,%edx
  push   %r12
  cvtsi2sd %ecx,%xmm0
  movzbl %ah,%ecx
  movzbl %dil,%eax
  push   %rbp
  cvtsi2sd %ecx,%xmm2
  movzbl %sil,%ebp
  lea    D23(%rip),%rdi
  push   %rbx
  cvtsi2sd %eax,%xmm4
  mov    %esi,%ebx
  movzbl %dh,%eax
  sar    $0x10,%ebx
  mov    %eax,%r12d
  movzbl %bl,%ebx
  sub    $0x8,%rsp
  movsd  D9(%rip),%xmm1
  movsd  D58(%rip),%xmm3
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm2
  addsd  %xmm2,%xmm0
  movsd  D21(%rip),%xmm2
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  cvtsi2sd %eax,%xmm4
  cvttsd2si %xmm0,%r8d
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  mulsd  %xmm3,%xmm4
  mov    %r8d,%edx
  mulsd  %xmm1,%xmm0
  addsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  cvtsi2sd %ebp,%xmm4
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  cvttsd2si %xmm0,%r9d
  pxor   %xmm0,%xmm0
  sub    %r9d,%edx
  add    %edx,%ebx
  add    %edx,%r12d
  add    %edx,%ebp
  mov    %ebx,%eax
  mov    %r12d,%ecx
  mov    %r12d,%r15d
  mov    %r12d,%r13d
  shl    $0x8,%ecx
  shl    $0x10,%eax
  mov    %ebx,%esi
  add    %ecx,%eax
  add    %ebp,%eax
  mov    %eax,%ecx
  sar    $0x10,%ecx
  cmp    %r12d,%ebx
  movzbl %cl,%ecx
  cmovle %ebx,%r15d
  cvtsi2sd %ecx,%xmm0
  movzbl %ah,%ecx
  movzbl %al,%eax
  cmp    %ebp,%r15d
  cmovg  %ebp,%r15d
  cmp    %r12d,%ebx
  cmovge %ebx,%r13d
  push   %r15
  mulsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cmp    %ebp,%r13d
  cvtsi2sd %ecx,%xmm1
  cmovl  %ebp,%r13d
  mov    %ebp,%ecx
  push   %r13
  mulsd  %xmm3,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  xor    %eax,%eax
  mulsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%r14d
  push   %r14
  push   %rdx
  mov    %r12d,%edx
  call   <printf@plt>
  add    $0x20,%rsp
  test   %r15d,%r15d
  js     L7
L17:
  cmp    $0xff,%r13d
  jg     L15
L25:
  shl    $0x10,%ebx
  shl    $0x8,%r12d
  add    $0x8,%rsp
  lea    (%rbx,%r12,1),%eax
  pop    %rbx
  add    %ebp,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L15:
  mov    %ebx,%eax
  mov    $0xff,%ecx
  sub    %r14d,%r13d
  sub    %r14d,%ecx
  sub    %r14d,%eax
  lea    D52(%rip),%rdi
  imul   %ecx,%eax
  cltd
  idiv   %r13d
  lea    (%rax,%r14,1),%ebx
  mov    %r12d,%eax
  sub    %r14d,%eax
  imul   %ecx,%eax
  cltd
  idiv   %r13d
  lea    (%rax,%r14,1),%r12d
  mov    %ebp,%eax
  sub    %r14d,%eax
  imul   %ecx,%eax
  cltd
  idiv   %r13d
  lea    (%rax,%r14,1),%ebp
  call   <puts@plt>
  jmp    L25
  nopw   0x0(%rax,%rax,1)
L7:
  mov    %ebx,%eax
  mov    %r14d,%ecx
  lea    D22(%rip),%rdi
  sub    %r14d,%eax
  sub    %r15d,%ecx
  imul   %r14d,%eax
  cltd
  idiv   %ecx
  lea    (%rax,%r14,1),%ebx
  mov    %r12d,%eax
  sub    %r14d,%eax
  imul   %r14d,%eax
  cltd
  idiv   %ecx
  lea    (%rax,%r14,1),%r12d
  mov    %ebp,%eax
  sub    %r14d,%eax
  imul   %r14d,%eax
  cltd
  idiv   %ecx
  lea    (%rax,%r14,1),%ebp
  call   <puts@plt>
  jmp    L17
```

tool_calls: name: read_data
arguments: tag: D23
data_type: string
name: read_data
arguments: tag: D9
data_type: f64
name: read_data
arguments: tag: D58
data_type: f64
name: read_data
arguments: tag: D21
data_type: f64
name: read_data
arguments: tag: D52
data_type: string
name: read_data
arguments: tag: D22
data_type: string

tool: D23: r=%3i, g=%3i, b=%3i, blum=%3i, tlum=%3i, diff=%3i, lum=%3i, max=%3i, min=%3i


tool: D9: 0.3

tool: D58: 0.59

tool: D21: 0.11

tool: D52: +

tool: D22: -

assistant: ```c
int set_rgb16_lum_from_rgb16(int base, int top) {
  const int botlum = (((base >> 16) & 0xff) * 0.3 + ((base >> 8) & 0xff) * 0.59 + (base & 0xff) * 0.11);
  const int toplum = (((top >> 16) & 0xff) * 0.3 + ((top >> 8) & 0xff) * 0.59 + (top & 0xff) * 0.11);
  const int diff = botlum - toplum;
  const int topr = ((top >> 16) & 0xff), topg = ((top >> 8) & 0xff), topb = (top & 0xff);
  int r = topr + diff;
  int g = topg + diff;
  int b = topb + diff;
  int lum = (((((r << 16) + (g << 8) + b) >> 16) & 0xff) * 0.3 + ((((r << 16) + (g << 8) + b) >> 8) & 0xff) * 0.59 + (((r << 16) + (g << 8) + b) & 0xff) * 0.11);
  int cmin = (((r) < ((((g) < (b)) ? (g) : (b)))) ? (r) : ((((g) < (b)) ? (g) : (b))));
  int cmax = (((r) > ((((g) > (b)) ? (g) : (b)))) ? (r) : ((((g) > (b)) ? (g) : (b))));
  printf("r=%3i, g=%3i, b=%3i, blum=%3i, tlum=%3i, diff=%3i, lum=%3i, max=%3i, min=%3i\n", r, g, b, botlum, toplum, diff, lum, cmax, cmin);
  if (cmin < 0) {
    r = lum + (((r - lum) * lum) / (lum - cmin));
    g = lum + (((g - lum) * lum) / (lum - cmin));
    b = lum + (((b - lum) * lum) / (lum - cmin));
    printf("-\n");
  }
  if (cmax > 255) {
    r = lum + (((r - lum) * (255 - lum)) / (cmax - lum));
    g = lum + (((g - lum) * (255 - lum)) / (cmax - lum));
    b = lum + (((b - lum) * (255 - lum)) / (cmax - lum));
    printf("+\n");
  }
  return ((r << 16) + (g << 8) + b);
}
```