user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r15
  lea    D14(%rip),%rsi
  lea    D23(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  movl   $0xff,0x50(%rsp)
  movabs $0x5500000000,%rax
  mov    %rax,0x60(%rsp)
  movabs $0xff000000aa,%rax
  mov    %rax,0x68(%rsp)
  movabs $0x6000000020,%rax
  mov    %rax,0x70(%rsp)
  movabs $0xdf0000009f,%rax
  mov    %rax,0x78(%rsp)
  movabs $0x7000000050,%rax
  mov    %rax,0x88(%rsp)
  movabs $0xaf0000008f,%rax
  mov    %rax,0x90(%rsp)
  movabs $0xef000000cf,%rax
  mov    %rax,0x98(%rsp)
  movabs $0xd500000080,%rax
  movl   $0x30,0x84(%rsp)
  mov    %rax,0x58(%rsp)
  call   <fopen@plt>
  test   %rax,%rax
  je     L114
  mov    %rax,%rcx
  mov    $0x29,%edx
  mov    $0x1,%esi
  mov    %rax,%rbp
  lea    D73(%rip),%rdi
  lea    D29(%rip),%r15
  call   <fwrite@plt>
  movl   $0x0,0x18(%rsp)
  movq   $0x0,0x28(%rsp)
L56:
  mov    0x28(%rsp),%rax
  xor    %r13d,%r13d
  xor    %ebx,%ebx
  mov    %eax,%ecx
  lea    0x1(%rax,%rax,1),%eax
  shl    $0x3,%ecx
  mov    %eax,0x10(%rsp)
  mov    %ecx,0x8(%rsp)
L39:
  mov    0x8(%rsp),%eax
  movl   $0x0,0x4(%rsp)
  mov    0x18(%rsp),%r14d
  lea    (%rax,%r13,1),%r12d
L68:
  mov    %r12d,%r9d
  xor    %r8d,%r8d
  mov    %r14d,%ecx
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  lea    0x1(%r12),%r9d
  xor    %eax,%eax
  mov    %r14d,%ecx
  mov    $0xff,%r8d
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <fprintf@plt>
  add    $0x2,%r12d
  cmpl   $0x1,0x4(%rsp)
  jne    L24
  add    $0x4,%r13
  cmp    $0x8,%r13
  je     L76
  mov    0x4c(%rsp,%r13,1),%ebx
  jmp    L39
  nopl   (%rax)
L24:
  movslq 0x10(%rsp),%rax
  movl   $0x1,0x4(%rsp)
  mov    0x60(%rsp,%rax,4),%r14d
  jmp    L68
  nopl   0x0(%rax)
L76:
  cmpq   $0x1,0x28(%rsp)
  je     L57
  movq   $0x1,0x28(%rsp)
  mov    0x68(%rsp),%eax
  mov    %eax,0x18(%rsp)
  jmp    L56
L57:
  mov    $0x10,%esi
  lea    D63(%rip),%rdi
  xor    %eax,%eax
  mov    $0x10,%ebx
  call   <printf@plt>
  xchg   %ax,%ax
L88:
  mov    %ebx,%edx
  mov    %ebx,%r9d
  xor    %eax,%eax
  mov    %r15,%rsi
  shl    $0x4,%edx
  mov    %rbp,%rdi
  sub    %ebx,%edx
  add    $0x1,%ebx
  sub    $0xe1,%edx
  mov    %edx,%r8d
  mov    %edx,%ecx
  call   <fprintf@plt>
  cmp    $0x20,%ebx
  jne    L88
  mov    $0x20,%esi
  lea    D70(%rip),%rdi
  xor    %eax,%eax
  mov    $0x2a,%r14d
  call   <printf@plt>
  lea    0x84(%rsp),%rax
  mov    %rax,0x30(%rsp)
  lea    0xa0(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    0x70(%rsp),%rax
  mov    %rax,0x38(%rsp)
L133:
  mov    0x28(%rsp),%eax
  movl   $0x0,0x20(%rsp)
  shl    $0x5,%eax
  mov    %eax,0x24(%rsp)
  mov    0x38(%rsp),%rax
  mov    %rax,0x8(%rsp)
L105:
  mov    0x20(%rsp),%eax
  mov    0x24(%rsp),%ebx
  mov    $0x10,%r13d
  mov    0x30(%rsp),%r12
  or     $0x2,%eax
  cltq
  mov    %rax,0x10(%rsp)
  jmp    L3
  nopl   0x0(%rax,%rax,1)
L14:
  mov    (%r12),%r13d
  add    $0x4,%r12
L3:
  mov    0x8(%rsp),%rax
  lea    0x1(%rbx),%r11d
  mov    %ebx,%r9d
  mov    %r13d,%ecx
  mov    %r14d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  mov    %r11d,0x4(%rsp)
  mov    (%rax),%r8d
  xor    %eax,%eax
  add    $0x2,%ebx
  call   <fprintf@plt>
  mov    0x10(%rsp),%rax
  mov    %r13d,%ecx
  mov    %r14d,%edx
  mov    0x4(%rsp),%r9d
  mov    %r15,%rsi
  mov    %rbp,%rdi
  mov    0x70(%rsp,%rax,4),%r8d
  xor    %eax,%eax
  call   <fprintf@plt>
  cmp    %r12,0x18(%rsp)
  jne    L14
  addl   $0x10,0x24(%rsp)
  addq   $0x4,0x8(%rsp)
  cmpl   $0x1,0x20(%rsp)
  je     L55
  movl   $0x1,0x20(%rsp)
  jmp    L105
  nopw   0x0(%rax,%rax,1)
L55:
  mov    0x28(%rsp),%rax
  cmp    $0x3,%rax
  je     L90
  mov    0x54(%rsp,%rax,4),%r14d
  add    $0x1,%rax
  mov    %rax,0x28(%rsp)
  jmp    L133
L90:
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    $0x80,%esi
  lea    D33(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  xor    %eax,%eax
L33:
  mov    0xa8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L22
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L114:
  lea    D77(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%eax
  jmp    L33
L22:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D14
type: string
name: unpack_data
arguments: data_label: D23
type: string
name: unpack_data
arguments: data_label: D73
type: string
name: unpack_data
arguments: data_label: D29
type: string
name: unpack_data
arguments: data_label: D63
type: string
name: unpack_data
arguments: data_label: D70
type: string
name: unpack_data
arguments: data_label: D33
type: string
name: unpack_data
arguments: data_label: D77
type: string

tool: D14: w

tool: D23: minimOS128.gpl

tool: D73: GIMP Palette
Name: minimOS
Columns: 16
#


tool: D29: %d %d %d	Index %d


tool: D63: Created %d system colours


tool: D70: Added system greyscale (total %d entries)


tool: D33: Finished palette with %d entries


tool: D77: *** CANNOT WRITE ***

assistant: ```c
int main(void) {
  FILE *arch;
  int r, g, b, h, l, i = 0;
  int byte[2] = {0, 255};
  int four[4] = {0, 85, 170, 255};
  int B[4] = {32, 96, 159, 223};
  int G[8] = {16, 48, 80, 112, 143, 175, 207, 239};
  int R[3] = {42, 128, 213};
  arch = fopen("minimOS128.gpl", "w");
  if (arch == NULL) {
    printf("*** CANNOT WRITE ***\n");
    return -1;
  }
  fprintf(arch, "GIMP Palette\nName: minimOS\nColumns: 16\n#\n");
  for (h = 0; h < 2; h++) {
    for (r = 0; r < 2; r++) {
      for (l = 0; l < 2; l++) {
        for (b = 0; b < 2; b++) {
          g = (h << 1) | l;
          fprintf(arch, "%d %d %d\tIndex %d\n", byte[r], four[g], byte[b], i++);
        }
      }
    }
  }
  printf("Created %d system colours\n", i);
  for (g = 15; g < 255; g += 15) {
    fprintf(arch, "%d %d %d\tIndex %d\n", g, g, g, i++);
  }
  printf("Added system greyscale (total %d entries)\n", i);
  for (r = 0; r < 3; r++) {
    for (l = 0; l < 2; l++) {
      for (g = 0; g < 8; g++) {
        for (h = 0; h < 2; h++) {
          b = (h << 1) | l;
          fprintf(arch, "%d %d %d\tIndex %d\n", R[r], G[g], B[b], i++);
        }
      }
    }
  }
  fclose(arch);
  printf("Finished palette with %d entries\n", i);
  return 0;
}
```