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

```asm
<parse_1st_msg>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%rbx
  test   %rbx,%rbx
  je     L30
L99:
  mov    0x40(%r15),%rax
  add    $0x10,%rbx
  movq   $0x0,0x30(%r15)
  lea    D22(%rip),%rbp
  movq   $0x0,0x10(%r15)
  lea    D68(%rip),%r12
  lea    D41(%rip),%r14
  sub    %rbx,%rax
  movq   $0x0,0x48(%r15)
  lea    D9(%rip),%r13
  test   %rax,%rax
  jg     L8
  jmp    L119
  nopw   0x0(%rax,%rax,1)
L73:
  cmp    $0x7,%al
  je     L38
L26:
  mov    %rbx,%rdi
  call   <uint4@plt>
  cltq
  add    %rax,%rbx
  mov    0x40(%r15),%rax
  sub    %rbx,%rax
  test   %rax,%rax
  jle    L119
L8:
  movzbl 0x4(%rbx),%esi
  cmp    $0x8,%sil
  ja     L74
L129:
  mov    %rbx,(%r15,%rsi,8)
  movzbl 0x4(%rbx),%eax
  cmp    $0x6,%al
  jne    L73
  movzbl 0x5(%rbx),%eax
  test   %al,%al
  jne    L95
  mov    %rbx,0x48(%r15)
  movzbl 0x4(%rbx),%eax
  cmp    $0x7,%al
  jne    L26
L38:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L74:
  mov    %rbp,%rdi
  call   <fatal_error_i@plt>
  movzbl 0x4(%rbx),%esi
  jmp    L129
  xchg   %ax,%ax
L95:
  lea    -0x1(%rax),%edx
  cmp    $0xfc,%dl
  jbe    L9
  cmp    $0xfe,%al
  jne    L26
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <fatal_error@plt>
  movzbl 0x4(%rbx),%eax
  jmp    L73
L119:
  lea    D68(%rip),%rsi
  lea    D65(%rip),%rdi
  call   <fatal_error@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L9:
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <fatal_error@plt>
  movzbl 0x4(%rbx),%eax
  jmp    L73
  nopl   0x0(%rax)
L30:
  lea    D68(%rip),%rsi
  lea    D20(%rip),%rdi
  call   <fatal_error@plt>
  mov    (%r15),%rbx
  jmp    L99
```

tool_calls: name: unpack_data
arguments: data_tag: D22
datatype: string
name: unpack_data
arguments: data_tag: D68
datatype: string
name: unpack_data
arguments: data_tag: D41
datatype: string
name: unpack_data
arguments: data_tag: D9
datatype: string
name: unpack_data
arguments: data_tag: D65
datatype: string
name: unpack_data
arguments: data_tag: D20
datatype: string

tool: D22: parse_1st_msg illegal section %d

tool: 

tool: D41: parse_1st_msg: illegal grib msg, bitmap not defined code, table 6.0=254

tool: D9: parse_1st_msg: predefined bitmaps are not handled

tool: D65: parse_1st_msg illegally format grib

tool: D20: parse_1st_msg .. sec[0] == NULL

assistant: ```c
int parse_1st_msg(unsigned char **sec) {
  unsigned char *p;
  if (sec[0] == NULL)
    fatal_error("parse_1st_msg .. sec[0] == NULL", "");
  sec[2] = sec[6] = NULL;
  sec[9] = NULL;
  p = sec[0] + 16;
  while (sec[8] - p > 0) {
    if (p[4] > 8)
      fatal_error_i("parse_1st_msg illegal section %d", (int)p[4]);
    sec[p[4]] = p;
    if (p[4] == 6) {
      if (p[5] == 0) {
        sec[9] = p;
      } else if (p[5] >= 1 && p[5] <= 253) {
        fatal_error("parse_1st_msg: predefined bitmaps are not handled", "");
      } else if (p[5] == 254) {
        fatal_error("parse_1st_msg: illegal grib msg, bitmap not defined code, table 6.0=254", "");
      }
    }
    if (p[4] == 7) {
      return 0;
    }
    p += uint4(p);
  }
  fatal_error("parse_1st_msg illegally format grib", "");
  return 1;
}
```