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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x130,%rsp
  mov    %edi,-0x124(%rbp)
  mov    %rsi,-0x130(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D34(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  cmpl   $0x3,-0x124(%rbp)
  jne    L116
  mov    -0x130(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  je     L219
  mov    -0x130(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  jne    L171
  mov    $0x2,%eax
  jmp    L220
L171:
  mov    $0x0,%eax
  jmp    L220
L219:
  mov    $0x1,%eax
L220:
  mov    %eax,-0x11c(%rbp)
  mov    -0x130(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D68(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  je     L60
  mov    -0x130(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D68(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  jne    L84
  mov    $0x2,%eax
  jmp    L98
L84:
  mov    $0x0,%eax
  jmp    L98
L60:
  mov    $0x1,%eax
L98:
  mov    %eax,-0x118(%rbp)
  mov    -0x130(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D8(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  je     L148
  mov    -0x130(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D8(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <CheckExtension@plt>
  test   %rax,%rax
  jne    L125
  mov    $0x2,%eax
  jmp    L39
L125:
  mov    $0x0,%eax
  jmp    L39
L148:
  mov    $0x1,%eax
L39:
  mov    %eax,-0x114(%rbp)
  cmpl   $0x0,-0x118(%rbp)
  je     L193
  cmpl   $0x0,-0x118(%rbp)
  je     L116
  cmpl   $0x0,-0x114(%rbp)
  je     L116
  mov    -0x118(%rbp),%eax
  cmp    -0x114(%rbp),%eax
  je     L116
  mov    -0x118(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  lea    -0x110(%rbp),%rax
  mov    $0x104,%esi
  mov    %rax,%rdi
  call   <GetFilenameWithoutExt@plt>
  mov    -0x118(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x114(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x110(%rbp),%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <Hd3Unpack@plt>
  jmp    L207
L193:
  cmpl   $0x0,-0x11c(%rbp)
  je     L116
  cmpl   $0x0,-0x114(%rbp)
  je     L116
  mov    -0x11c(%rbp),%eax
  cmp    -0x114(%rbp),%eax
  je     L116
  mov    -0x11c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  lea    -0x110(%rbp),%rax
  mov    $0x104,%esi
  mov    %rax,%rdi
  call   <GetFilenameWithoutExt@plt>
  mov    -0x11c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x114(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x130(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x110(%rbp),%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <Hd2Unpack@plt>
  jmp    L207
L116:
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%eax
L207:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L106
  call   <__stack_chk_fail@plt>
L106:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D34
type_guessed: string
name: parse_data
arguments: data_tag: D2
type_guessed: string
name: parse_data
arguments: data_tag: D68
type_guessed: string
name: parse_data
arguments: data_tag: D8
type_guessed: string
name: parse_data
arguments: data_tag: D13
type_guessed: string

tool: D34: White Cloud - Dark Cloud's HD2/HD3 unpacker
Developed by Luciano Ciccariello (Xeeynamo)



tool: D2: .HD2

tool: D68: .HD3

tool: D8: .DAT

tool: D13: Usage:	whitecloud <data.dat> (<data.hd3> | <data.hd2)
	whitecloud (<data.hd3> | <data.hd2) <data.dat>


assistant: ```c
int main(int argc, char *argv[]) {
  printf("White Cloud - Dark Cloud's HD2/HD3 unpacker\n"
         "Developed by Luciano Ciccariello (Xeeynamo)\n\n");
  if (argc == 3) {
    int hd2Pos;
    int hd3Pos;
    int datPos;
    hd2Pos = CheckExtension(argv[1], ".HD2") == 0 ? 1 : CheckExtension(argv[2], ".HD2") == 0 ? 2 : 0;
    hd3Pos = CheckExtension(argv[1], ".HD3") == 0 ? 1 : CheckExtension(argv[2], ".HD3") == 0 ? 2 : 0;
    datPos = CheckExtension(argv[1], ".DAT") == 0 ? 1 : CheckExtension(argv[2], ".DAT") == 0 ? 2 : 0;
    if (hd3Pos != 0) {
      if (hd3Pos != 0 && datPos != 0 && hd3Pos != datPos) {
        char exportDir[260];
        GetFilenameWithoutExt(exportDir, sizeof(exportDir), argv[hd3Pos]);
        return Hd3Unpack(argv[datPos], argv[hd3Pos], exportDir);
      }
    } else {
      if (hd2Pos != 0 && datPos != 0 && hd2Pos != datPos) {
        char exportDir[260];
        GetFilenameWithoutExt(exportDir, sizeof(exportDir), argv[hd2Pos]);
        return Hd2Unpack(argv[datPos], argv[hd2Pos], exportDir);
      }
    }
  }
  printf("Usage:"
         "\twhitecloud <data.dat> (<data.hd3> | <data.hd2)\n"
         "\twhitecloud (<data.hd3> | <data.hd2) <data.dat>\n");
  return 1;
}
```