user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rotateByBilinear>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,0x48(%rsp)
  mov    %rsi,0x28(%rsp)
  mov    %rdx,0x50(%rsp)
  mov    %rcx,%r15
  mov    %r8,0x18(%rsp)
  mov    %r9,0x8(%rsp)
  mov    0xd0(%rsp),%r12
  mov    0xd8(%rsp),%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  movsd  (%r8),%xmm0
  movsd  D3(%rip),%xmm1
  comisd %xmm1,%xmm0
  jb     L2
L112:
  subsd  %xmm1,%xmm0
  comisd %xmm1,%xmm0
  jae    L112
  mov    0x18(%rsp),%rax
  movsd  %xmm0,(%rax)
L2:
  mov    0x28(%rsp),%rax
  mov    (%rax),%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  mov    %eax,0x34(%rsp)
  mov    0x50(%rsp),%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,%ebx
  mov    %eax,0x58(%rsp)
  mov    (%r12),%eax
  sub    %ecx,%eax
  mov    %eax,%ecx
  shr    $0x1f,%ecx
  add    %ecx,%eax
  sar    %eax
  mov    %eax,%edi
  mov    %eax,0x5c(%rsp)
  mov    0x0(%r13),%eax
  mov    %eax,%ecx
  sub    %edx,%ecx
  mov    %ecx,%edx
  shr    $0x1f,%edx
  add    %ecx,%edx
  mov    %edx,%esi
  sar    %esi
  mov    %esi,0x6c(%rsp)
  mov    %esi,%edx
  neg    %edx
  sub    %esi,%eax
  cmp    %eax,%edx
  jge    L156
  sub    %ebx,%edx
  mov    %edx,0x30(%rsp)
  movl   $0x0,0x10(%rsp)
  neg    %edi
  mov    %edi,0x68(%rsp)
  lea    0x70(%rsp),%rax
  mov    %rax,0x60(%rsp)
  mov    %r13,%r14
  jmp    L15
L30:
  mov    (%r14),%edx
  mov    %edx,%eax
  imul   (%r12),%eax
  imul   %ebx,%eax
  imul   %ebp,%edx
  add    0x10(%rsp),%edx
  add    %edx,%eax
  cltq
  mov    0x8(%rsp),%rcx
  movl   $0x0,(%rcx,%rax,4)
L65:
  add    $0x1,%ebx
  cmp    %ebx,(%r15)
  jle    L10
L199:
  test   %r13d,%r13d
  js     L30
  mov    0x28(%rsp),%rax
  mov    (%rax),%eax
  cmp    %eax,0x20(%rsp)
  jge    L30
  mov    0x50(%rsp),%rdi
  mov    (%rdi),%edx
  cmp    %edx,0x24(%rsp)
  jge    L30
  mov    0x20(%rsp),%r10d
  mov    %r10d,%ecx
  imul   %edx,%ecx
  mov    %eax,%edi
  imul   %edx,%edi
  imul   %ebx,%edi
  mov    0x24(%rsp),%r11d
  lea    (%r11,%rcx,1),%esi
  add    %edi,%esi
  movslq %esi,%rsi
  mov    0x48(%rsp),%r9
  mov    (%r9,%rsi,4),%esi
  mov    %esi,0x70(%rsp)
  sub    $0x1,%eax
  cmp    %eax,%r10d
  je     L51
  lea    (%rdx,%rcx,1),%eax
  add    %r11d,%eax
  add    %edi,%eax
  cltq
  mov    (%r9,%rax,4),%eax
  mov    %eax,0x74(%rsp)
  lea    -0x1(%rdx),%eax
  cmp    %eax,%r11d
  je     L111
  mov    0x24(%rsp),%eax
  lea    0x1(%rax),%r8d
  lea    (%rcx,%r8,1),%eax
  add    %edi,%eax
  cltq
  mov    0x48(%rsp),%rsi
  mov    (%rsi,%rax,4),%eax
  mov    %eax,0x78(%rsp)
L129:
  lea    (%rdx,%rcx,1),%eax
  add    %r8d,%eax
  add    %edi,%eax
  cltq
  mov    0x48(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
L145:
  mov    %esi,0x7c(%rsp)
  movsd  0x40(%rsp),%xmm1
  movsd  0x38(%rsp),%xmm0
  mov    0x60(%rsp),%rdi
  call   <bilinear@plt>
  mov    %rax,%rcx
  mov    (%r14),%edx
  mov    %edx,%eax
  imul   (%r12),%eax
  imul   %ebx,%eax
  imul   %ebp,%edx
  add    0x10(%rsp),%edx
  add    %edx,%eax
  cltq
  mov    0x8(%rsp),%rdi
  mov    %ecx,(%rdi,%rax,4)
  jmp    L65
L51:
  mov    %esi,0x74(%rsp)
  lea    -0x1(%rdx),%r8d
  mov    0x24(%rsp),%r10d
  cmp    %r8d,%r10d
  je     L111
  lea    0x1(%r10),%r8d
  lea    (%rcx,%r8,1),%r9d
  add    %edi,%r9d
  movslq %r9d,%r9
  mov    0x48(%rsp),%r10
  mov    (%r10,%r9,4),%r9d
  mov    %r9d,0x78(%rsp)
  cmp    %eax,0x20(%rsp)
  je     L145
  jmp    L129
L10:
  addl   $0x1,0x14(%rsp)
  mov    0x14(%rsp),%esi
  add    $0x1,%ebp
  mov    (%r12),%eax
  sub    0x5c(%rsp),%eax
  mov    0x34(%rsp),%edx
  add    %esi,%edx
  cmp    %edx,%eax
  jle    L132
L172:
  mov    0x18(%rsp),%r13
  movsd  0x0(%r13),%xmm0
  call   <cos@plt>
  imul   0x14(%rsp),%eax
  mov    %eax,%ebx
  mov    %r13,0x18(%rsp)
  movsd  0x0(%r13),%xmm0
  call   <sin@plt>
  imul   0x30(%rsp),%eax
  add    %ebx,%eax
  add    0x34(%rsp),%eax
  mov    %eax,%r13d
  mov    %eax,0x20(%rsp)
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  movsd  %xmm2,0x38(%rsp)
  mov    0x18(%rsp),%rax
  movsd  (%rax),%xmm0
  call   <cos@plt>
  mov    %eax,%ebx
  imul   0x30(%rsp),%ebx
  mov    0x18(%rsp),%rax
  movsd  (%rax),%xmm0
  call   <sin@plt>
  imul   0x14(%rsp),%eax
  sub    %eax,%ebx
  add    0x58(%rsp),%ebx
  mov    %ebx,%eax
  mov    %ebx,0x24(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  movsd  0x38(%rsp),%xmm2
  subsd  %xmm2,%xmm2
  movsd  %xmm2,0x38(%rsp)
  subsd  %xmm0,%xmm0
  movsd  %xmm0,0x40(%rsp)
  cmpl   $0x0,(%r15)
  jle    L10
  mov    $0x0,%ebx
  or     %eax,%r13d
  jmp    L199
L132:
  addl   $0x1,0x30(%rsp)
  mov    0x30(%rsp),%edi
  addl   $0x1,0x10(%rsp)
  mov    (%r14),%eax
  sub    0x6c(%rsp),%eax
  mov    0x58(%rsp),%edx
  add    %edi,%edx
  cmp    %edx,%eax
  jle    L156
L15:
  mov    (%r12),%eax
  sub    0x5c(%rsp),%eax
  mov    0x68(%rsp),%ecx
  cmp    %eax,%ecx
  jge    L132
  sub    0x34(%rsp),%ecx
  mov    %ecx,0x14(%rsp)
  mov    $0x0,%ebp
  jmp    L172
L111:
  mov    %esi,0x78(%rsp)
  jmp    L145
L156:
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D3
type_infered: byte[8]

tool: {"D3": [0x00,0x00,0x00,0x00,0x00,0x80,0x76,0x40]}

assistant: ```c
void rotateByBilinear(int *image, int *width, int *height, int *depth, double *angle, int *ret, int *new_width, int *new_height) {
  int x_center, y_center, x_diff, y_diff;
  int x, y, d;
  double x_src_d, y_src_d;
  int x_src, y_src;
  double x_weight, y_weight;
  while (*angle >= 360) {
    *angle = *angle - 360;
  }
  x_center = *width / 2;
  y_center = *height / 2;
  x_diff = (*new_width - *width) / 2;
  y_diff = (*new_height - *height) / 2;
  for (y = -1 * y_diff; y < (*new_height - y_diff); y++) {
    for (x = -1 * x_diff; x < (*new_width - x_diff); x++) {
      x_src_d = (x - x_center) * cos(*angle) + (y - y_center) * sin(*angle) + x_center;
      y_src_d = (y - y_center) * cos(*angle) - (x - x_center) * sin(*angle) + y_center;
      x_src = (int)x_src_d;
      y_src = (int)y_src_d;
      x_weight = x_src_d - x_src;
      y_weight = y_src_d - y_src;
      for (d = 0; d < *depth; d++) {
        if (x_src_d < 0 || y_src_d < 0 || x_src_d >= *width || y_src_d >= *height) {
          ret[((*new_height) * (x + x_diff) + (y + y_diff) + (*new_width) * (*new_height) * (d))] = 0;
        } else {
          int a[4];
          a[0] = image[((*height) * (x_src) + (y_src) + (*width) * (*height) * (d))];
          a[1] = (x_src == *width - 1) ? a[0] : image[((*height) * (x_src + 1) + (y_src) + (*width) * (*height) * (d))];
          a[2] = (y_src == *height - 1) ? a[0] : image[((*height) * (x_src) + (y_src + 1) + (*width) * (*height) * (d))];
          a[3] = ((x_src == *width - 1) || (y_src == *height - 1)) ? a[0] : image[((*height) * (x_src + 1) + (y_src + 1) + (*width) * (*height) * (d))];
          ret[((*new_height) * (x + x_diff) + (y + y_diff) + (*new_width) * (*new_height) * (d))] = (int)bilinear(a, x_weight, y_weight);
        }
      }
    }
  }
}
```