// File: lunasorcery[P]brailify/./stb/stb_image.h
// Function: stbi__gif_load_next(stbi__context*, stbi__gif*, int*, int)
static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp)
{
   int i;
   stbi_uc *prev_out = 0;

   if (g->out == 0 && !stbi__gif_header(s, g, comp,0))
      return 0; // stbi__g_failure_reason set by stbi__gif_header

   if (!stbi__mad3sizes_valid(g->w, g->h, 4, 0))
      return stbi__errpuc("too large", "GIF too large");

   prev_out = g->out;
   g->out = (stbi_uc *) stbi__malloc_mad3(4, g->w, g->h, 0);
   if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory");

   switch ((g->eflags & 0x1C) >> 2) {
      case 0: // unspecified (also always used on 1st frame)
         stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h);
         break;
      case 1: // do not dispose
         if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h);
         g->old_out = prev_out;
         break;
      case 2: // dispose to background
         if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h);
         stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y);
         break;
      case 3: // dispose to previous
         if (g->old_out) {
            for (i = g->start_y; i < g->max_y; i += 4 * g->w)
               memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x);
         }
         break;
   }

   for (;;) {
      switch (stbi__get8(s)) {
         case 0x2C: /* Image Descriptor */
         {
            int prev_trans = -1;
            stbi__int32 x, y, w, h;
            stbi_uc *o;

            x = stbi__get16le(s);
            y = stbi__get16le(s);
            w = stbi__get16le(s);
            h = stbi__get16le(s);
            if (((x + w) > (g->w)) || ((y + h) > (g->h)))
               return stbi__errpuc("bad Image Descriptor", "Corrupt GIF");

            g->line_size = g->w * 4;
            g->start_x = x * 4;
            g->start_y = y * g->line_size;
            g->max_x   = g->start_x + w * 4;
            g->max_y   = g->start_y + h * g->line_size;
            g->cur_x   = g->start_x;
            g->cur_y   = g->start_y;

            g->lflags = stbi__get8(s);

            if (g->lflags & 0x40) {
               g->step = 8 * g->line_size; // first interlaced spacing
               g->parse = 3;
            } else {
               g->step = g->line_size;
               g->parse = 0;
            }

            if (g->lflags & 0x80) {
               stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
               g->color_table = (stbi_uc *) g->lpal;
            } else if (g->flags & 0x80) {
               if (g->transparent >= 0 && (g->eflags & 0x01)) {
                  prev_trans = g->pal[g->transparent][3];
                  g->pal[g->transparent][3] = 0;
               }
               g->color_table = (stbi_uc *) g->pal;
            } else
               return stbi__errpuc("missing color table", "Corrupt GIF");

            o = stbi__process_gif_raster(s, g);
            if (o == NULL) return NULL;

            if (prev_trans != -1)
               g->pal[g->transparent][3] = (stbi_uc) prev_trans;

            return o;
         }

         case 0x21: // Comment Extension.
         {
            int len;
            if (stbi__get8(s) == 0xF9) { // Graphic Control Extension.
               len = stbi__get8(s);
               if (len == 4) {
                  g->eflags = stbi__get8(s);
                  g->delay = stbi__get16le(s);
                  g->transparent = stbi__get8(s);
               } else {
                  stbi__skip(s, len);
                  break;
               }
            }
            while ((len = stbi__get8(s)) != 0)
               stbi__skip(s, len);
            break;
         }

         case 0x3B: // gif stream termination code
            return (stbi_uc *) s; // using '1' causes warning on some compilers

         default:
            return stbi__errpuc("unknown code", "Corrupt GIF");
      }
   }

   STBI_NOTUSED(req_comp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x15942
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %ecx, %ecx
callq 0x15f60
cmpl $0x0, %eax
jne 0x15942
movq $0x0, -0x8(%rbp)
jmp 0x15f53
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0xe4b0
cmpl $0x0, %eax
jne 0x15980
leaq 0xae48(%rip), %rdi      # 0x207af
callq 0x13d0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %edx
movl $0x4, %edi
xorl %ecx, %ecx
callq 0xe6f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x159db
leaq 0xadf7(%rip), %rdi      # 0x207b9
callq 0x13d0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1c, %eax
shrl $0x2, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x3, %eax
ja 0x15b66
movq -0x60(%rbp), %rax
leaq 0xa7f2(%rip), %rcx      # 0x201f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %ecx
shll $0x2, %ecx
movq -0x18(%rbp), %rax
movl (%rax), %r8d
shll $0x2, %r8d
movq -0x18(%rbp), %rax
imull 0x4(%rax), %r8d
xorl %edx, %edx
movl %edx, %esi
callq 0x16110
jmp 0x15b66
cmpq $0x0, -0x30(%rbp)
je 0x15a66
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %eax
shll $0x2, %eax
movq -0x18(%rbp), %rcx
imull 0x4(%rcx), %eax
movslq %eax, %rdx
callq 0x10a0
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x15b66
cmpq $0x0, -0x30(%rbp)
je 0x15aa3
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %eax
shll $0x2, %eax
movq -0x18(%rbp), %rcx
imull 0x4(%rcx), %eax
movslq %eax, %rdx
callq 0x10a0
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x4844(%rax), %esi
movq -0x18(%rbp), %rax
movl 0x4848(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x484c(%rax), %ecx
movq -0x18(%rbp), %rax
movl 0x4850(%rax), %r8d
callq 0x16110
jmp 0x15b66
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x15b64
movq -0x18(%rbp), %rax
movl 0x4848(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4850(%rcx), %eax
jge 0x15b62
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
addl 0x4844(%rcx), %eax
cltq
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
addl 0x4844(%rcx), %eax
cltq
addq %rax, %rsi
movq -0x18(%rbp), %rax
movl 0x484c(%rax), %eax
movq -0x18(%rbp), %rcx
subl 0x4844(%rcx), %eax
movslq %eax, %rdx
callq 0x10a0
movq -0x18(%rbp), %rax
movl (%rax), %eax
shll $0x2, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x15af2
jmp 0x15b64
jmp 0x15b66
jmp 0x15b68
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %ecx
movl %ecx, -0x64(%rbp)
subb $0x21, %al
je 0x15e8f
jmp 0x15b81
movl -0x64(%rbp), %eax
subl $0x2c, %eax
je 0x15b9c
jmp 0x15b8b
movl -0x64(%rbp), %eax
subl $0x3b, %eax
je 0x15f27
jmp 0x15f31
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rdi
callq 0x151f0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x151f0
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x151f0
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x151f0
movl %eax, -0x44(%rbp)
movl -0x38(%rbp), %eax
addl -0x40(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x15bf0
movl -0x3c(%rbp), %eax
addl -0x44(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x15c10
leaq 0xb120(%rip), %rdi      # 0x20d17
callq 0x13d0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
movq -0x18(%rbp), %rax
movl (%rax), %ecx
shll $0x2, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x485c(%rax)
movl -0x38(%rbp), %ecx
shll $0x2, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4844(%rax)
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
imull 0x485c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4848(%rax)
movq -0x18(%rbp), %rax
movl 0x4844(%rax), %ecx
movl -0x40(%rbp), %eax
shll $0x2, %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x484c(%rax)
movq -0x18(%rbp), %rax
movl 0x4848(%rax), %ecx
movl -0x44(%rbp), %eax
movq -0x18(%rbp), %rdx
imull 0x485c(%rdx), %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4850(%rax)
movq -0x18(%rbp), %rax
movl 0x4844(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4854(%rax)
movq -0x18(%rbp), %rax
movl 0x4848(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4858(%rax)
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4840(%rax)
movq -0x18(%rbp), %rax
movl 0x4840(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x15d02
movq -0x18(%rbp), %rax
movl 0x485c(%rax), %ecx
shll $0x3, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x483c(%rax)
movq -0x18(%rbp), %rax
movl $0x3, 0x4838(%rax)
jmp 0x15d24
movq -0x18(%rbp), %rax
movl 0x485c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x483c(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x4838(%rax)
movq -0x18(%rbp), %rax
movl 0x4840(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x15dbc
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
addq $0x430, %rax            # imm = 0x430
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl 0x4840(%rax), %ecx
andl $0x7, %ecx
movl $0x2, %eax
shll %cl, %eax
movl %eax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x15d84
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x7c(%rbp)
jmp 0x15d8e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x7c(%rbp)
jmp 0x15d8e
movl -0x68(%rbp), %edx
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movl -0x7c(%rbp), %ecx
callq 0x161d0
movq -0x18(%rbp), %rcx
addq $0x430, %rcx            # imm = 0x430
movq -0x18(%rbp), %rax
movq %rcx, 0x4830(%rax)
jmp 0x15e42
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x15e20
movq -0x18(%rbp), %rax
cmpl $0x0, 0x24(%rax)
jl 0x15e0b
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x15e0b
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x24(%rcx), %rcx
movzbl 0x33(%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x24(%rcx), %rcx
movb $0x0, 0x33(%rax,%rcx,4)
movq -0x18(%rbp), %rcx
addq $0x30, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x4830(%rax)
jmp 0x15e40
leaq 0xaf05(%rip), %rdi      # 0x20d2c
callq 0x13d0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
jmp 0x15e42
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x16270
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x15e67
movq $0x0, -0x8(%rbp)
jmp 0x15f53
cmpl $-0x1, -0x34(%rbp)
je 0x15e82
movl -0x34(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x24(%rcx), %rcx
movb %dl, 0x33(%rax,%rcx,4)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %eax
cmpl $0xf9, %eax
jne 0x15f01
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %eax
movl %eax, -0x54(%rbp)
cmpl $0x4, -0x54(%rbp)
jne 0x15ef1
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rdi
callq 0x151f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
jmp 0x15eff
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0xe400
jmp 0x15f4e
jmp 0x15f01
jmp 0x15f03
movq -0x10(%rbp), %rdi
callq 0xdf10
movzbl %al, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
je 0x15f25
movq -0x10(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0xe400
jmp 0x15f03
jmp 0x15f4e
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
leaq 0xae08(%rip), %rdi      # 0x20d40
callq 0x13d0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
cmovneq %rax, %rax
movq %rax, -0x8(%rbp)
jmp 0x15f53
jmp 0x15b68
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq