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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%edi
  jle    L88
  mov    0x8(%rsi),%rdi
  lea    D8(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L88
  lea    D7(%rip),%rsi
  lea    D14(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L88
  lea    0x24(%rsp),%rdx
  lea    0x20(%rsp),%rsi
  mov    %r13,%rdi
  call   <spng_dec_read_size@plt>
  mov    0x24(%rsp),%edx
  mov    0x20(%rsp),%esi
  mov    %r12,%rdi
  call   <write_ppm_header@plt>
  mov    %r13,%rdi
  call   <spng_dec_read_palet@plt>
  mov    %r13,%rdi
  call   <spng_dec_go_to_image_data@plt>
  mov    $0x3,%esi
  mov    %r13,%rdi
  call   <spng_dec_read_bits@plt>
  cmpl   $0x0,0x24(%rsp)
  je     L58
  movl   $0x0,0xc(%rsp)
  lea    0x1f(%rsp),%r14
  nopl   (%rax)
L35:
  mov    %r13,%rdi
  call   <spng_dec_read_literal@plt>
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  je     L32
  xor    %ebp,%ebp
  jmp    L112
  nopl   0x0(%rax,%rax,1)
L95:
  lea    0x1e(%rsp),%rcx
  lea    0x1d(%rsp),%rdx
  mov    %r13,%rdi
  mov    %r14,%r8
  call   <spng_dec_literal_to_rgb@plt>
  movzbl 0x1f(%rsp),%ecx
  mov    %r12,%rdi
  add    $0x1,%ebp
  movzbl 0x1e(%rsp),%edx
  movzbl 0x1d(%rsp),%esi
  call   <write_ppm_pixel@plt>
L31:
  cmp    %ebp,0x20(%rsp)
  jbe    L32
L112:
  mov    %r13,%rdi
  call   <spng_dec_read_literal@plt>
  mov    %eax,%esi
  cmp    $0xff,%eax
  jbe    L95
  mov    %r13,%rdi
  call   <spng_dec_read_length@plt>
  mov    $0x5,%esi
  mov    %r13,%rdi
  mov    %eax,%ebx
  add    %eax,%ebp
  call   <spng_dec_read_bits@plt>
  test   %ebx,%ebx
  je     L31
  xor    %r15d,%r15d
  cs nopw 0x0(%rax,%rax,1)
L38:
  movzbl 0x1f(%rsp),%ecx
  movzbl 0x1e(%rsp),%edx
  mov    %r12,%rdi
  add    $0x1,%r15d
  movzbl 0x1d(%rsp),%esi
  call   <write_ppm_pixel@plt>
  cmp    %r15d,%ebx
  jne    L38
  cmp    %ebp,0x20(%rsp)
  ja     L112
L32:
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  cmp    %eax,0x24(%rsp)
  ja     L35
L58:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L127:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L88:
  xor    %eax,%eax
  call   <usage@plt>
  mov    $0x2,%eax
  jmp    L127
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D8
type_guessed: string
name: retrieve_data
arguments: label: D7
type_guessed: string
name: retrieve_data
arguments: label: D14
type_guessed: string

tool: D8: r

tool: D7: w

tool: D14: out.ppm

assistant: ```c
int main(int argc, char *argv[]) {
  unsigned char r, g, b;
  unsigned int i, x, y;
  unsigned int w, h;
  unsigned int lit;
  FILE *fp = NULL;
  FILE *fpppm = NULL;
  if (argc > 1) {
    fp = fopen(argv[1], "r");
  }
  if (!fp) {
    usage();
    return 2;
  }
  fpppm = fopen("out.ppm", "w");
  if (!fpppm) {
    usage();
    return 2;
  }
  spng_dec_read_size(fp, &w, &h);
  write_ppm_header(fpppm, w, h);
  spng_dec_read_palet(fp);
  spng_dec_go_to_image_data(fp);
  spng_dec_read_bits(fp, 3);
  y = 0;
  while (y < h) {
    spng_dec_read_literal(fp);
    x = 0;
    while (x < w) {
      lit = spng_dec_read_literal(fp);
      if (lit < 256) {
        spng_dec_literal_to_rgb(fp, lit, &r, &g, &b);
        x++;
        write_ppm_pixel(fpppm, r, g, b);
      } else {
        lit = spng_dec_read_length(fp, lit);
        x += lit;
        spng_dec_read_bits(fp, 5);
        for (i = 0; i < lit; i++) {
          write_ppm_pixel(fpppm, r, g, b);
        }
      }
    }
    y++;
  }
  fclose(fpppm);
  fclose(fp);
  return 1;
}
```