// File: alan0201tw[P]RayTracer/include/stb_image.h
// Function: stbi__create_png_image(stbi__png*, unsigned char*, unsigned int, int, int, int, int)
static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced)
{
   int bytes = (depth == 16 ? 2 : 1);
   int out_bytes = out_n * bytes;
   stbi_uc *final;
   int p;
   if (!interlaced)
      return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color);

   // de-interlacing
   final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
   for (p=0; p < 7; ++p) {
      int xorig[] = { 0,4,0,2,0,1,0 };
      int yorig[] = { 0,0,4,0,2,0,1 };
      int xspc[]  = { 8,8,4,4,2,2,1 };
      int yspc[]  = { 8,8,8,4,4,2,2 };
      int i,j,x,y;
      // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1
      x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p];
      y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p];
      if (x && y) {
         stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;
         if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) {
            STBI_FREE(final);
            return 0;
         }
         for (j=0; j < y; ++j) {
            for (i=0; i < x; ++i) {
               int out_y = j*yspc[p]+yorig[p];
               int out_x = i*xspc[p]+xorig[p];
               memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes,
                      a->out + (j*x+i)*out_bytes, out_bytes);
            }
         }
         STBI_FREE(a->out);
         image_data += img_len;
         image_data_len -= img_len;
      }
   }
   a->out = final;

   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl -0x24(%rbp), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x10, %edx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x6b609
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %r8d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %r9d
movl -0x24(%rbp), %r10d
movl -0x28(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x6bf80
movl %eax, -0x4(%rbp)
jmp 0x6b93b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
movl -0x30(%rbp), %edx
xorl %ecx, %ecx
callq 0x664e0
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x7, -0x3c(%rbp)
jge 0x6b928
movq 0x13f3e(%rip), %rax     # 0x7f580
movq %rax, -0x60(%rbp)
movq 0x13f3b(%rip), %rax     # 0x7f588
movq %rax, -0x58(%rbp)
movq 0x13f38(%rip), %rax     # 0x7f590
movq %rax, -0x50(%rbp)
movl 0x13f36(%rip), %eax     # 0x7f598
movl %eax, -0x48(%rbp)
movq 0x13f34(%rip), %rax     # 0x7f5a0
movq %rax, -0x80(%rbp)
movq 0x13f31(%rip), %rax     # 0x7f5a8
movq %rax, -0x78(%rbp)
movq 0x13f2e(%rip), %rax     # 0x7f5b0
movq %rax, -0x70(%rbp)
movl 0x13f2c(%rip), %eax     # 0x7f5b8
movl %eax, -0x68(%rbp)
movq 0x13f2a(%rip), %rax     # 0x7f5c0
movq %rax, -0xa0(%rbp)
movq 0x13f24(%rip), %rax     # 0x7f5c8
movq %rax, -0x98(%rbp)
movq 0x13f1e(%rip), %rax     # 0x7f5d0
movq %rax, -0x90(%rbp)
movl 0x13f19(%rip), %eax     # 0x7f5d8
movl %eax, -0x88(%rbp)
movq 0x13f14(%rip), %rax     # 0x7f5e0
movq %rax, -0xc0(%rbp)
movq 0x13f0e(%rip), %rax     # 0x7f5e8
movq %rax, -0xb8(%rbp)
movq 0x13f08(%rip), %rax     # 0x7f5f0
movq %rax, -0xb0(%rbp)
movl 0x13f03(%rip), %eax     # 0x7f5f8
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movslq -0x3c(%rbp), %rcx
subl -0x60(%rbp,%rcx,4), %eax
movslq -0x3c(%rbp), %rcx
addl -0xa0(%rbp,%rcx,4), %eax
subl $0x1, %eax
movslq -0x3c(%rbp), %rcx
xorl %edx, %edx
divl -0xa0(%rbp,%rcx,4)
movl %eax, -0xcc(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movslq -0x3c(%rbp), %rcx
subl -0x80(%rbp,%rcx,4), %eax
movslq -0x3c(%rbp), %rcx
addl -0xc0(%rbp,%rcx,4), %eax
subl $0x1, %eax
movslq -0x3c(%rbp), %rcx
xorl %edx, %edx
divl -0xc0(%rbp,%rcx,4)
movl %eax, -0xd0(%rbp)
cmpl $0x0, -0xcc(%rbp)
je 0x6b918
cmpl $0x0, -0xd0(%rbp)
je 0x6b918
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %eax
imull -0xcc(%rbp), %eax
imull -0x24(%rbp), %eax
addl $0x7, %eax
sarl $0x3, %eax
addl $0x1, %eax
imull -0xd0(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0xcc(%rbp), %r8d
movl -0xd0(%rbp), %r9d
movl -0x24(%rbp), %r10d
movl -0x28(%rbp), %eax
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x6bf80
cmpl $0x0, %eax
jne 0x6b7ef
movq -0x38(%rbp), %rdi
callq 0x75e0
movl $0x0, -0x4(%rbp)
jmp 0x6b93b
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0xd0(%rbp), %eax
jge 0x6b8ea
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jge 0x6b8d4
movl -0xc8(%rbp), %eax
movslq -0x3c(%rbp), %rcx
imull -0xc0(%rbp,%rcx,4), %eax
movslq -0x3c(%rbp), %rcx
addl -0x80(%rbp,%rcx,4), %eax
movl %eax, -0xd8(%rbp)
movl -0xc4(%rbp), %eax
movslq -0x3c(%rbp), %rcx
imull -0xa0(%rbp,%rcx,4), %eax
movslq -0x3c(%rbp), %rcx
addl -0x60(%rbp,%rcx,4), %eax
movl %eax, -0xdc(%rbp)
movq -0x38(%rbp), %rdi
movl -0xd8(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imull (%rcx), %eax
imull -0x30(%rbp), %eax
movl %eax, %eax
addq %rax, %rdi
movl -0xdc(%rbp), %eax
imull -0x30(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movl -0xc8(%rbp), %eax
imull -0xcc(%rbp), %eax
addl -0xc4(%rbp), %eax
imull -0x30(%rbp), %eax
cltq
addq %rax, %rsi
movslq -0x30(%rbp), %rdx
callq 0x7400
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x6b815
jmp 0x6b8d6
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x6b7f9
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x75e0
movl -0xd4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0xd4(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6b91a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6b631
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)