// File: /workspace/github_c_makefile_star2_O0/ggerganov[P]font-rasterizer/./stb_image_write.h
// Function: stbi_write_png_to_mem
STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
{
   int force_filter = stbi_write_force_png_filter;
   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 j,zlen;

   if (stride_bytes == 0)
      stride_bytes = x * n;

   if (force_filter >= 5) {
      force_filter = -1;
   }

   filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;
   line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
   for (j=0; j < y; ++j) {
      int filter_type;
      if (force_filter > -1) {
         filter_type = force_filter;
         stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);
      } else { // Estimate the best filter by running through all of them:
         int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
         for (filter_type = 0; filter_type < 5; filter_type++) {
            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);

            // Estimate the entropy of the line using this filter; the less, the better.
            est = 0;
            for (i = 0; i < x*n; ++i) {
               est += abs((signed char) line_buffer[i]);
            }
            if (est < best_filter_val) {
               best_filter_val = est;
               best_filter = filter_type;
            }
         }
         if (filter_type != best_filter) {  // If the last iteration already got us the best filter, don't redo it
            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);
            filter_type = best_filter;
         }
      }
      // when we get here, filter_type contains the filter type, and line_buffer contains the data
      filt[j*(x*n+1)] = (unsigned char) filter_type;
      STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);
   }
   STBIW_FREE(line_buffer);
   zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);
   STBIW_FREE(filt);
   if (!zlib) return 0;

   // each tag requires 12 bytes of overhead
   out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);
   if (!out) return 0;
   *out_len = 8 + 12+13 + 12+zlen + 12;

   o=out;
   STBIW_MEMMOVE(o,sig,8); o+= 8;
   stbiw__wp32(o, 13); // header length
   stbiw__wptag(o, "IHDR");
   stbiw__wp32(o, x);
   stbiw__wp32(o, y);
   *o++ = 8;
   *o++ = STBIW_UCHAR(ctype[n]);
   *o++ = 0;
   *o++ = 0;
   *o++ = 0;
   stbiw__wpcrc(&o,13);

   stbiw__wp32(o, zlen);
   stbiw__wptag(o, "IDAT");
   STBIW_MEMMOVE(o, zlib, zlen);
   o += zlen;
   STBIW_FREE(zlib);
   stbiw__wpcrc(&o, zlen);

   stbiw__wp32(o,0);
   stbiw__wptag(o, "IEND");
   stbiw__wpcrc(&o,0);

   STBIW_ASSERT(o == out + *out_len);

   return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl 0x184c2(%rip), %eax     # 0x1b118
movl %eax, -0x2c(%rbp)
movq 0x124f0(%rip), %rax     # 0x15150
movq %rax, -0x40(%rbp)
movq 0x124ed(%rip), %rax     # 0x15158
movq %rax, -0x38(%rbp)
movl 0x124eb(%rip), %eax     # 0x15160
movl %eax, -0x30(%rbp)
movq 0x13a39(%rip), %rax     # 0x166b8
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x2c93
movl -0x18(%rbp), %eax
imull -0x20(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x5, -0x2c(%rbp)
jl 0x2ca0
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl -0x18(%rbp), %eax
imull -0x20(%rbp), %eax
addl $0x1, %eax
imull -0x1c(%rbp), %eax
movslq %eax, %rdi
callq 0x1140
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x2cce
movq $0x0, -0x8(%rbp)
jmp 0x32d4
movl -0x18(%rbp), %eax
imull -0x20(%rbp), %eax
movslq %eax, %rdi
callq 0x1140
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x2cfe
movq -0x60(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
jmp 0x32d4
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2eba
cmpl $-0x1, -0x2c(%rbp)
jle 0x2d4d
movl -0x2c(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x74(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x2c(%rbp), %r10d
movq -0x70(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x32f0
jmp 0x2e5d
movl $0x0, -0x80(%rbp)
movl $0x7fffffff, -0x84(%rbp) # imm = 0x7FFFFFFF
movl $0x0, -0x7c(%rbp)
cmpl $0x5, -0x7c(%rbp)
jge 0x2e22
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x74(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x7c(%rbp), %r10d
movq -0x70(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x32f0
movl $0x0, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl -0x18(%rbp), %ecx
imull -0x20(%rbp), %ecx
cmpl %ecx, %eax
jge 0x2df2
movq -0x70(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2dae
movl -0x88(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x2e12
movl -0x88(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x2e14
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2d65
movl -0x7c(%rbp), %eax
cmpl -0x80(%rbp), %eax
je 0x2e5b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x74(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x80(%rbp), %r10d
movq -0x70(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x32f0
movl -0x80(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x2e5d
movl -0x7c(%rbp), %eax
movb %al, %dl
movq -0x60(%rbp), %rax
movl -0x74(%rbp), %ecx
movl -0x18(%rbp), %esi
imull -0x20(%rbp), %esi
addl $0x1, %esi
imull %esi, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x60(%rbp), %rdi
movl -0x74(%rbp), %eax
movl -0x18(%rbp), %ecx
imull -0x20(%rbp), %ecx
addl $0x1, %ecx
imull %ecx, %eax
cltq
addq %rax, %rdi
addq $0x1, %rdi
movq -0x70(%rbp), %rsi
movl -0x18(%rbp), %eax
imull -0x20(%rbp), %eax
movslq %eax, %rdx
callq 0x1170
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2d05
movq -0x70(%rbp), %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %eax
imull -0x20(%rbp), %eax
addl $0x1, %eax
imull %eax, %esi
movl 0x18233(%rip), %ecx     # 0x1b110
leaq -0x78(%rbp), %rdx
callq 0x1dc0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x68(%rbp)
jne 0x2f07
movq $0x0, -0x8(%rbp)
jmp 0x32d4
movl -0x78(%rbp), %eax
addl $0x2d, %eax
addl $0xc, %eax
movslq %eax, %rdi
callq 0x1140
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x2f30
movq $0x0, -0x8(%rbp)
jmp 0x32d4
movl -0x78(%rbp), %ecx
addl $0x2d, %ecx
addl $0xc, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
leaq -0x48(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movb $0x0, (%rax)
movq -0x58(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x58(%rbp), %rax
movb $0x0, 0x2(%rax)
movq -0x58(%rbp), %rax
movb $0xd, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movsbl 0x137a7(%rip), %eax     # 0x1673a
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movsbl 0x13794(%rip), %eax     # 0x1673b
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movsbl 0x13780(%rip), %eax     # 0x1673c
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movsbl 0x1376c(%rip), %eax     # 0x1673d
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movl -0x18(%rbp), %eax
sarl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movl -0x18(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x18(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x18(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movl -0x1c(%rbp), %eax
sarl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movl -0x1c(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x1c(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x1c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb $0x8, (%rax)
movslq -0x20(%rbp), %rax
movl -0x40(%rbp,%rax,4), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x58(%rbp)
movb %cl, (%rax)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb $0x0, (%rax)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb $0x0, (%rax)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb $0x0, (%rax)
leaq -0x58(%rbp), %rdi
movl $0xd, %esi
callq 0x3760
movl -0x78(%rbp), %eax
sarl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movl -0x78(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x78(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x78(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movsbl 0x135cf(%rip), %eax     # 0x1673f
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movsbl 0x135bc(%rip), %eax     # 0x16740
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movsbl 0x135a8(%rip), %eax     # 0x16741
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movsbl 0x13594(%rip), %eax     # 0x16742
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
movslq -0x78(%rbp), %rdx
callq 0x1170
movl -0x78(%rbp), %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x68(%rbp), %rdi
callq 0x1030
movl -0x78(%rbp), %esi
leaq -0x58(%rbp), %rdi
callq 0x3760
movq -0x58(%rbp), %rax
movb $0x0, (%rax)
movq -0x58(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x58(%rbp), %rax
movb $0x0, 0x2(%rax)
movq -0x58(%rbp), %rax
movb $0x0, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
movsbl 0x13513(%rip), %eax     # 0x16744
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, (%rax)
movsbl 0x13500(%rip), %eax     # 0x16745
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x1(%rax)
movsbl 0x134ec(%rip), %eax     # 0x16746
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x2(%rax)
movsbl 0x134d8(%rip), %eax     # 0x16747
andl $0xff, %eax
movb %al, %cl
movq -0x58(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x3760
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rdx
movslq (%rdx), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0x32ad
jmp 0x32cc
leaq 0x13495(%rip), %rdi     # 0x16749
leaq 0x13427(%rip), %rsi     # 0x166e2
movl $0x483, %edx            # imm = 0x483
leaq 0x13496(%rip), %rcx     # 0x1675d
callq 0x10a0
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)