user: Converte this assembly snippet into its equivalent C code:

```asm
<double_to_image>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x88,%rsp
  mov    %esi,(%rsp)
  imul   %ebx,%esi
  lea    0x70(%rsp),%rcx
  mov    %r8d,0x4(%rsp)
  lea    0x68(%rsp),%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  call   <min_max@plt>
  movsd  0x68(%rsp),%xmm1
  movsd  0x70(%rsp),%xmm0
  ucomisd %xmm0,%xmm1
  jp     L41
  je     L156
L41:
  movsd  D31(%rip),%xmm8
  subsd  %xmm1,%xmm0
  mov    (%rsp),%eax
  divsd  %xmm0,%xmm8
  test   %eax,%eax
  jle    L156
  test   %ebx,%ebx
  jle    L156
  movslq 0x4(%rsp),%rax
  mov    %ebx,%r10d
  lea    -0x1(%rbx),%edx
  movapd %xmm8,%xmm5
  and    $0xfffffff0,%r10d
  mov    %edx,0x28(%rsp)
  mov    %r12,%rdi
  mov    %rbp,%r8
  lea    0x3(%r10),%ecx
  mov    %rax,0x8(%rsp)
  movslq %ebx,%rax
  lea    0xa(%r10),%esi
  mov    %rax,0x18(%rsp)
  shl    $0x3,%rax
  lea    0x1(%r10),%r14d
  xor    %r11d,%r11d
  mov    %ecx,0x2c(%rsp)
  lea    0x4(%r10),%ecx
  lea    0x2(%r10),%r15d
  unpcklpd %xmm5,%xmm5
  mov    %ecx,0x30(%rsp)
  lea    0x5(%r10),%ecx
  movapd D13(%rip),%xmm4
  pxor   %xmm6,%xmm6
  mov    %rax,0x10(%rsp)
  mov    %ebx,%eax
  movdqa D20(%rip),%xmm3
  mov    %ecx,0x34(%rsp)
  shr    $0x4,%eax
  lea    0x6(%r10),%ecx
  movdqa D11(%rip),%xmm7
  movsd  D13(%rip),%xmm9
  mov    %ecx,0x38(%rsp)
  sub    $0x1,%eax
  lea    0x7(%r10),%ecx
  mov    %ecx,0x3c(%rsp)
  add    $0x1,%rax
  lea    0x8(%r10),%ecx
  mov    %ecx,0x40(%rsp)
  shl    $0x7,%rax
  lea    0x9(%r10),%ecx
  mov    %ecx,0x44(%rsp)
  lea    0xb(%r10),%ecx
  mov    %esi,0x4c(%rsp)
  lea    0xc(%r10),%esi
  mov    %rax,0x20(%rsp)
  mov    %ecx,0x50(%rsp)
  lea    0xd(%r10),%ecx
  mov    %esi,0x54(%rsp)
  lea    0xe(%r10),%esi
  mov    %ecx,0x58(%rsp)
  xor    %ecx,%ecx
  mov    %esi,0x5c(%rsp)
  xor    %esi,%esi
  nopl   (%rax)
L116:
  mov    0x18(%rsp),%rax
  add    %rdi,%rax
  cmp    %rax,%r8
  mov    0x10(%rsp),%rax
  setae  %dl
  lea    (%r8,%rax,1),%r13
  cmp    %r13,%rdi
  setae  %al
  or     %dl,%al
  je     L234
  mov    0x20(%rsp),%rax
  cmpl   $0xe,0x28(%rsp)
  mov    %rdi,%rdx
  lea    (%rax,%r8,1),%r9
  mov    %r8,%rax
  jbe    L234
  nopw   0x0(%rax,%rax,1)
L122:
  movupd (%rax),%xmm1
  movdqa %xmm3,%xmm2
  sub    $0xffffffffffffff80,%rax
  add    $0x10,%rdx
  movupd -0x70(%rax),%xmm0
  movdqa %xmm3,%xmm10
  movdqa %xmm3,%xmm11
  mulpd  %xmm5,%xmm1
  mulpd  %xmm5,%xmm0
  addpd  %xmm4,%xmm1
  addpd  %xmm4,%xmm0
  cvttpd2dq %xmm1,%xmm1
  cvttpd2dq %xmm0,%xmm0
  punpcklqdq %xmm0,%xmm1
  movdqa %xmm1,%xmm0
  pcmpgtd %xmm3,%xmm0
  pand   %xmm0,%xmm2
  pandn  %xmm1,%xmm0
  por    %xmm2,%xmm0
  movupd -0x60(%rax),%xmm2
  movdqa %xmm0,%xmm1
  mulpd  %xmm5,%xmm2
  pcmpgtd %xmm6,%xmm1
  pand   %xmm1,%xmm0
  movupd -0x50(%rax),%xmm1
  mulpd  %xmm5,%xmm1
  addpd  %xmm4,%xmm2
  cvttpd2dq %xmm2,%xmm2
  addpd  %xmm4,%xmm1
  cvttpd2dq %xmm1,%xmm1
  punpcklqdq %xmm1,%xmm2
  movdqa %xmm2,%xmm1
  pcmpgtd %xmm3,%xmm1
  pand   %xmm1,%xmm10
  pandn  %xmm2,%xmm1
  por    %xmm10,%xmm1
  movdqa %xmm3,%xmm10
  movdqa %xmm1,%xmm2
  pcmpgtd %xmm6,%xmm2
  pand   %xmm2,%xmm1
  movdqa %xmm0,%xmm2
  punpcklwd %xmm1,%xmm0
  punpckhwd %xmm1,%xmm2
  movdqa %xmm0,%xmm1
  punpcklwd %xmm2,%xmm0
  punpckhwd %xmm2,%xmm1
  movupd -0x40(%rax),%xmm2
  punpcklwd %xmm1,%xmm0
  movupd -0x30(%rax),%xmm1
  mulpd  %xmm5,%xmm2
  pand   %xmm7,%xmm0
  mulpd  %xmm5,%xmm1
  addpd  %xmm4,%xmm2
  addpd  %xmm4,%xmm1
  cvttpd2dq %xmm2,%xmm2
  cvttpd2dq %xmm1,%xmm1
  punpcklqdq %xmm1,%xmm2
  movdqa %xmm2,%xmm1
  pcmpgtd %xmm3,%xmm1
  pand   %xmm1,%xmm10
  pandn  %xmm2,%xmm1
  por    %xmm10,%xmm1
  movupd -0x20(%rax),%xmm10
  movdqa %xmm1,%xmm2
  mulpd  %xmm5,%xmm10
  pcmpgtd %xmm6,%xmm2
  pand   %xmm2,%xmm1
  movupd -0x10(%rax),%xmm2
  mulpd  %xmm5,%xmm2
  addpd  %xmm4,%xmm10
  cvttpd2dq %xmm10,%xmm10
  addpd  %xmm4,%xmm2
  cvttpd2dq %xmm2,%xmm2
  punpcklqdq %xmm2,%xmm10
  movdqa %xmm10,%xmm2
  pcmpgtd %xmm3,%xmm2
  pand   %xmm2,%xmm11
  pandn  %xmm10,%xmm2
  por    %xmm11,%xmm2
  movdqa %xmm2,%xmm10
  pcmpgtd %xmm6,%xmm10
  pand   %xmm10,%xmm2
  movdqa %xmm1,%xmm10
  punpcklwd %xmm2,%xmm1
  punpckhwd %xmm2,%xmm10
  movdqa %xmm1,%xmm2
  punpcklwd %xmm10,%xmm1
  punpckhwd %xmm10,%xmm2
  punpcklwd %xmm2,%xmm1
  pand   %xmm7,%xmm1
  packuswb %xmm1,%xmm0
  movups %xmm0,-0x10(%rdx)
  cmp    %r9,%rax
  jne    L122
  cmp    %ebx,%r10d
  je     L57
  lea    (%rcx,%r10,1),%eax
  mov    $0xff,%r8d
  lea    (%rsi,%r10,1),%edx
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  cmp    %r14d,%ebx
  jle    L57
  lea    (%rcx,%r14,1),%eax
  mov    $0xff,%r8d
  lea    (%rsi,%r14,1),%edx
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  cmp    %r15d,%ebx
  jle    L57
  lea    (%rcx,%r15,1),%eax
  mov    $0xff,%r8d
  lea    (%rsi,%r15,1),%edx
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x2c(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x30(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x34(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x38(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x3c(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x40(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x44(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x4c(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x50(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x54(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x58(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  mov    0x5c(%rsp),%eax
  cmp    %eax,%ebx
  jle    L57
  lea    (%rsi,%rax,1),%edx
  add    %ecx,%eax
  mov    $0xff,%r8d
  cltq
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r8d,%eax
  cmovg  %r8d,%eax
  xor    %r8d,%r8d
  test   %eax,%eax
  cmovs  %r8d,%eax
  mov    %al,(%r12,%rdx,1)
  nopl   0x0(%rax,%rax,1)
L57:
  add    $0x1,%r11d
  add    0x8(%rsp),%rdi
  mov    %r13,%r8
  add    %ebx,%ecx
  add    0x4(%rsp),%esi
  cmp    %r11d,(%rsp)
  jne    L116
L156:
  mov    0x78(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L153
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L234:
  mov    %ebx,%eax
  mov    %r11d,0x48(%rsp)
  xor    %edx,%edx
  mov    %rax,%r11
  nopl   0x0(%rax)
L209:
  movsd  (%r8,%rdx,8),%xmm0
  mov    $0xff,%r9d
  mulsd  %xmm8,%xmm0
  addsd  %xmm9,%xmm0
  cvttsd2si %xmm0,%eax
  cmp    %r9d,%eax
  cmovg  %r9d,%eax
  xor    %r9d,%r9d
  test   %eax,%eax
  cmovs  %r9d,%eax
  mov    %al,(%rdi,%rdx,1)
  add    $0x1,%rdx
  cmp    %r11,%rdx
  jne    L209
  mov    0x48(%rsp),%r11d
  jmp    L57
L153:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D31
type_guessed: f64
name: extract_symbolic_data
arguments: tag: D13
type_guessed: f64[2]
name: extract_symbolic_data
arguments: tag: D20
type_guessed: byte[16]
name: extract_symbolic_data
arguments: tag: D11
type_guessed: byte[16]

tool: D31: 255

tool: {"D13": [0.5,0.5]}

tool: {"D20": [0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00]}

tool: {"D11": [0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]}

assistant: ```c
void double_to_image(const double *m, int rows, int cols, unsigned char *data, int step) {
  int i, j;
  double mi, ma, scale;
  min_max(m, rows * cols, &mi, &ma);
  if (mi == ma) {
    return;
  }
  scale = 255.0 / (ma - mi);
  for (i = 0; i < rows; ++i) {
    for (j = 0; j < cols; ++j) {
      const double s = m[i * cols + j] * scale;
      const int t = ((int)((s) + 0.5));
      data[i * step + j] = ((t) < 0 ? 0 : (t) > 255 ? 255 : (t));
    }
  }
}
```