user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x4000(%rsp),%r11
L66:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L66
  sub    $0xb28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x4b18(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x8(%rsp)
  movl   $0x0,0xc(%rsp)
  mov    $0x1c200,%esi
  lea    D66(%rip),%rdi
  call   <serialOpen@plt>
  mov    %eax,%ebx
  lea    D46(%rip),%rsi
  lea    D60(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  mov    $0x31,%esi
  mov    %ebx,%edi
  call   <sendShot@plt>
  lea    0xc(%rsp),%rdx
  lea    0x8(%rsp),%rsi
  mov    %ebx,%edi
  call   <readImageDetails@plt>
  mov    0xc(%rsp),%edx
  mov    0x8(%rsp),%esi
  lea    D77(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%eax
  lea    0x1(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    0xc(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %rax,%rsi
  mov    %ebx,%edi
  call   <readImage@plt>
  mov    %ebx,%edi
  call   <serialClose@plt>
  mov    $0x0,%eax
  call   <njInit@plt>
  mov    0x8(%rsp),%esi
  mov    %rbp,%rdi
  call   <njDecode@plt>
  test   %rax,%rax
  jne    L174
  mov    $0x0,%eax
  call   <njGetHeight@plt>
  mov    %eax,%ebx
  mov    $0x0,%eax
  call   <njGetWidth@plt>
  mov    %eax,%esi
  mov    %ebx,%edx
  lea    D68(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  call   <njGetHeight@plt>
  mov    %eax,%ebp
  mov    $0x0,%eax
  call   <njGetWidth@plt>
  mov    %eax,%ebx
  mov    $0x0,%eax
  call   <njIsColor@plt>
  cmp    $0x1,%rax
  sbb    %edx,%edx
  add    $0x6,%edx
  mov    %ebp,%r8d
  mov    %ebx,%ecx
  lea    D16(%rip),%rsi
  mov    %r12,%rdi
  call   <fprintf@plt>
  mov    $0x0,%eax
  call   <njGetWidth@plt>
  mov    %eax,%ebp
  mov    $0x0,%eax
  call   <njGetHeight@plt>
  mov    %eax,%ebx
  mov    $0x0,%eax
  call   <njGetImageSize@plt>
  mov    %eax,%r13d
  mov    $0x0,%eax
  call   <njGetImage@plt>
  mov    %rax,%rdi
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    $0x0,%eax
  call   <njGetImage@plt>
  mov    %rax,%rcx
  test   %ebp,%ebp
  je     L151
  lea    -0x1(%rbx),%r10d
  lea    0x11(%rsp,%r10,1),%rdi
  imul   $0x3,%ebp,%r8d
  mov    $0x0,%r9d
  movsd  D38(%rip),%xmm4
  movsd  D5(%rip),%xmm3
  movsd  D51(%rip),%xmm2
  jmp    L65
L174:
  lea    D47(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L72
L77:
  lea    (%r9,%r9,2),%eax
  mov    %rdi,%rdx
  sub    %r10,%rdx
  sub    $0x1,%rdx
L127:
  lea    0x1(%rax),%esi
  movzbl (%rcx,%rsi,1),%esi
  pxor   %xmm0,%xmm0
  cvtsi2sd %esi,%xmm0
  mulsd  %xmm4,%xmm0
  mov    %eax,%esi
  movzbl (%rcx,%rsi,1),%esi
  pxor   %xmm1,%xmm1
  cvtsi2sd %esi,%xmm1
  mulsd  %xmm3,%xmm1
  addsd  %xmm1,%xmm0
  lea    0x2(%rax),%esi
  movzbl (%rcx,%rsi,1),%esi
  pxor   %xmm1,%xmm1
  cvtsi2sd %esi,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%esi
  mov    %sil,(%rdx)
  add    %r8d,%eax
  add    $0x1,%rdx
  cmp    %rdi,%rdx
  jne    L127
L88:
  add    $0x1,%r9d
  add    $0x78,%rdi
  cmp    %r9d,%ebp
  je     L151
L65:
  test   %ebx,%ebx
  jne    L77
  jmp    L88
L151:
  test   %ebx,%ebx
  je     L204
  lea    0x10(%rsp),%r14
  lea    -0x1(%rbp),%eax
  imul   $0x78,%rax,%rax
  lea    0x88(%rsp,%rax,1),%r13
  lea    -0x1(%rbx),%eax
  lea    0x11(%rsp,%rax,1),%r15
  jmp    L3
L189:
  mov    $0x40,%edi
  call   <putchar@plt>
L154:
  add    $0x78,%rbx
  cmp    %r13,%rbx
  je     L1
L20:
  movzbl (%rbx),%eax
  cmp    $0x3e,%al
  jbe    L189
  test   %al,%al
  jns    L201
  cmp    $0xbe,%al
  ja     L178
  mov    $0x2b,%edi
  call   <putchar@plt>
  jmp    L154
L201:
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L154
L178:
  mov    $0x2d,%edi
  call   <putchar@plt>
  jmp    L154
L1:
  mov    $0xa,%edi
  call   <putchar@plt>
  add    $0x1,%r13
  add    $0x1,%r14
  cmp    %r15,%r14
  je     L204
L3:
  mov    %r14,%rbx
  test   %ebp,%ebp
  jne    L20
  jmp    L1
L204:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  call   <njDone@plt>
  mov    $0x0,%eax
L72:
  mov    0x4b18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L135
  add    $0x4b28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L135:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D66
type: string
name: parse_data
arguments: tag: D46
type: string
name: parse_data
arguments: tag: D60
type: string
name: parse_data
arguments: tag: D77
type: string
name: parse_data
arguments: tag: D68
type: string
name: parse_data
arguments: tag: D16
type: string
name: parse_data
arguments: tag: D38
type: f64
name: parse_data
arguments: tag: D5
type: f64
name: parse_data
arguments: tag: D51
type: f64
name: parse_data
arguments: tag: D47
type: string

tool: D66: /dev/ttyUSB1

tool: D46: w

tool: D60: ./image.ppm

tool: D77: size: %d
packets count: %d


tool: D68: size:
%d %d


tool: D16: P%d
%d %d
255


tool: D38: 0.72

tool: D5: 0.21

tool: D51: 0.07

tool: D47: Error decoding the input file.

assistant: ```c
int main() {
  unsigned char buffer[1024] = {0};
  unsigned int picSize = 0;
  unsigned int packNum = 0;
  unsigned int packSize;
  unsigned short int checksum;
  unsigned int width, height;
  unsigned int i, j;
  unsigned char bytes[2];
  unsigned char image[160][120];
  int fd = serialOpen("/dev/ttyUSB1", 115200);
  FILE *filefd = fopen("./image.ppm", "w");
  unsigned char *bufptr;
  sendShot(fd, 0x31);
  readImageDetails(fd, &picSize, &packNum);
  printf("size: %d\npackets count: %d\n", picSize, packNum);
  unsigned char *imgBuffer = (unsigned char *)malloc((picSize + 1) * sizeof(unsigned char));
  readImage(fd, imgBuffer, picSize, packNum);
  serialClose(fd);
  njInit();
  if (njDecode(imgBuffer, picSize)) {
    printf("Error decoding the input file.\n");
    return 1;
  }
  printf("size:\n%d %d\n", njGetWidth(), njGetHeight());
  fprintf(filefd, "P%d\n%d %d\n255\n", njIsColor() ? 6 : 5, njGetWidth(), njGetHeight());
  width = njGetWidth();
  height = njGetHeight();
  fwrite(njGetImage(), 1, njGetImageSize(), filefd);
  bufptr = njGetImage();
  for (i = 0; i < width; i++) {
    for (j = 0; j < height; j++) {
      image[i][j] = (char)((0.21 * (double)bufptr[(i + j * width) * 3]) + 0.72 * (double)bufptr[(i + j * width) * 3 + 1] + 0.07 * (double)bufptr[(i + j * width) * 3 + 2]);
    }
  }
  for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++) {
      if (image[i][j] < 63)
        printf("@");
      else if (image[i][j] < 128)
        printf("*");
      else if (image[i][j] < 191)
        printf("+");
      else
        printf("-");
    }
    printf("\n");
  }
  fclose(filefd);
  njDone();
}
```