user: Demonstrate the C code that generates the assembly output below:

```asm
<stbi_write_png_to_mem>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xd8,%rsp
  mov    %rdi,0x88(%rsp)
  mov    %esi,%ebx
  mov    %edx,0x90(%rsp)
  mov    %ecx,0x6c(%rsp)
  mov    %r8d,0x14(%rsp)
  mov    %r9,0x98(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xc8(%rsp)
  xor    %eax,%eax
  movl   $0xffffffff,0xb0(%rsp)
  movl   $0x0,0xb4(%rsp)
  movl   $0x4,0xb8(%rsp)
  movl   $0x2,0xbc(%rsp)
  movl   $0x6,0xc0(%rsp)
  test   %esi,%esi
  jne    L84
  mov    %edx,%ebx
  imul   %r8d,%ebx
L84:
  mov    0x90(%rsp),%r14d
  imul   0x14(%rsp),%r14d
  mov    %r14d,0x1c(%rsp)
  lea    0x1(%r14),%ebp
  mov    0x6c(%rsp),%r15d
  mov    %r15d,%eax
  imul   %ebp,%eax
  mov    %eax,0x94(%rsp)
  movslq %eax,%rdi
  call   <malloc@plt>
  mov    %rax,0x70(%rsp)
  test   %rax,%rax
  je     L204
  movslq %r14d,%rax
  mov    %rax,0x78(%rsp)
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L402
  test   %r15d,%r15d
  jle    L39
  movslq %ebp,%rax
  mov    %rax,0x80(%rsp)
  mov    0x70(%rsp),%rax
  add    $0x1,%rax
  mov    %rax,0x60(%rsp)
  mov    %ebx,0x28(%rsp)
  movl   $0x0,0x68(%rsp)
  movl   $0x0,0x5c(%rsp)
  lea    D49(%rip),%rax
  mov    %rax,0x38(%rsp)
  movslq 0x14(%rsp),%rax
  mov    %rax,%rsi
  mov    %rax,0x40(%rsp)
  mov    0x20(%rsp),%rax
  add    %rsi,%rax
  mov    %rax,0x48(%rsp)
  add    %eax,%ebx
  mov    %ebx,0x50(%rsp)
  jmp    L381
L402:
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rax
  mov    %rax,0x70(%rsp)
  jmp    L204
L401:
  mov    0x58(%rsp),%eax
  jmp    L307
  movzbl (%r12),%eax
  mov    %al,0x0(%rbp)
L147:
  add    $0x1,%r12
  add    $0x1,%rbp
  add    $0x1,%ebx
  cmp    %r13d,%ebx
  je     L234
L322:
  cmp    $0x6,%r15d
  ja     L147
  mov    %r15d,%eax
  lea    D12(%rip),%rdi
  movslq (%rdi,%rax,4),%rax
  add    %rdi,%rax
  notrack jmp *%rax
  movzbl (%r12),%eax
  mov    %al,0x0(%rbp)
  jmp    L147
  movslq %ebx,%rdx
  movzbl (%r12),%eax
  mov    (%rsp),%rcx
  sub    (%rcx,%rdx,1),%al
  mov    %al,0x0(%rbp)
  jmp    L147
  movslq %ebx,%rax
  mov    (%rsp),%rcx
  movzbl (%rcx,%rax,1),%edx
  shr    %dl
  movzbl (%r12),%eax
  sub    %edx,%eax
  mov    %al,0x0(%rbp)
  jmp    L147
  movzbl (%r12),%r14d
  movslq %ebx,%rax
  mov    (%rsp),%rcx
  movzbl (%rcx,%rax,1),%esi
  mov    $0x0,%edx
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <stbi__paeth@plt>
  sub    %eax,%r14d
  mov    %r14b,0x0(%rbp)
  jmp    L147
  movzbl (%r12),%eax
  mov    %al,0x0(%rbp)
  jmp    L147
  movzbl (%r12),%eax
  mov    %al,0x0(%rbp)
  jmp    L147
L234:
  mov    0x1c(%rsp),%esi
  mov    0x14(%rsp),%eax
  cmp    %eax,%esi
  jle    L101
  mov    (%rsp),%r12
  add    0x40(%rsp),%r12
  mov    %eax,%r13d
  sub    0x28(%rsp),%r13d
  sub    %eax,%esi
  mov    %esi,0x10(%rsp)
  mov    0x48(%rsp),%rbp
  mov    $0x0,%ebx
  lea    D8(%rip),%r14
  jmp    L7
  movzbl (%r12),%eax
  mov    %al,0x0(%rbp)
L148:
  add    $0x1,%ebx
  add    $0x1,%r12
  add    $0x1,%rbp
  add    $0x1,%r13d
  cmp    0x10(%rsp),%ebx
  je     L101
L7:
  cmp    $0x6,%r15d
  ja     L148
  mov    %r15d,%eax
  movslq (%r14,%rax,4),%rax
  add    %r14,%rax
  notrack jmp *%rax
  movslq %ebx,%rdx
  movzbl (%r12),%eax
  mov    (%rsp),%rsi
  sub    (%rsi,%rdx,1),%al
  mov    %al,0x0(%rbp)
  jmp    L148
  movslq %r13d,%rdx
  movzbl (%r12),%eax
  mov    (%rsp),%rcx
  sub    (%rcx,%rdx,1),%al
  mov    %al,0x0(%rbp)
  jmp    L148
  movslq %ebx,%rax
  mov    (%rsp),%rsi
  movzbl (%rsi,%rax,1),%eax
  movslq %r13d,%rdx
  movzbl (%rsi,%rdx,1),%edx
  add    %edx,%eax
  sar    %eax
  movzbl (%r12),%edx
  sub    %eax,%edx
  mov    %dl,0x0(%rbp)
  jmp    L148
  movzbl (%r12),%eax
  mov    %al,0x1b(%rsp)
  mov    %ebp,%eax
  sub    0x50(%rsp),%eax
  cltq
  mov    (%rsp),%rcx
  movzbl (%rcx,%rax,1),%edx
  movslq %r13d,%rax
  movzbl (%rcx,%rax,1),%esi
  movslq %ebx,%rax
  movzbl (%rcx,%rax,1),%edi
  mov    $0x0,%eax
  call   <stbi__paeth@plt>
  movzbl 0x1b(%rsp),%edx
  sub    %eax,%edx
  mov    %dl,0x0(%rbp)
  jmp    L148
  movslq %ebx,%rax
  mov    (%rsp),%rsi
  movzbl (%rsi,%rax,1),%edx
  shr    %dl
  movzbl (%r12),%eax
  sub    %edx,%eax
  mov    %al,0x0(%rbp)
  jmp    L148
  movzbl (%r12),%eax
  mov    %al,0x1b(%rsp)
  movslq %ebx,%rax
  mov    (%rsp),%rcx
  movzbl (%rcx,%rax,1),%edi
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%eax
  call   <stbi__paeth@plt>
  movzbl 0x1b(%rsp),%edx
  sub    %eax,%edx
  mov    %dl,0x0(%rbp)
  jmp    L148
L101:
  mov    0x34(%rsp),%esi
  test   %esi,%esi
  jne    L176
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  jle    L366
  mov    0x20(%rsp),%rcx
  mov    %rcx,%rdx
  mov    %eax,%edi
  add    %rcx,%rdi
L257:
  movzbl (%rdx),%ecx
  mov    %ecx,%eax
  neg    %al
  cmovs  %ecx,%eax
  movzbl %al,%eax
  add    %eax,%esi
  add    $0x1,%rdx
  cmp    %rdx,%rdi
  jne    L257
L214:
  cmp    %esi,0x2c(%rsp)
  jle    L370
  mov    %esi,0x2c(%rsp)
  mov    0x30(%rsp),%eax
  mov    %eax,0x54(%rsp)
L370:
  addq   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%rax
  cmp    $0x4,%eax
  jg     L225
L215:
  mov    0x8(%rsp),%rax
  mov    %eax,0x30(%rsp)
  mov    0x38(%rsp),%rcx
  mov    (%rcx,%rax,4),%r15d
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L234
  mov    (%rsp),%r12
  mov    0x20(%rsp),%rbp
  mov    0x28(%rsp),%esi
  mov    %esi,%ebx
  neg    %ebx
  sub    %esi,%eax
  mov    %eax,%r13d
  jmp    L322
L366:
  mov    0x34(%rsp),%esi
  jmp    L214
L176:
  mov    0x58(%rsp),%eax
  add    $0x1,%eax
  cmp    $0x1,%eax
  jle    L225
  mov    0x60(%rsp),%rbx
  movzbl 0x54(%rsp),%eax
  mov    %al,-0x1(%rbx)
  mov    0x78(%rsp),%rdx
  mov    0x20(%rsp),%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  addl   $0x1,0x5c(%rsp)
  mov    0x5c(%rsp),%eax
  mov    0x80(%rsp),%rsi
  add    %rsi,%rbx
  mov    %rbx,0x60(%rsp)
  mov    0x28(%rsp),%ebx
  add    %ebx,0x68(%rsp)
  cmp    %eax,0x6c(%rsp)
  je     L39
  cmpl   $0x0,0x5c(%rsp)
  lea    D7(%rip),%rdx
  lea    D49(%rip),%rax
  cmovne %rdx,%rax
  mov    %rax,0x38(%rsp)
L381:
  movslq 0x68(%rsp),%rax
  add    0x88(%rsp),%rax
  mov    %rax,(%rsp)
  movl   $0x0,0x58(%rsp)
  movl   $0x7fffffff,0x2c(%rsp)
  movl   $0x0,0x54(%rsp)
  jmp    L250
L225:
  addl   $0x1,0x58(%rsp)
L250:
  mov    0x58(%rsp),%eax
  mov    %eax,0x34(%rsp)
  test   %eax,%eax
  je     L401
  mov    0x54(%rsp),%eax
  cmp    $0x4,%eax
  jg     L176
L307:
  cltq
  mov    %rax,0x8(%rsp)
  jmp    L215
L39:
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  lea    0xa4(%rsp),%rdx
  mov    $0x8,%ecx
  mov    0x94(%rsp),%esi
  mov    0x70(%rsp),%r14
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <stbi_zlib_compress@plt>
  mov    %eax,%ebx
  mov    %r14,%rdi
  call   <free@plt>
  movq   $0x0,0x70(%rsp)
  test   %ebx,%ebx
  je     L204
  mov    0xa4(%rsp),%eax
  lea    0x39(%rax),%ebp
  movslq %ebp,%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    %rax,0x70(%rsp)
  test   %rax,%rax
  je     L204
  movslq %ebx,%rbx
  mov    0x98(%rsp),%r15
  mov    %ebp,(%r15)
  movabs $0xa1a0a0d474e5089,%rsi
  mov    %rsi,(%rax)
  movb   $0x0,0x8(%rax)
  movb   $0x0,0x9(%rax)
  movb   $0x0,0xa(%rax)
  movb   $0xd,0xb(%rax)
  movb   $0x49,0xc(%rax)
  movb   $0x48,0xd(%rax)
  movb   $0x44,0xe(%rax)
  movb   $0x52,0xf(%rax)
  mov    0x90(%rsp),%esi
  mov    %esi,%eax
  sar    $0x18,%eax
  mov    %al,0x10(%r14)
  mov    %esi,%eax
  sar    $0x10,%eax
  mov    %al,0x11(%r14)
  mov    %esi,%eax
  movzbl %ah,%ecx
  mov    %cl,0x12(%r14)
  mov    %sil,0x13(%r14)
  mov    0x6c(%rsp),%esi
  mov    %esi,%eax
  sar    $0x18,%eax
  mov    %al,0x14(%r14)
  mov    %esi,%eax
  sar    $0x10,%eax
  mov    %al,0x15(%r14)
  mov    %esi,%eax
  movzbl %ah,%ecx
  mov    %cl,0x16(%r14)
  mov    %sil,0x17(%r14)
  movb   $0x8,0x18(%r14)
  movslq 0x14(%rsp),%rax
  mov    0xb0(%rsp,%rax,4),%eax
  mov    %al,0x19(%r14)
  movb   $0x0,0x1a(%r14)
  movb   $0x0,0x1b(%r14)
  lea    0x1d(%r14),%rax
  mov    %rax,0xa8(%rsp)
  movb   $0x0,0x1c(%r14)
  lea    0xa8(%rsp),%rbp
  mov    $0xd,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <stbi__wpcrc@plt>
  movsbl 0xa7(%rsp),%edx
  mov    0xa8(%rsp),%rax
  mov    %dl,(%rax)
  movswl 0xa6(%rsp),%edx
  mov    0xa8(%rsp),%rax
  mov    %dl,0x1(%rax)
  mov    0xa8(%rsp),%rax
  mov    0xa4(%rsp),%edx
  movzbl %dh,%ecx
  mov    %cl,0x2(%rax)
  mov    0xa8(%rsp),%rax
  mov    0xa4(%rsp),%edx
  mov    %dl,0x3(%rax)
  mov    0xa8(%rsp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,0xa8(%rsp)
  movb   $0x49,0x4(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x44,0x1(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x41,0x2(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x54,0x3(%rax)
  mov    0xa8(%rsp),%rax
  lea    0x4(%rax),%rdi
  mov    %rdi,0xa8(%rsp)
  movslq 0xa4(%rsp),%r12
  mov    %r12,%rdx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  add    %r12,0xa8(%rsp)
  mov    %rbx,%rdi
  call   <free@plt>
  mov    0xa4(%rsp),%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <stbi__wpcrc@plt>
  mov    0xa8(%rsp),%rax
  movb   $0x0,(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x0,0x1(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x0,0x2(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x0,0x3(%rax)
  mov    0xa8(%rsp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,0xa8(%rsp)
  movb   $0x49,0x4(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x45,0x1(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x4e,0x2(%rax)
  mov    0xa8(%rsp),%rax
  movb   $0x44,0x3(%rax)
  addq   $0x4,0xa8(%rsp)
  mov    $0x0,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <stbi__wpcrc@plt>
  movslq (%r15),%rax
  add    %r14,%rax
  cmp    %rax,0xa8(%rsp)
  sete   %dil
  movzbl %dil,%edi
  mov    $0x0,%eax
  call   <assert@plt>
L204:
  mov    0xc8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  mov    0x70(%rsp),%rax
  add    $0xd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L56:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) {
  int ctype[5] = {-1, 0, 4, 2, 6};
  unsigned char sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
  unsigned char *out, *o, *filt, *zlib;
  signed char *line_buffer;
  int i, j, k, p, zlen;
  if (stride_bytes == 0)
    stride_bytes = x * n;
  filt = (unsigned char *)malloc((x * n + 1) * y);
  if (!filt)
    return 0;
  line_buffer = (signed char *)malloc(x * n);
  if (!line_buffer) {
    free(filt);
    return 0;
  }
  for (j = 0; j < y; ++j) {
    static int mapping[] = {0, 1, 2, 3, 4};
    static int firstmap[] = {0, 1, 0, 5, 6};
    int *mymap = j ? mapping : firstmap;
    int best = 0, bestval = 0x7fffffff;
    for (p = 0; p < 2; ++p) {
      for (k = p ? best : 0; k < 5; ++k) {
        int type = mymap[k], est = 0;
        unsigned char *z = pixels + stride_bytes * j;
        for (i = 0; i < n; ++i)
          switch (type) {
          case 0:
            line_buffer[i] = z[i];
            break;
          case 1:
            line_buffer[i] = z[i];
            break;
          case 2:
            line_buffer[i] = z[i] - z[i - stride_bytes];
            break;
          case 3:
            line_buffer[i] = z[i] - (z[i - stride_bytes] >> 1);
            break;
          case 4:
            line_buffer[i] = (signed char)(z[i] - stbi__paeth(0, z[i - stride_bytes], 0));
            break;
          case 5:
            line_buffer[i] = z[i];
            break;
          case 6:
            line_buffer[i] = z[i];
            break;
          }
        for (i = n; i < x * n; ++i) {
          switch (type) {
          case 0:
            line_buffer[i] = z[i];
            break;
          case 1:
            line_buffer[i] = z[i] - z[i - n];
            break;
          case 2:
            line_buffer[i] = z[i] - z[i - stride_bytes];
            break;
          case 3:
            line_buffer[i] = z[i] - ((z[i - n] + z[i - stride_bytes]) >> 1);
            break;
          case 4:
            line_buffer[i] = z[i] - stbi__paeth(z[i - n], z[i - stride_bytes], z[i - stride_bytes - n]);
            break;
          case 5:
            line_buffer[i] = z[i] - (z[i - n] >> 1);
            break;
          case 6:
            line_buffer[i] = z[i] - stbi__paeth(z[i - n], 0, 0);
            break;
          }
        }
        if (p)
          break;
        for (i = 0; i < x * n; ++i)
          est += abs((signed char)line_buffer[i]);
        if (est < bestval) {
          bestval = est;
          best = k;
        }
      }
    }
    filt[j * (x * n + 1)] = (unsigned char)best;
    memcpy(filt + j * (x * n + 1) + 1, line_buffer, x * n);
  }
  free(line_buffer);
  zlib = stbi_zlib_compress(filt, y * (x * n + 1), &zlen, 8);
  free(filt);
  if (!zlib)
    return 0;
  out = (unsigned char *)malloc(8 + 12 + 13 + 12 + zlen + 12);
  if (!out)
    return 0;
  *out_len = 8 + 12 + 13 + 12 + zlen + 12;
  o = out;
  memcpy(o, sig, 8);
  o += 8;
  ((o)[0] = (unsigned char)((13) >> 24), (o)[1] = (unsigned char)((13) >> 16), (o)[2] = (unsigned char)((13) >> 8), (o)[3] = (unsigned char)((13)), (o) += 4);
  ;
  ((o)[0] = (unsigned char)("IHDR"[0]), (o)[1] = (unsigned char)("IHDR"[1]), (o)[2] = (unsigned char)("IHDR"[2]), (o)[3] = (unsigned char)("IHDR"[3]), (o) += 4);
  ((o)[0] = (unsigned char)((x) >> 24), (o)[1] = (unsigned char)((x) >> 16), (o)[2] = (unsigned char)((x) >> 8), (o)[3] = (unsigned char)((x)), (o) += 4);
  ;
  ((o)[0] = (unsigned char)((y) >> 24), (o)[1] = (unsigned char)((y) >> 16), (o)[2] = (unsigned char)((y) >> 8), (o)[3] = (unsigned char)((y)), (o) += 4);
  ;
  *o++ = 8;
  *o++ = (unsigned char)ctype[n];
  *o++ = 0;
  *o++ = 0;
  *o++ = 0;
  stbi__wpcrc(&o, 13);
  ((o)[0] = (unsigned char)((zlen) >> 24), (o)[1] = (unsigned char)((zlen) >> 16), (o)[2] = (unsigned char)((zlen) >> 8), (o)[3] = (unsigned char)((zlen)), (o) += 4);
  ;
  ((o)[0] = (unsigned char)("IDAT"[0]), (o)[1] = (unsigned char)("IDAT"[1]), (o)[2] = (unsigned char)("IDAT"[2]), (o)[3] = (unsigned char)("IDAT"[3]), (o) += 4);
  memcpy(o, zlib, zlen);
  o += zlen;
  free(zlib);
  stbi__wpcrc(&o, zlen);
  ((o)[0] = (unsigned char)((0) >> 24), (o)[1] = (unsigned char)((0) >> 16), (o)[2] = (unsigned char)((0) >> 8), (o)[3] = (unsigned char)((0)), (o) += 4);
  ;
  ((o)[0] = (unsigned char)("IEND"[0]), (o)[1] = (unsigned char)("IEND"[1]), (o)[2] = (unsigned char)("IEND"[2]), (o)[3] = (unsigned char)("IEND"[3]), (o) += 4);
  stbi__wpcrc(&o, 0);
  assert(o == out + *out_len);
  return out;
}
```