// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__process_marker(stbi__jpeg*, int)
static int stbi__process_marker(stbi__jpeg *z, int m)
{
   int L;
   switch (m) {
      case STBI__MARKER_none: // no marker found
         return stbi__err("expected marker","Corrupt JPEG");

      case 0xDD: // DRI - specify restart interval
         if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG");
         z->restart_interval = stbi__get16be(z->s);
         return 1;

      case 0xDB: // DQT - define quantization table
         L = stbi__get16be(z->s)-2;
         while (L > 0) {
            int q = stbi__get8(z->s);
            int p = q >> 4;
            int t = q & 15,i;
            if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG");
            if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
            for (i=0; i < 64; ++i)
               z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s);
            L -= 65;
         }
         return L==0;

      case 0xC4: // DHT - define huffman table
         L = stbi__get16be(z->s)-2;
         while (L > 0) {
            stbi_uc *v;
            int sizes[16],i,n=0;
            int q = stbi__get8(z->s);
            int tc = q >> 4;
            int th = q & 15;
            if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG");
            for (i=0; i < 16; ++i) {
               sizes[i] = stbi__get8(z->s);
               n += sizes[i];
            }
            L -= 17;
            if (tc == 0) {
               if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
               v = z->huff_dc[th].values;
            } else {
               if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0;
               v = z->huff_ac[th].values;
            }
            for (i=0; i < n; ++i)
               v[i] = stbi__get8(z->s);
            if (tc != 0)
               stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th);
            L -= n;
         }
         return L==0;
   }
   // check for comment block or APP blocks
   if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) {
      stbi__skip(z->s, stbi__get16be(z->s)-2);
      return 1;
   }
   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x88(%rbp)
subl $0xc4, %eax
je 0x2c2dd
jmp 0x2c168
movl -0x88(%rbp), %eax
subl $0xdb, %eax
je 0x2c1fa
jmp 0x2c17b
movl -0x88(%rbp), %eax
subl $0xdd, %eax
je 0x2c1b1
jmp 0x2c18a
movl -0x88(%rbp), %eax
subl $0xff, %eax
jne 0x2c4dd
jmp 0x2c19d
leaq 0x1bd78(%rip), %rdi     # 0x47f1c
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cf90
cmpl $0x4, %eax
je 0x2c1d6
leaq 0x1bd63(%rip), %rdi     # 0x47f2c
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cf90
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x475c(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cf90
subl $0x2, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x2c2c9
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
sarl $0x4, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x2c254
leaq 0x1bcf1(%rip), %rdi     # 0x47f38
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2c533
cmpl $0x3, -0x24(%rbp)
jle 0x2c26e
leaq 0x1bce4(%rip), %rdi     # 0x47f45
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2c533
movl $0x0, -0x28(%rbp)
cmpl $0x40, -0x28(%rbp)
jge 0x2c2bb
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movb %al, %dl
movq -0x10(%rbp), %rax
addq $0x3488, %rax           # imm = 0x3488
movslq -0x24(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movslq -0x28(%rbp), %rsi
leaq 0x301a7(%rip), %rcx     # 0x5c450
movzbl (%rcx,%rsi), %ecx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2c275
movl -0x18(%rbp), %eax
subl $0x41, %eax
movl %eax, -0x18(%rbp)
jmp 0x2c20c
cmpl $0x0, -0x18(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cf90
subl $0x2, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jle 0x2c4cc
movl $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movzbl %al, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
sarl $0x4, %eax
movl %eax, -0x80(%rbp)
movl -0x7c(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x84(%rbp)
cmpl $0x1, -0x80(%rbp)
jg 0x2c336
cmpl $0x3, -0x84(%rbp)
jle 0x2c34a
leaq 0x1bc16(%rip), %rdi     # 0x47f53
callq 0x275b0
movl %eax, -0x4(%rbp)
jmp 0x2c533
movl $0x0, -0x74(%rbp)
cmpl $0x10, -0x74(%rbp)
jge 0x2c387
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movzbl %al, %ecx
movslq -0x74(%rbp), %rax
movl %ecx, -0x70(%rbp,%rax,4)
movslq -0x74(%rbp), %rax
movl -0x70(%rbp,%rax,4), %eax
addl -0x78(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2c351
movl -0x18(%rbp), %eax
subl $0x11, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x80(%rbp)
jne 0x2c3ee
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movslq -0x84(%rbp), %rax
imulq $0x690, %rax, %rax      # imm = 0x690
addq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x2cfd0
cmpl $0x0, %eax
jne 0x2c3c9
movl $0x0, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
addq $0x8, %rax
movslq -0x84(%rbp), %rcx
imulq $0x690, %rcx, %rcx      # imm = 0x690
addq %rcx, %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x30(%rbp)
jmp 0x2c449
movq -0x10(%rbp), %rdi
addq $0x1a48, %rdi           # imm = 0x1A48
movslq -0x84(%rbp), %rax
imulq $0x690, %rax, %rax      # imm = 0x690
addq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x2cfd0
cmpl $0x0, %eax
jne 0x2c424
movl $0x0, -0x4(%rbp)
jmp 0x2c533
movq -0x10(%rbp), %rax
addq $0x1a48, %rax           # imm = 0x1A48
movslq -0x84(%rbp), %rcx
imulq $0x690, %rcx, %rcx      # imm = 0x690
addq %rcx, %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x30(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x78(%rbp), %eax
jge 0x2c47c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2ce50
movb %al, %dl
movq -0x30(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2c450
cmpl $0x0, -0x80(%rbp)
je 0x2c4bc
movq -0x10(%rbp), %rdi
addq $0x3588, %rdi           # imm = 0x3588
movslq -0x84(%rbp), %rax
shlq $0xa, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x1a48, %rsi           # imm = 0x1A48
movslq -0x84(%rbp), %rax
imulq $0x690, %rax, %rax      # imm = 0x690
addq %rax, %rsi
callq 0x2d210
movl -0x78(%rbp), %ecx
movl -0x18(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
jmp 0x2c2ef
cmpl $0x0, -0x18(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0x2c533
cmpl $0xe0, -0x14(%rbp)
jl 0x2c4ef
cmpl $0xef, -0x14(%rbp)
jle 0x2c4f8
cmpl $0xfe, -0x14(%rbp)
jne 0x2c52c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2cf90
movq -0x90(%rbp), %rdi
movl %eax, %esi
subl $0x2, %esi
callq 0x2d340
movl $0x1, -0x4(%rbp)
jmp 0x2c533
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop