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

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%edi
  je     L0
  cmp    $0x3,%edi
  je     L51
  cmp    $0x2,%edi
  je     L45
  lea    D7(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L98:
  mov    %rsp,%rsi
  mov    %rbx,%rdi
  call   <loadfile2@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L117
L10:
  mov    (%rsp),%rcx
  movabs $0xaaaaaaaaaaaaaaab,%rdx
  mov    %rcx,%rax
  mul    %rdx
  shr    %rdx
  mov    %rbx,%rsi
  lea    D76(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D5(%rip),%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L126
L23:
  mov    %r12,%rcx
  mov    $0x1c,%edx
  mov    $0x1,%esi
  lea    D53(%rip),%rdi
  call   <fwrite@plt>
  cmpq   $0x0,(%rsp)
  je     L104
  mov    $0x0,%ebx
  mov    $0x0,%eax
  lea    D109(%rip),%r13
L18:
  movzbl 0x0(%rbp,%rax,1),%esi
  lea    0x1(%rbx),%eax
  movzbl 0x0(%rbp,%rax,1),%edx
  lea    0x2(%rbx),%eax
  movzbl 0x0(%rbp,%rax,1),%eax
  movzbl %al,%r8d
  shl    $0x2,%r8d
  shr    $0x4,%al
  movzbl %al,%eax
  movzbl %dl,%ecx
  shl    $0x2,%ecx
  shr    $0x4,%dl
  movzbl %dl,%edx
  or     %edx,%ecx
  movzbl %sil,%edx
  shl    $0x2,%edx
  shr    $0x4,%sil
  movzbl %sil,%esi
  or     %esi,%edx
  or     %eax,%r8d
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x3,%ebx
  mov    %ebx,%eax
  cmp    (%rsp),%rax
  jb     L18
L104:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L94
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L0:
  lea    D97(%rip),%rdi
  call   <puts@plt>
  lea    D0(%rip),%rdi
  call   <puts@plt>
  lea    D88(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L98
L51:
  mov    0x8(%rsi),%rbx
  mov    0x10(%rsi),%r12
  jmp    L98
L45:
  mov    0x8(%rsi),%rbx
  mov    $0x9,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L22
L59:
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    D17(%rip),%rsi
  mov    %r12,%rdi
  call   <changefileext@plt>
  jmp    L98
L22:
  lea    D90(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L59
L117:
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L10
L126:
  lea    D71(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L23
L94:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D7
type_infered: string
name: unpack_data
arguments: data_tag: D76
type_infered: string
name: unpack_data
arguments: data_tag: D5
type_infered: string
name: unpack_data
arguments: data_tag: D53
type_infered: string
name: unpack_data
arguments: data_tag: D109
type_infered: string
name: unpack_data
arguments: data_tag: D97
type_infered: string
name: unpack_data
arguments: data_tag: D0
type_infered: string
name: unpack_data
arguments: data_tag: D88
type_infered: string
name: unpack_data
arguments: data_tag: D17
type_infered: string
name: unpack_data
arguments: data_tag: D90
type_infered: string
name: unpack_data
arguments: data_tag: D71
type_infered: string

tool: D7: Too many arguments!

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


tool: D5: wb

tool: D53: GIMP Palette
Name: eracha
#


tool: D109: %3d %3d %3d


tool: D97: pal2gpl

tool: D0: ----------------------------------

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

tool: D17: .gpl

tool: D90: malloc

tool: D71: create file

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);
}
```