// File: /workspace/github_cpp_makefile_star2_O3/cloudinary[P]fuif/./export/write_pam.h
// Function: write_PAM_file(char const*, Image const&)
bool write_PAM_file(const char *output_image, const Image &image) {

  int nb_channels = image.channel.size();
  bool debugstuff = false;

  if (nb_channels > ((image.colormodel & 48) == 16 ? 5 : 4)) {
    e_printf("Too many channels. Saving just the first 3 channels (instead of %i)\n",nb_channels);
    nb_channels = 3; // just use the first 3. debug stuff
    debugstuff = true;
  }
  if (nb_channels == 0) {
    e_printf("Cannot save a zero-channel 'image' as PAM.\n");
    return false;
  }

  int w = image.channel[0].w;
  int h = image.channel[0].h;
  if (image.w < w) w = image.w;
  if (image.h < h) h = image.h;
  for (int i=1; i<nb_channels; i++) {
    if (image.channel[i].w < w) nb_channels = 1;
    if (image.channel[i].h < h) nb_channels = 1;
    if (nb_channels == 1) e_printf("Not saving channel %i since dimensions (%ix%i) do not correspond with the image dimensions (%ix%i).\n",i,image.channel[i].w,image.channel[i].h,w,h);
  }

  if (nb_channels > image.nb_channels) {debugstuff=true; nb_channels=1;}

  FILE *fp = fopen(output_image,"wb");
  if (!fp) {
    return false;
  }


  int components=3;
  bool cmyk = false;
  if ((image.colormodel & 48) == 0) { // RGB
    if (nb_channels == 4) components=4;
  } else if ((image.colormodel & 48) == 16) { // CMYK
    if (nb_channels == 5) components=4;
    if (nb_channels > 3) cmyk = true;
  }
  if (image.colormodel != 0 && image.colormodel != 16) {
    v_printf(1,"Warning: saving raw pixel data without a color profile, even though the image is not sRGB.\n");
  }
  if (nb_channels == 1) components = 1;
  if (nb_channels == 2) components = 2;

  int bit_depth = 8, bytes_per_value=1;
  if (image.channel[0].minval < 0) {bit_depth = 8; bytes_per_value=1;} // this is just for debugging things


  if (image.maxval > 255) {bit_depth = 16; bytes_per_value=2;}
  if (image.maxval > 65535) { e_printf("Warning: cannot save as PAM since bit depth is higher than 16-bit. Doing it anyway.\n");}

  if (image.nb_channels == 0) {
    // visualize signed stuff
    int range = image.channel[0].maxval - image.channel[0].minval;
    v_printf(3,"Visualizing %ix%i channel with range %i..%i\n",w,h,image.channel[0].minval,image.channel[0].maxval);
    if (range > 255) {bit_depth = 16; bytes_per_value=2;}
    if (image.real_nb_channels == 0) {
    fprintf(fp,"P6\n%u %u\n%i\n", w, h, 255);
    for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
      for (int c=0; c<components; c++) {
        // 5461 is one bit
        fputc(CLAMP(image.channel[c].value(y,x)*255/5461, 0, 255),fp);
        fputc(CLAMP(image.channel[c].value(y,x)*50/5461, 0, 255),fp);
        fputc(CLAMP(image.channel[c].value(y,x)*12/5461, 0, 255),fp);
      }
     }
    }
    } else {
    fprintf(fp,"P5\n%u %u\n%i\n", w, h, range);
    for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
      for (int c=0; c<components; c++) {
        if (bytes_per_value > 1) fputc((image.channel[c].value(y,x) - image.channel[0].minval) >> 8,fp);
        fputc((image.channel[c].value(y,x) - image.channel[0].minval) & 0xFF,fp);
      }
     }
    }
    }
    fclose(fp);
    return 0;
  }

  if (components == 1) fprintf(fp,"P5\n%u %u\n%i\n", w, h, image.maxval);
  if (components == 2) fprintf(fp,"P7\nWIDTH %u\nHEIGHT %u\nDEPTH 2\nMAXVAL %i\nTUPLTYPE GRAYSCALE_ALPHA\nENDHDR\n", w, h, image.maxval);
  if (components == 3) fprintf(fp,"P6\n%u %u\n%i\n", w, h, image.maxval);
  if (components == 4) fprintf(fp,"P7\nWIDTH %u\nHEIGHT %u\nDEPTH 4\nMAXVAL %i\nTUPLTYPE RGB_ALPHA\nENDHDR\n", w, h, image.maxval);
  v_printf(10,"Writing %i-channel PAM file (range %i..%i)\n",components,image.minval,image.maxval);

  if (cmyk) {
    v_printf(1,"Warning: converting CMYK image to RGB in order to save it as PAM.\n");
    for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
      for (int c=0; c<3; c++) {
        if (bytes_per_value > 1) fputc(CLAMP( (image.maxval-image.channel[c].value_nocheck(y,x))*image.channel[3].value_nocheck(y,x)/image.maxval,image.minval,image.maxval) >> 8,fp);
        fputc(CLAMP( (image.maxval-image.channel[c].value_nocheck(y,x))*image.channel[3].value_nocheck(y,x)/image.maxval,image.minval,image.maxval) & 0xFF,fp);
      }
      if (nb_channels == 5) {
        if (bytes_per_value > 1) fputc(CLAMP(image.channel[4].value_nocheck(y,x),image.minval,image.maxval) >> 8,fp);
        fputc(CLAMP(image.channel[4].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
      }
     }
    }
  } else {
    if (bytes_per_value > 1) {
    for (int y = 0; y < h; y++) {
     for (int x = 0; x < w; x++) {
      for (int c=0; c<components; c++) {
        fputc(CLAMP(image.channel[c].value_nocheck(y,x),image.minval,image.maxval) >> 8,fp);
        fputc(CLAMP(image.channel[c].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
      }
     }
    }
    } else {
      if (components == 3) {
        for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++) {
            fputc(CLAMP(image.channel[0].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
            fputc(CLAMP(image.channel[1].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
            fputc(CLAMP(image.channel[2].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
         }
        }
      } else {
        for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++) {
          for (int c=0; c<components; c++) {
            fputc(CLAMP(image.channel[c].value_nocheck(y,x),image.minval,image.maxval) & 0xFF,fp);
          }
         }
        }
      }
    }
  }

  fclose(fp);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
movq 0x8(%rsi), %r12
subq %rax, %r12
shrq $0x6, %r12
movl 0x70(%rsi), %ecx
andl $0x30, %ecx
xorl %edx, %edx
cmpl $0x10, %ecx
sete %dl
orl $0x4, %edx
cmpl %r12d, %edx
jge 0x20740
leaq 0x6ce0(%rip), %rdi      # 0x2740b
movl %r12d, %esi
xorl %eax, %eax
callq 0x379e
movq (%rbx), %rax
movl $0x3, %r12d
jmp 0x20749
testl %r12d, %r12d
je 0x2082f
movq %r14, 0x8(%rsp)
movslq 0x18(%rax), %rcx
movl 0x1c(%rax), %esi
movslq 0x30(%rbx), %rbp
cmpl %ecx, %ebp
movq %rcx, 0x20(%rsp)
movl %ecx, %eax
cmovll %ebp, %eax
movl %eax, (%rsp)
movl 0x34(%rbx), %eax
cmpl %esi, %eax
cmovll %eax, %esi
cmpl $0x2, %r12d
movl %esi, 0x4(%rsp)
jl 0x207d8
movl $0x1, %r13d
movl $0x5c, %r14d
movl $0x1, %r15d
movq (%rbx), %rax
movl -0x4(%rax,%r14), %edx
movl (%rax,%r14), %ecx
cmpl (%rsp), %edx
cmovll %r15d, %r12d
cmpl %esi, %ecx
cmovll %r15d, %r12d
cmpl $0x1, %r12d
jne 0x207c9
leaq 0x6cca(%rip), %rdi      # 0x2747c
movl %r13d, %esi
movl (%rsp), %r8d
movl 0x4(%rsp), %r9d
xorl %eax, %eax
callq 0x379e
movl 0x4(%rsp), %esi
incq %r13
movslq %r12d, %rax
addq $0x40, %r14
cmpq %rax, %r13
jl 0x2078c
cmpl 0x64(%rbx), %r12d
movl $0x1, %eax
cmovlel %r12d, %eax
movl %eax, 0x10(%rsp)
leaq 0x6269(%rip), %rsi      # 0x26a59
movq 0x8(%rsp), %rdi
callq 0x3370
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2104b
movl 0x70(%rbx), %eax
movl %eax, %ecx
andl $0x30, %ecx
cmpl $0x10, %ecx
je 0x20842
testl %ecx, %ecx
movl (%rsp), %r15d
jne 0x20861
xorl %r13d, %r13d
cmpl $0x4, 0x10(%rsp)
sete %r13b
addl $0x3, %r13d
jmp 0x20867
leaq 0x6d81(%rip), %rdi      # 0x275b7
xorl %eax, %eax
callq 0x379e
jmp 0x2104b
xorl %r13d, %r13d
movl 0x10(%rsp), %ecx
cmpl $0x5, %ecx
sete %r13b
addl $0x3, %r13d
cmpl $0x4, %ecx
setge %r14b
movl (%rsp), %r15d
jmp 0x2086a
movl $0x3, %r13d
xorl %r14d, %r14d
testl $0xffffffef, %eax       # imm = 0xFFFFFFEF
je 0x20884
leaq 0x6d6b(%rip), %rsi      # 0x275e3
movl $0x1, %edi
xorl %eax, %eax
callq 0x1cede
movl 0x10(%rsp), %eax
cmpl $0x1, %eax
cmovel %eax, %r13d
cmpl $0x2, %eax
cmovel %eax, %r13d
movl 0x60(%rbx), %r12d
cmpl $0x10000, %r12d         # imm = 0x10000
jl 0x208b1
leaq 0x6d95(%rip), %rdi      # 0x2763f
xorl %eax, %eax
callq 0x379e
cmpl $0x0, 0x64(%rbx)
je 0x208e8
movl 0x60(%rbx), %r8d
cmpl $0x1, %r13d
je 0x20a57
cmpl $0x3, %r13d
je 0x20a45
movl %r13d, %r15d
cmpl $0x2, %r13d
jne 0x20a63
leaq 0x6df8(%rip), %rsi      # 0x276db
jmp 0x20a6a
movl %r13d, 0x10(%rsp)
movl $0x100, %r14d           # imm = 0x100
cmpl %r14d, %r12d
setge %bpl
movq (%rbx), %rax
movswl 0x22(%rax), %r9d
movswl 0x20(%rax), %r8d
movl %r9d, %r13d
subl %r8d, %r13d
leaq 0x6d80(%rip), %rsi      # 0x27694
movl $0x3, %edi
movl %r15d, %edx
movl 0x4(%rsp), %r12d
movl %r12d, %ecx
xorl %eax, %eax
callq 0x1cede
cmpl %r14d, %r13d
movl %r15d, %edx
setge %r15b
cmpl $0x0, 0x68(%rbx)
je 0x20e18
leaq 0x6d88(%rip), %rsi      # 0x276ce
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
movl %r12d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x33f0
testl %r12d, %r12d
jle 0x21041
orb %r15b, %bpl
movl 0x10(%rsp), %eax
movq %rax, 0x10(%rsp)
cmpl $0x0, (%rsp)
jle 0x20a32
xorl %r12d, %r12d
movl $0x24, %r13d
movq 0x10(%rsp), %r15
testb %bpl, %bpl
je 0x209d4
movq (%rbx), %rax
leaq (%rax,%r13), %rcx
movl -0xc(%rax,%r13), %edx
imull %r14d, %edx
addl %r12d, %edx
movslq %edx, %rdx
movq -0x24(%rax,%r13), %rsi
movq -0x1c(%rax,%r13), %rdi
subq %rsi, %rdi
sarq %rdi
cmpq %rdx, %rdi
leaq (%rsi,%rdx,2), %rdx
cmovbeq %rcx, %rdx
movswl (%rdx), %edi
movswl 0x20(%rax), %eax
subl %eax, %edi
sarl $0x8, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
leaq (%rax,%r13), %rcx
movl -0xc(%rax,%r13), %edx
imull %r14d, %edx
addl %r12d, %edx
movslq %edx, %rdx
movq -0x24(%rax,%r13), %rsi
movq -0x1c(%rax,%r13), %rdi
subq %rsi, %rdi
sarq %rdi
cmpq %rdx, %rdi
leaq (%rsi,%rdx,2), %rdx
cmovbeq %rcx, %rdx
movzwl (%rdx), %ecx
subl 0x20(%rax), %ecx
movzbl %cl, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
addq $0x40, %r13
decq %r15
jne 0x20988
incl %r12d
cmpl (%rsp), %r12d
jne 0x2097d
incl %r14d
cmpl 0x4(%rsp), %r14d
jne 0x20970
jmp 0x21041
movl %r13d, %r15d
movb $0x1, %al
movl %eax, 0x1c(%rsp)
leaq 0x6c6c(%rip), %rsi      # 0x276c1
jmp 0x20a72
movl %r13d, %r15d
leaq 0x6c6d(%rip), %rsi      # 0x276ce
jmp 0x20a6a
leaq 0x6cba(%rip), %rsi      # 0x27724
movl $0x0, 0x1c(%rsp)
movq 0x8(%rsp), %rdi
movl (%rsp), %edx
movl 0x4(%rsp), %r13d
movl %r13d, %ecx
xorl %eax, %eax
callq 0x33f0
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %r8d
leaq 0x6cd0(%rip), %rsi      # 0x27767
movl $0xa, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1cede
testb %r14b, %r14b
je 0x20c57
leaq 0x6cdd(%rip), %rsi      # 0x27793
xorl %ebp, %ebp
movl $0x1, %edi
xorl %eax, %eax
callq 0x1cede
testl %r13d, %r13d
jle 0x21041
movl (%rsp), %r15d
testl %r15d, %r15d
jle 0x20c46
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpl $0x100, %r12d           # imm = 0x100
jl 0x20b47
movl 0x60(%rbx), %ecx
movq (%rbx), %rax
movl 0x18(%rax,%r14), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq (%rax,%r14), %rsi
movswl (%rsi,%rdx,2), %edx
movl %ecx, %esi
subl %edx, %esi
movl 0xd8(%rax), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq 0xc0(%rax), %rax
movswl (%rax,%rdx,2), %eax
imull %esi, %eax
cltd
idivl %ecx
movl %eax, %edx
cmpl %ecx, %eax
jl 0x20b31
movl %ecx, %edx
movl 0x5c(%rbx), %edi
cmpl %edi, %eax
jl 0x20b3a
movl %edx, %edi
sarl $0x8, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movl 0x60(%rbx), %ecx
movq (%rbx), %rax
movl 0x18(%rax,%r14), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq (%rax,%r14), %rsi
movswl (%rsi,%rdx,2), %edx
movl %ecx, %esi
subl %edx, %esi
movl 0xd8(%rax), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq 0xc0(%rax), %rax
movswl (%rax,%rdx,2), %eax
imull %esi, %eax
cltd
idivl %ecx
movl 0x5c(%rbx), %edx
movl %eax, %esi
cmpl %ecx, %eax
jl 0x20b92
movl %ecx, %esi
cmpl %edx, %eax
jl 0x20b98
movl %esi, %edx
movzbl %dl, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
addq $0x40, %r14
cmpq $0xc0, %r14
jne 0x20ae0
cmpl $0x5, 0x10(%rsp)
jne 0x20c3a
cmpl $0x100, %r12d           # imm = 0x100
jl 0x20c00
movq (%rbx), %rax
movl 0x118(%rax), %ecx
imull %ebp, %ecx
addl %r13d, %ecx
movslq %ecx, %rcx
movq 0x100(%rax), %rax
movswl (%rax,%rcx,2), %eax
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %edi
cmpl %eax, %edi
cmovgel %eax, %edi
cmpl %eax, %ecx
cmovgl %ecx, %edi
sarl $0x8, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
movl 0x118(%rax), %ecx
imull %ebp, %ecx
addl %r13d, %ecx
movslq %ecx, %rcx
movq 0x100(%rax), %rax
movswl (%rax,%rcx,2), %eax
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %edx
cmpl %eax, %edx
cmovgel %eax, %edx
cmpl %eax, %ecx
cmovgl %ecx, %edx
movzbl %dl, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
incl %r13d
cmpl %r15d, %r13d
jne 0x20add
incl %ebp
cmpl 0x4(%rsp), %ebp
jne 0x20ad1
jmp 0x21041
cmpl $0x100, %r12d           # imm = 0x100
jl 0x20d1c
cmpl $0x0, 0x4(%rsp)
jle 0x21041
movl %r15d, %r14d
xorl %r15d, %r15d
cmpl $0x0, (%rsp)
jle 0x20d09
xorl %ebp, %ebp
movq %r14, %r12
xorl %r13d, %r13d
movq (%rbx), %rax
movl 0x18(%rax,%r13), %ecx
imull %r15d, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
movq (%rax,%r13), %rax
movswl (%rax,%rcx,2), %eax
movl 0x60(%rbx), %edi
cmpl %eax, %edi
jl 0x20ca9
movl %eax, %edi
movl 0x5c(%rbx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %edi
sarl $0x8, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
movl 0x18(%rax,%r13), %ecx
imull %r15d, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
movq (%rax,%r13), %rax
movswl (%rax,%rcx,2), %ecx
movl 0x60(%rbx), %eax
cmpl %ecx, %eax
jl 0x20ce0
movl %ecx, %eax
movl 0x5c(%rbx), %edx
cmpl %ecx, %edx
cmovgl %edx, %eax
movzbl %al, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
addq $0x40, %r13
decq %r12
jne 0x20c87
incl %ebp
cmpl (%rsp), %ebp
jne 0x20c81
incl %r15d
cmpl 0x4(%rsp), %r15d
jne 0x20c75
jmp 0x21041
cmpb $0x0, 0x1c(%rsp)
movl 0x4(%rsp), %eax
je 0x20fd8
testl %eax, %eax
jle 0x21041
movq 0x20(%rsp), %rax
cmpq %rbp, %rax
cmovlq %rax, %rbp
xorl %r14d, %r14d
movl $0xff, %r15d
cmpl $0x0, (%rsp)
jle 0x20e05
movslq %r14d, %r12
xorl %r13d, %r13d
movq (%rbx), %rax
movslq 0x18(%rax), %rcx
imulq %r12, %rcx
addq %r13, %rcx
movq (%rax), %rax
movswl (%rax,%rcx,2), %eax
movl 0x60(%rbx), %edi
cmpl %eax, %edi
jl 0x20d76
movl %eax, %edi
movl 0x5c(%rbx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %edi
andl %r15d, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
movslq 0x58(%rax), %rcx
imulq %r12, %rcx
addq %r13, %rcx
movq 0x40(%rax), %rax
movswl (%rax,%rcx,2), %eax
movl 0x60(%rbx), %edi
cmpl %eax, %edi
jl 0x20daa
movl %eax, %edi
movl 0x5c(%rbx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %edi
andl %r15d, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
movslq 0x98(%rax), %rcx
imulq %r12, %rcx
addq %r13, %rcx
movq 0x80(%rax), %rax
movswl (%rax,%rcx,2), %ecx
movl 0x5c(%rbx), %eax
movl 0x60(%rbx), %edi
cmpl %ecx, %edi
jl 0x20de7
movl %ecx, %edi
cmpl %ecx, %eax
cmovgl %eax, %edi
andl %r15d, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
incq %r13
cmpl %r13d, %ebp
jne 0x20d58
incl %r14d
cmpl 0x4(%rsp), %r14d
jne 0x20d48
jmp 0x21041
leaq 0x68a2(%rip), %rsi      # 0x276c1
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
movl %r12d, %ecx
movl $0xff, %r8d
xorl %eax, %eax
callq 0x33f0
testl %r12d, %r12d
jle 0x21041
movl 0x10(%rsp), %eax
movq %rax, 0x10(%rsp)
cmpl $0x0, (%rsp)
jle 0x20fca
xorl %r13d, %r13d
movl $0x24, %r14d
movq 0x10(%rsp), %r15
movq (%rbx), %rax
leaq (%rax,%r14), %rcx
movl -0xc(%rax,%r14), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq -0x24(%rax,%r14), %rsi
movq -0x1c(%rax,%r14), %rax
subq %rsi, %rax
sarq %rax
cmpq %rdx, %rax
leaq (%rsi,%rdx,2), %rax
cmovbeq %rcx, %rax
movswl (%rax), %eax
xorl %r12d, %r12d
movl $0x0, %edi
cmpl $-0x15, %eax
jl 0x20ecd
movl $0xff, %edi
cmpl $0x156a, %eax           # imm = 0x156A
jg 0x20ecd
movl %eax, %ecx
shll $0x8, %ecx
subl %eax, %ecx
movslq %ecx, %rdi
imulq $-0x3ffcfff3, %rdi, %rax # imm = 0xC003000D
shrq $0x20, %rax
addl %eax, %edi
movl %edi, %eax
shrl $0x1f, %eax
sarl $0xc, %edi
addl %eax, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
leaq (%rax,%r14), %rcx
movl -0xc(%rax,%r14), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq -0x24(%rax,%r14), %rsi
movq -0x1c(%rax,%r14), %rax
subq %rsi, %rax
sarq %rax
cmpq %rdx, %rax
leaq (%rsi,%rdx,2), %rax
cmovbeq %rcx, %rax
movswl (%rax), %eax
cmpl $-0x6d, %eax
jl 0x20f3d
movl $0xff, %r12d
cmpl $0x6d38, %eax           # imm = 0x6D38
jg 0x20f3d
imull $0x32, %eax, %eax
movslq %eax, %r12
imulq $-0x3ffcfff3, %r12, %rax # imm = 0xC003000D
shrq $0x20, %rax
addl %eax, %r12d
movl %r12d, %eax
shrl $0x1f, %eax
sarl $0xc, %r12d
addl %eax, %r12d
movl %r12d, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
movq (%rbx), %rax
leaq (%rax,%r14), %rcx
movl -0xc(%rax,%r14), %edx
imull %ebp, %edx
addl %r13d, %edx
movslq %edx, %rdx
movq -0x24(%rax,%r14), %rsi
movq -0x1c(%rax,%r14), %rax
subq %rsi, %rax
sarq %rax
cmpq %rdx, %rax
leaq (%rsi,%rdx,2), %rax
cmovbeq %rcx, %rax
movswl (%rax), %eax
xorl %edi, %edi
cmpl $0xfffffe39, %eax       # imm = 0xFFFFFE39
jl 0x20fa6
shll $0x2, %eax
leal (%rax,%rax,2), %eax
movslq %eax, %rdi
imulq $-0x3ffcfff3, %rdi, %rax # imm = 0xC003000D
shrq $0x20, %rax
addl %eax, %edi
movl %edi, %eax
shrl $0x1f, %eax
sarl $0xc, %edi
addl %eax, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
addq $0x40, %r14
decq %r15
jne 0x20e60
incl %r13d
cmpl (%rsp), %r13d
jne 0x20e55
incl %ebp
cmpl 0x4(%rsp), %ebp
jne 0x20e48
jmp 0x21041
testl %eax, %eax
jle 0x21041
movl %r15d, %r14d
xorl %r15d, %r15d
cmpl $0x0, (%rsp)
jle 0x21037
xorl %ebp, %ebp
movq %r14, %r12
xorl %r13d, %r13d
movq (%rbx), %rax
movl 0x18(%rax,%r13), %ecx
imull %r15d, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
movq (%rax,%r13), %rax
movswl (%rax,%rcx,2), %ecx
movl 0x60(%rbx), %eax
cmpl %ecx, %eax
jl 0x21012
movl %ecx, %eax
movl 0x5c(%rbx), %edx
cmpl %ecx, %edx
cmovgl %edx, %eax
movzbl %al, %edi
movq 0x8(%rsp), %rsi
callq 0x33a0
addq $0x40, %r13
decq %r12
jne 0x20ff0
incl %ebp
cmpl (%rsp), %ebp
jne 0x20fea
incl %r15d
cmpl 0x4(%rsp), %r15d
jne 0x20fe2
movq 0x8(%rsp), %rdi
callq 0x32a0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq