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

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x60,%rsp
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  cmp    $0x3,%edi
  jle    L70
L82:
  mov    0x18(%rbp),%rdi
  lea    D49(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L53
L47:
  mov    $0x0,%edi
  call   <time@plt>
  mov    %eax,0xc(%rsp)
  mov    %rbx,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D38(%rip),%rdi
  call   <fwrite@plt>
  lea    0xc(%rsp),%r12
  mov    %r12,%rdi
  call   <ctime@plt>
  mov    %rax,%rdx
  lea    D89(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %rbx,%rcx
  mov    $0x36,%edx
  mov    $0x1,%esi
  lea    D64(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbx,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D54(%rip),%rdi
  call   <fwrite@plt>
  mov    0x10(%rbp),%rcx
  mov    0x8(%rbp),%rdx
  lea    D69(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0x0,%edi
  call   <cuserid@plt>
  mov    %rax,%rbp
  mov    %r12,%rdi
  call   <ctime@plt>
  mov    %rax,%rsi
  lea    0x10(%rsp),%rdi
  call   <strcpy@plt>
  cmpb   $0x0,0x10(%rsp)
  je     L68
  lea    0x10(%rsp),%rax
L3:
  add    $0x1,%rax
  cmpb   $0x0,(%rax)
  jne    L3
L32:
  cmpb   $0xa,-0x1(%rax)
  je     L98
L46:
  lea    0x10(%rsp),%rcx
  mov    %rbp,%rdx
  lea    D85(%rip),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  mov    $0x0,%eax
  add    $0x60,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L70:
  lea    D44(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L82
L53:
  mov    0x18(%rbp),%rsi
  lea    D86(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L47
L68:
  lea    0x10(%rsp),%rax
  jmp    L32
L98:
  movb   $0x0,-0x1(%rax)
  jmp    L46
L20:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D49
type: string
name: unpack_data
arguments: tag: D38
type: string
name: unpack_data
arguments: tag: D89
type: string
name: unpack_data
arguments: tag: D64
type: string
name: unpack_data
arguments: tag: D54
type: string
name: unpack_data
arguments: tag: D69
type: string
name: unpack_data
arguments: tag: D85
type: string
name: unpack_data
arguments: tag: D44
type: string
name: unpack_data
arguments: tag: D86
type: string

tool: D49: w

tool: D38: /*


tool: D89:  * G2 Version Stamp, %s

tool: D64:  * Automatically generated, hand edits are pointless.


tool: D54:  */



tool: D69: const char *version_string = "G2 (%s) major version %s";


tool: D85: const char *minor_v_string = "Built by %s at %s";


tool: D44: usage: mkversion ostype version outputfile

tool: D86: Couldn't create %s


assistant: ```c
int main(int argc, char **argv) {
  time_t now;
  FILE *ofp;
  char *dateval;
  char *username;
  char *userstr;
  char *datestr;
  int i;
  char propname[32];
  char *propvalue;
  char timestr[64];
  char *cp;
  if (argc < 4) {
    printf("usage: mkversion ostype version outputfile\n");
    exit(1);
  }
  ofp = fopen(argv[3], "w");
  if (ofp == NULL) {
    printf("Couldn't create %s\n", argv[3]);
    exit(1);
  }
  now = time(0);
  fprintf(ofp, "/*\n");
  fprintf(ofp, " * G2 Version Stamp, %s", ctime(&now));
  fprintf(ofp, " * Automatically generated, hand edits are pointless.\n");
  fprintf(ofp, " */\n\n");
  fprintf(ofp, "const char *version_string = \"G2 (%s) major version %s\";\n", argv[1], argv[2]);
  username = (char *)cuserid(0);
  strcpy(timestr, ctime(&now));
  cp = timestr;
  while (*cp) {
    cp++;
  }
  if (*--cp == '\n')
    *cp = 0;
  fprintf(ofp, "const char *minor_v_string = \"Built by %s at %s\";\n", username, timestr);
  exit(0);
}
```