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

```asm
<chopGribFile>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x18,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r13
  mov    %rdx,%rbx
  mov    %rcx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x1008(%rsp)
  xor    %eax,%eax
  cmp    $0x2,%r8d
  ja     L58
  mov    %r8d,%r12d
  mov    %rsp,%r15
  mov    %rdx,%rcx
  mov    %rdi,%rdx
  lea    D11(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r15,%rdi
  call   <callSystem@plt>
  test   %r12d,%r12d
  je     L41
  cmp    $0x1,%r12d
  je     L44
  mov    %rsp,%rdi
  mov    %rbp,%r8
  mov    %rbx,%rcx
  mov    %rbx,%rdx
  lea    D27(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L30
L58:
  lea    D55(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    %rsp,%r12
  mov    %rbx,%rcx
  mov    %r14,%rdx
  lea    D11(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r12,%rdi
  call   <callSystem@plt>
L30:
  mov    %rsp,%r12
  mov    %r12,%rdi
  call   <callSystem@plt>
  mov    %r13,%rcx
  mov    %rbp,%rdx
  lea    D67(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    %r12,%rdi
  call   <callSystem@plt>
  mov    %rbx,%rdi
  call   <removeAFile@plt>
  mov    %rbp,%rdi
  call   <removeAFile@plt>
  mov    0x1008(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L60
  add    $0x1018,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L41:
  mov    %rsp,%rdi
  mov    %rbp,%r8
  mov    %rbx,%rcx
  mov    %rbx,%rdx
  lea    D56(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L30
L44:
  mov    %rsp,%rdi
  mov    %rbp,%r8
  mov    %rbx,%rcx
  mov    %rbx,%rdx
  lea    D28(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L30
L60:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D11
type: string
name: parse_data
arguments: tag: D27
type: string
name: parse_data
arguments: tag: D55
type: string
name: parse_data
arguments: tag: D67
type: string
name: parse_data
arguments: tag: D56
type: string
name: parse_data
arguments: tag: D28
type: string

tool: D11: ./wgrib2 %s -if_n 6::6 -s -set_grib_type c3 -grib_out %s

tool: D27: ./wgrib2 %s | grep ":d=$YYYYMMDD" | ./wgrib2 -i %s -if '00:PRATE:' -rpn sto_1 -fi -if '06:PRATE:' -rpn sto_2 -fi -if '12:PRATE:' -rpn sto_3 -fi -if '18:PRATE:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:+:+:+' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s

tool: D55: Invalid chop type specified, exiting


tool: D67: ./wgrib2 %s -if_n 1::4 -s -set_grib_type c3 -grib_out %s

tool: D56: ./wgrib2 %s | grep ":d=$YYYYMMDD" | ./wgrib2 -i %s -if '00:TMAX:' -rpn sto_1 -fi -if '06:TMAX:' -rpn sto_2 -fi -if '12:TMAX:' -rpn sto_3 -fi -if '18:TMAX:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:max:max:max' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s

tool: D28: ./wgrib2 %s | grep ":d=$YYYYMMDD" | ./wgrib2 -i %s -if '00:TMIN:' -rpn sto_1 -fi -if '06:TMIN:' -rpn sto_2 -fi -if '12:TMIN:' -rpn sto_3 -fi -if '18:TMIN:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:min:min:min' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s

assistant: ```c
void chopGribFile(char *inFileName, char *outFileName, char *tempFileName, char *tempFileName2, int type) {
  if (type < 0 || type > 2) {
    printf("Invalid chop type specified, exiting\n");
    exit(0);
  }
  char systemCall[4096];
  sprintf(systemCall, "./wgrib2 %s -if_n 6::6 -s -set_grib_type c3 -grib_out %s", inFileName, tempFileName);
  callSystem(systemCall);
  if (type == 0)
    sprintf(systemCall, "./wgrib2 %s | grep \":d=$YYYYMMDD\" | ./wgrib2 -i %s -if '00:TMAX:' -rpn sto_1 -fi -if '06:TMAX:' -rpn sto_2 -fi -if '12:TMAX:' -rpn sto_3 -fi -if '18:TMAX:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:max:max:max' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s", tempFileName, tempFileName, tempFileName2);
  else if (type == 1)
    sprintf(systemCall, "./wgrib2 %s | grep \":d=$YYYYMMDD\" | ./wgrib2 -i %s -if '00:TMIN:' -rpn sto_1 -fi -if '06:TMIN:' -rpn sto_2 -fi -if '12:TMIN:' -rpn sto_3 -fi -if '18:TMIN:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:min:min:min' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s", tempFileName, tempFileName, tempFileName2);
  else if (type == 2)
    sprintf(systemCall, "./wgrib2 %s | grep \":d=$YYYYMMDD\" | ./wgrib2 -i %s -if '00:PRATE:' -rpn sto_1 -fi -if '06:PRATE:' -rpn sto_2 -fi -if '12:PRATE:' -rpn sto_3 -fi -if '18:PRATE:' -rpn sto_4 -fi -if_reg '1:2:3:4' -rpn 'rcl_1:rcl_2:rcl_3:rcl_4:+:+:+' -set_ave '4@6 hour max(0-6 hour max fcst),missing=0' -set_grib_type c3 -grib_out %s", tempFileName, tempFileName, tempFileName2);
  callSystem(systemCall);
  sprintf(systemCall, "./wgrib2 %s -if_n 1::4 -s -set_grib_type c3 -grib_out %s", tempFileName2, outFileName);
  callSystem(systemCall);
  removeAFile(tempFileName);
  removeAFile(tempFileName2);
}
```