user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x1,-0x54(%rbp)
  jne    L112
  lea    D109(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D62(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D20(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L96
L112:
  cmpl   $0x3,-0x54(%rbp)
  jne    L17
  mov    -0x60(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x60(%rbp),%rax
  mov    0x10(%rax),%rax
  mov    %rax,-0x20(%rbp)
  jmp    L96
L17:
  cmpl   $0x2,-0x54(%rbp)
  jne    L116
  mov    -0x60(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x28(%rbp)
  mov    $0x9,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L37
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L37:
  mov    -0x28(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x20(%rbp),%rax
  lea    D51(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <changefileext@plt>
  jmp    L96
L116:
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L96:
  lea    -0x30(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <loadfile2@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L88
  mov    $0x1,%edi
  call   <exit@plt>
L88:
  mov    -0x30(%rbp),%rax
  movabs $0xaaaaaaaaaaaaaaab,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    %rax
  mov    %eax,-0x40(%rbp)
  mov    -0x30(%rbp),%rcx
  mov    -0x40(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  lea    D77(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x20(%rbp),%rax
  lea    D79(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L42
  lea    D45(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L42:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1c,%edx
  mov    $0x1,%esi
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  movl   $0x0,-0x44(%rbp)
  jmp    L43
L104:
  mov    -0x44(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  lea    0x0(,%rax,4),%ecx
  mov    -0x44(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  shr    $0x4,%al
  movzbl %al,%eax
  or     %ecx,%eax
  mov    %eax,-0x3c(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%ecx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  shr    $0x4,%al
  movzbl %al,%eax
  or     %edx,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  mov    %eax,%ecx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  shr    $0x4,%al
  movzbl %al,%eax
  or     %edx,%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x34(%rbp),%esi
  mov    -0x38(%rbp),%ecx
  mov    -0x3c(%rbp),%edx
  mov    -0x10(%rbp),%rax
  mov    %esi,%r8d
  lea    D23(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  addl   $0x3,-0x44(%rbp)
L43:
  mov    -0x44(%rbp),%edx
  mov    -0x30(%rbp),%rax
  cmp    %rax,%rdx
  jb     L104
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L57
  call   <__stack_chk_fail@plt>
L57:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D109
datatype: string
name: unpack_data
arguments: data_label: D62
datatype: string
name: unpack_data
arguments: data_label: D20
datatype: string
name: unpack_data
arguments: data_label: D1
datatype: string
name: unpack_data
arguments: data_label: D51
datatype: string
name: unpack_data
arguments: data_label: D4
datatype: string
name: unpack_data
arguments: data_label: D77
datatype: string
name: unpack_data
arguments: data_label: D79
datatype: string
name: unpack_data
arguments: data_label: D45
datatype: string
name: unpack_data
arguments: data_label: D29
datatype: string
name: unpack_data
arguments: data_label: D23
datatype: string

tool: D109: pal2gpl

tool: D62: ----------------------------------

tool: D20: usage: pal2gpl file.pal [file.gpl]

tool: D1: malloc

tool: D51: .gpl

tool: D4: Too many arguments!

tool: D77: '%s' has %d colors, file size is %li.


tool: D79: wb

tool: D45: create file

tool: D29: GIMP Palette
Name: eracha
#


tool: D23: %3d %3d %3d


assistant: ```c
int main(int argc, char *argv[]) {
  char *filename_from, *filename_to;
  unsigned int count;
  unsigned long size;
  unsigned char *buf;
  if (argc == 1) {
    printf("pal2gpl\n");
    printf("----------------------------------\n");
    printf("usage: pal2gpl file.pal [file.gpl]\n");
    exit(0);
  } else if (argc == 3) {
    filename_from = argv[1];
    filename_to = argv[2];
  } else if (argc == 2) {
    filename_from = argv[1];
    filename_to = (char *)malloc(sizeof(filename_from) + 1);
    if (filename_to == NULL) {
      perror("malloc");
      exit(1);
    }
    strcpy(filename_to, filename_from);
    changefileext(filename_to, ".gpl");
  } else {
    printf("Too many arguments!\n");
    exit(1);
  }
  buf = loadfile2(filename_from, &size);
  if (buf == NULL)
    exit(1);
  count = size / 3;
  printf("'%s' has %d colors, file size is %li.\n", filename_from, count, size);
  FILE *des = fopen(filename_to, "wb");
  if (des == NULL) {
    perror("create file");
    exit(1);
  }
  fprintf(des, "GIMP Palette\nName: eracha\n#\n");
  unsigned int i, r, g, b;
  for (i = 0; i < size; i = i + 3) {
    r = (buf[i] << 2) | (buf[i] >> 4);
    g = (buf[i + 1] << 2) | (buf[i + 1] >> 4);
    b = (buf[i + 2] << 2) | (buf[i + 2] >> 4);
    fprintf(des, "%3d %3d %3d\n", r, g, b);
  }
  fclose(des);
  free(buf);
  exit(0);
}
```