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

```asm
<extract2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1a8,%rsp
  mov    %rdi,%r15
  mov    %rsi,0x10(%rsp)
  mov    %edx,%r12d
  mov    %edx,0x6c(%rsp)
  mov    %r8d,%ebp
  mov    %r9,0x50(%rsp)
  mov    0x1e8(%rsp),%r14d
  mov    0x1f0(%rsp),%rax
  mov    %rax,0x70(%rsp)
  mov    0x1f8(%rsp),%rax
  mov    %rax,0x78(%rsp)
  mov    0x200(%rsp),%rbx
  mov    0x220(%rsp),%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x198(%rsp)
  xor    %eax,%eax
  call   <rewind@plt>
  test   %ebp,%ebp
  jle    L61
  mov    %rbx,0x38(%rsp)
  lea    -0x1(%rbp),%eax
  lea    (%rax,%rax,4),%rax
  lea    0x14(%rbx,%rax,4),%rax
  mov    %rax,0x60(%rsp)
  lea    -0x1(%r12),%eax
  mov    0x50(%rsp),%rcx
  lea    0x4(%rcx,%rax,4),%rax
  mov    %rax,0x58(%rsp)
L79:
  cmpl   $0x0,0x6c(%rsp)
  jle    L187
  mov    0x38(%rsp),%rax
  mov    %rax,0x28(%rsp)
  mov    0x70(%rsp),%rax
  mov    %rax,0x48(%rsp)
  mov    0x50(%rsp),%rax
  mov    %rax,0x40(%rsp)
L64:
  mov    0x40(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    0x48(%rsp),%rcx
  mov    %rcx,0x20(%rsp)
  mov    0x78(%rsp),%rcx
  mov    %rcx,0x18(%rsp)
  movl   $0x0,0x68(%rsp)
  cmpl   $0x0,(%rax)
  jg     L109
L39:
  addq   $0x4,0x40(%rsp)
  mov    0x40(%rsp),%rax
  addq   $0xa,0x48(%rsp)
  cmp    %rax,0x58(%rsp)
  jne    L64
L187:
  addq   $0x14,0x38(%rsp)
  mov    0x38(%rsp),%rax
  cmp    0x60(%rsp),%rax
  jne    L79
  mov    $0x0,%eax
  jmp    L118
L189:
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  mov    0x28(%rsp),%rsi
  lea    D29(%rip),%rdi
  call   <printf@plt>
  jmp    L48
L142:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x8c(%rsp),%xmm0
  lea    D13(%rip),%rsi
  mov    0x10(%rsp),%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
L10:
  add    $0x1,%ebx
  cmp    %ebx,%r14d
  jl     L166
L245:
  mov    %r12,%rdx
  lea    D21(%rip),%rsi
  mov    %r15,%rdi
  call   <fscanf@plt>
  cmp    %ebp,%r13d
  jl     L10
  cmp    %ebp,0x218(%rsp)
  jg     L10
  cmp    %ebx,0x210(%rsp)
  jg     L10
  cmp    %ebx,0x208(%rsp)
  jl     L10
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  cmp    $0x7,%eax
  jle    L142
  pxor   %xmm0,%xmm0
  cvtss2sd 0x8c(%rsp),%xmm0
  lea    D20(%rip),%rsi
  mov    0x10(%rsp),%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
  movl   $0x0,0xc(%rsp)
  jmp    L10
L166:
  add    $0x1,%ebp
  cmp    %ebp,0x1e0(%rsp)
  jl     L96
L114:
  mov    $0x1,%ebx
  lea    0x8c(%rsp),%r12
  test   %r14d,%r14d
  jg     L245
  jmp    L166
L96:
  cmpl   $0x0,0xc(%rsp)
  jne    L140
L132:
  addl   $0x1,0x68(%rsp)
  mov    0x68(%rsp),%eax
  addq   $0xa,0x18(%rsp)
  mov    0x30(%rsp),%rcx
  cmp    %eax,(%rcx)
  jle    L39
L109:
  cmpl   $0x1,0x228(%rsp)
  je     L189
L48:
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  mov    0x28(%rsp),%rsi
  mov    %r15,%rdi
  call   <find_TSVL@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L21
  mov    $0xe,%ebx
  lea    0x90(%rsp),%rbp
  mov    0x10(%rsp),%r12
L19:
  mov    %r15,%rdx
  mov    $0xff,%esi
  mov    %rbp,%rdi
  call   <fgets@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <fputs@plt>
  sub    $0x1,%ebx
  jne    L19
  movl   $0x0,0xc(%rsp)
  mov    $0x1,%ebp
  cmpl   $0x0,0x1e0(%rsp)
  jg     L114
  jmp    L132
L140:
  mov    0x10(%rsp),%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  jmp    L132
L61:
  mov    $0x0,%eax
  jmp    L118
L21:
  mov    $0xffffffff,%eax
L118:
  mov    0x198(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L176
  add    $0x1a8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L176:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D29
datatype: string
name: unpack_data
arguments: tag: D13
datatype: string
name: unpack_data
arguments: tag: D21
datatype: string
name: unpack_data
arguments: tag: D20
datatype: string

tool: D29: [%s][%s][%s]


tool: D13: %.6e 

tool: D21:  %f

tool: D20: %.6e


assistant: ```c
int extract2(FILE *fpin, FILE *fpout, int NumVars, int NumLev, int NumTimes, int Nl[], int Nr, int Nc, char VarName[][10], char LevName[][10], char TStepName[][20], int east_bound, int west_bound, int north_bound, int south_bound, int flag_i) {
  int it, iv, ir, ic, il, skip, val_cnt;
  float val;
  char inStr[255];
  rewind(fpin);
  for (it = 0; it < NumTimes; it++) {
    for (iv = 0; iv < NumVars; iv++) {
      for (il = 0; il < Nl[iv]; il++) {
        if (flag_i == 1)
          printf("[%s][%s][%s]\n", TStepName[it], VarName[iv], LevName[il]);
        fpin = find_TSVL(fpin, TStepName[it], VarName[iv], LevName[il]);
        if (fpin == NULL)
          goto err;
        for (skip = 1; skip <= 14; skip++) {
          fgets(inStr, 255, fpin);
          fprintf(fpout, "%s", inStr);
        }
        val_cnt = 0;
        for (ir = 1; ir <= Nr; ir++) {
          for (ic = 1; ic <= Nc; ic++) {
            fscanf(fpin, " %f", &val);
            if ((ir <= south_bound) && (ir >= north_bound) && (ic >= west_bound) && (ic <= east_bound)) {
              val_cnt++;
              if (val_cnt >= 8) {
                fprintf(fpout, "%.6e\n", val);
                val_cnt = 0;
              } else
                fprintf(fpout, "%.6e ", val);
            }
          }
        }
        if (val_cnt != 0) {
          fprintf(fpout, "\n");
          val_cnt = 0;
        }
      }
    }
  }
  return 0;
err:
  return -1;
}
```