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

```asm
<set_rgb16_lum_from_rgb16>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%eax
  mov    %esi,%edx
  mov    %edi,%ecx
  sar    $0x10,%ecx
  movzbl %cl,%ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  movsd  D27(%rip),%xmm1
  mulsd  %xmm1,%xmm0
  movzbl %ah,%ecx
  pxor   %xmm2,%xmm2
  cvtsi2sd %ecx,%xmm2
  movsd  D4(%rip),%xmm3
  mulsd  %xmm3,%xmm2
  addsd  %xmm2,%xmm0
  movzbl %dil,%eax
  pxor   %xmm4,%xmm4
  cvtsi2sd %eax,%xmm4
  movsd  D2(%rip),%xmm2
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  cvttsd2si %xmm0,%r8d
  mov    %esi,%ebx
  sar    $0x10,%ebx
  movzbl %bl,%ebx
  movzbl %dh,%eax
  movzbl %sil,%ebp
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  mulsd  %xmm1,%xmm0
  pxor   %xmm4,%xmm4
  cvtsi2sd %eax,%xmm4
  mulsd  %xmm3,%xmm4
  addsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  cvtsi2sd %ebp,%xmm4
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  cvttsd2si %xmm0,%r9d
  mov    %r8d,%edx
  sub    %r9d,%edx
  add    %edx,%ebx
  lea    (%rax,%rdx,1),%r12d
  add    %edx,%ebp
  mov    %ebx,%eax
  shl    $0x10,%eax
  mov    %r12d,%ecx
  shl    $0x8,%ecx
  add    %ecx,%eax
  add    %ebp,%eax
  mov    %eax,%ecx
  sar    $0x10,%ecx
  movzbl %cl,%ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  mulsd  %xmm1,%xmm0
  movzbl %ah,%ecx
  pxor   %xmm1,%xmm1
  cvtsi2sd %ecx,%xmm1
  mulsd  %xmm3,%xmm1
  addsd  %xmm1,%xmm0
  movzbl %al,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%r14d
  cmp    %r12d,%ebx
  mov    %r12d,%r15d
  cmovle %ebx,%r15d
  cmp    %ebp,%r15d
  cmovg  %ebp,%r15d
  cmp    %r12d,%ebx
  mov    %r12d,%r13d
  cmovge %ebx,%r13d
  cmp    %ebp,%r13d
  cmovl  %ebp,%r13d
  push   %r15
  push   %r13
  push   %r14
  push   %rdx
  mov    %ebp,%ecx
  mov    %r12d,%edx
  mov    %ebx,%esi
  lea    D16(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x20,%rsp
  test   %r15d,%r15d
  js     L15
L5:
  cmp    $0xff,%r13d
  jg     L10
L38:
  shl    $0x10,%ebx
  shl    $0x8,%r12d
  lea    (%rbx,%r12,1),%eax
  add    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L15:
  mov    %r14d,%ecx
  sub    %r15d,%ecx
  mov    %ebx,%eax
  sub    %r14d,%eax
  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
  lea    D1(%rip),%rdi
  call   <puts@plt>
  jmp    L5
L10:
  mov    $0xff,%ecx
  sub    %r14d,%ecx
  sub    %r14d,%r13d
  mov    %ebx,%eax
  sub    %r14d,%eax
  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
  lea    D25(%rip),%rdi
  call   <puts@plt>
  jmp    L38
```

tool_calls: name: parse_data
arguments: tag: D27
type: f64
name: parse_data
arguments: tag: D4
type: f64
name: parse_data
arguments: tag: D2
type: f64
name: parse_data
arguments: tag: D16
type: string
name: parse_data
arguments: tag: D1
type: string
name: parse_data
arguments: tag: D25
type: string

tool: D27: 0.3

tool: D4: 0.59

tool: D2: 0.11

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


tool: D1: -

tool: D25: +

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);
}
```