// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/avilib.c
// Function: avi_update_header
int avi_update_header(avi_t *AVI)
{
   int njunk, sampsize, hasIndex, ms_per_frame, frate, flag;
   int movi_len, hdrl_start, strl_start, j;
   unsigned char AVI_header[HEADERBYTES];
   long nhb;

   //assume max size
   movi_len = AVI_MAX_LEN - HEADERBYTES + 4;

   //assume index will be written
   hasIndex=1;

   if(AVI->fps < 0.001) {
     frate=0;
     ms_per_frame=0;
   } else {
     frate = (int) (FRAME_RATE_SCALE*AVI->fps + 0.5);
     ms_per_frame=(int) (1000000/AVI->fps + 0.5);
   }

   /* Prepare the file header */

   nhb = 0;

   /* The RIFF header */

   OUT4CC ("RIFF");
   OUTLONG(movi_len);    // assume max size
   OUT4CC ("AVI ");

   /* Start the header list */

   OUT4CC ("LIST");
   OUTLONG(0);        /* Length of list in bytes, don't know yet */
   hdrl_start = nhb;  /* Store start position */
   OUT4CC ("hdrl");

   /* The main AVI header */

   /* The Flags in AVI File header */

#define AVIF_HASINDEX           0x00000010      /* Index at end of file */
#define AVIF_MUSTUSEINDEX       0x00000020
#define AVIF_ISINTERLEAVED      0x00000100
#define AVIF_TRUSTCKTYPE        0x00000800      /* Use CKType to find key frames */
#define AVIF_WASCAPTUREFILE     0x00010000
#define AVIF_COPYRIGHTED        0x00020000

   OUT4CC ("avih");
   OUTLONG(56);                 /* # of bytes to follow */
   OUTLONG(ms_per_frame);       /* Microseconds per frame */
   //ThOe ->0
   //   OUTLONG(10000000);           /* MaxBytesPerSec, I hope this will never be used */
   OUTLONG(0);
   OUTLONG(0);                  /* PaddingGranularity (whatever that might be) */
                                /* Other sources call it 'reserved' */
   flag = AVIF_ISINTERLEAVED;
   if(hasIndex) flag |= AVIF_HASINDEX;
   if(hasIndex && AVI->must_use_index) flag |= AVIF_MUSTUSEINDEX;
   OUTLONG(flag);               /* Flags */
   OUTLONG(0);                  // no frames yet
   OUTLONG(0);                  /* InitialFrames */

   OUTLONG(AVI->anum+1);

   OUTLONG(0);                  /* SuggestedBufferSize */
   OUTLONG(AVI->width);         /* Width */
   OUTLONG(AVI->height);        /* Height */
                                /* MS calls the following 'reserved': */
   OUTLONG(0);                  /* TimeScale:  Unit used to measure time */
   OUTLONG(0);                  /* DataRate:   Data rate of playback     */
   OUTLONG(0);                  /* StartTime:  Starting time of AVI data */
   OUTLONG(0);                  /* DataLength: Size of AVI data chunk    */


   /* Start the video stream list ---------------------------------- */

   OUT4CC ("LIST");
   OUTLONG(0);        /* Length of list in bytes, don't know yet */
   strl_start = nhb;  /* Store start position */
   OUT4CC ("strl");

   /* The video stream header */

   OUT4CC ("strh");
   OUTLONG(56);                 /* # of bytes to follow */
   OUT4CC ("vids");             /* Type */
   OUT4CC (AVI->compressor);    /* Handler */
   OUTLONG(0);                  /* Flags */
   OUTLONG(0);                  /* Reserved, MS says: wPriority, wLanguage */
   OUTLONG(0);                  /* InitialFrames */
   OUTLONG(FRAME_RATE_SCALE);              /* Scale */
   OUTLONG(frate);              /* Rate: Rate/Scale == samples/second */
   OUTLONG(0);                  /* Start */
   OUTLONG(0);                  // no frames yet
   OUTLONG(0);                  /* SuggestedBufferSize */
   OUTLONG(-1);                 /* Quality */
   OUTLONG(0);                  /* SampleSize */
   OUTLONG(0);                  /* Frame */
   OUTLONG(0);                  /* Frame */
   //   OUTLONG(0);                  /* Frame */
   //OUTLONG(0);                  /* Frame */

   /* The video stream format */

   OUT4CC ("strf");
   OUTLONG(40);                 /* # of bytes to follow */
   OUTLONG(40);                 /* Size */
   OUTLONG(AVI->width);         /* Width */
   OUTLONG(AVI->height);        /* Height */
   OUTSHRT(1); OUTSHRT(24);     /* Planes, Count */
   OUT4CC (AVI->compressor);    /* Compression */
   // ThOe (*3)
   OUTLONG(AVI->width*AVI->height*3);  /* SizeImage (in bytes?) */
   OUTLONG(0);                  /* XPelsPerMeter */
   OUTLONG(0);                  /* YPelsPerMeter */
   OUTLONG(0);                  /* ClrUsed: Number of colors used */
   OUTLONG(0);                  /* ClrImportant: Number of colors important */

   /* Finish stream list, i.e. put number of bytes in the list to proper pos */

   long2str(AVI_header+strl_start-4,nhb-strl_start);


   /* Start the audio stream list ---------------------------------- */

   for(j=0; j<AVI->anum; ++j) {

       sampsize = avi_sampsize(AVI, j);

       OUT4CC ("LIST");
       OUTLONG(0);        /* Length of list in bytes, don't know yet */
       strl_start = nhb;  /* Store start position */
       OUT4CC ("strl");

       /* The audio stream header */

       OUT4CC ("strh");
       OUTLONG(56);            /* # of bytes to follow */
       OUT4CC ("auds");

       // -----------
       // ThOe
       OUTLONG(0);             /* Format (Optionally) */
       // -----------

       OUTLONG(0);             /* Flags */
       OUTLONG(0);             /* Reserved, MS says: wPriority, wLanguage */
       OUTLONG(0);             /* InitialFrames */

       // ThOe /4
       OUTLONG(sampsize/4);      /* Scale */
       OUTLONG(1000*AVI->track[j].mp3rate/8);
       OUTLONG(0);             /* Start */
       OUTLONG(4*AVI->track[j].audio_bytes/sampsize);   /* Length */
       OUTLONG(0);             /* SuggestedBufferSize */
       OUTLONG(-1);            /* Quality */

       // ThOe /4
       OUTLONG(sampsize/4);    /* SampleSize */

       OUTLONG(0);             /* Frame */
       OUTLONG(0);             /* Frame */
       //       OUTLONG(0);             /* Frame */
       //OUTLONG(0);             /* Frame */

       /* The audio stream format */

       OUT4CC ("strf");
       OUTLONG(16);                   /* # of bytes to follow */
       OUTSHRT(AVI->track[j].a_fmt);           /* Format */
       OUTSHRT(AVI->track[j].a_chans);         /* Number of channels */
       OUTLONG(AVI->track[j].a_rate);          /* SamplesPerSec */
       // ThOe
       OUTLONG(1000*AVI->track[j].mp3rate/8);
       //ThOe (/4)

       OUTSHRT(sampsize/4);           /* BlockAlign */


       OUTSHRT(AVI->track[j].a_bits);          /* BitsPerSample */

       /* Finish stream list, i.e. put number of bytes in the list to proper pos */

       long2str(AVI_header+strl_start-4,nhb-strl_start);
   }

   /* Finish header list */

   long2str(AVI_header+hdrl_start-4,nhb-hdrl_start);


   /* Calculate the needed amount of junk bytes, output junk */

   njunk = HEADERBYTES - nhb - 8 - 12;

   /* Safety first: if njunk <= 0, somebody has played with
      HEADERBYTES without knowing what (s)he did.
      This is a fatal error */

   if(njunk<=0)
     {
       fprintf(stderr,"AVI_close_output_file: # of header bytes too small\n");
       exit(1);
     }

   OUT4CC ("JUNK");
   OUTLONG(njunk);
   memset(AVI_header+nhb,0,njunk);

   //2001-11-14 added id string

   if((size_t)njunk > strlen(id_str)+8) {
     //sprintf(id_str, "%s-%s", PACKAGE, VERSION);
     //memcpy(AVI_header+nhb, id_str, strlen(id_str));
   }

   nhb += njunk;

   /* Start the movi list */

   OUT4CC ("LIST");
   OUTLONG(movi_len); /* Length of list in bytes */
   OUT4CC ("movi");

   /* Output the header, truncate the file to the number of bytes
      actually written, report an error if someting goes wrong */

   if ( lseek(AVI->fdes,0,SEEK_SET)<0 ||
        avi_write(AVI->fdes,(char *)AVI_header,HEADERBYTES)!=HEADERBYTES ||
	lseek(AVI->fdes,AVI->pos,SEEK_SET)<0)
     {
       AVI_errno = AVI_ERR_CLOSE;
       return -1;
     }

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x850, %rsp            # imm = 0x850
movq %rdi, -0x10(%rbp)
movl $0xfefff003, -0x2c(%rbp) # imm = 0xFEFFF003
movl $0x1, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movsd 0xe147f(%rip), %xmm0    # 0x4e3008
ucomisd 0x20(%rax), %xmm0
jbe 0x401ba0
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
jmp 0x401bec
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd 0xe1467(%rip), %xmm1    # 0x4e3018
mulsd %xmm1, %xmm0
movsd 0xe1453(%rip), %xmm1    # 0x4e3010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movsd 0xe1444(%rip), %xmm0    # 0x4e3018
divsd 0x20(%rax), %xmm0
movsd 0xe142f(%rip), %xmm1    # 0x4e3010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x20(%rbp)
movq $0x0, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401c18
movq -0x848(%rbp), %rax
movl 0xe143b(%rip), %ecx     # 0x4e304c
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401c4d
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401c80
movq -0x848(%rbp), %rax
movl 0xe13d8(%rip), %ecx     # 0x4e3051
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401cb3
movq -0x848(%rbp), %rax
movl 0xe13aa(%rip), %ecx     # 0x4e3056
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401ce7
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
movq -0x848(%rbp), %rax
movl %eax, -0x30(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401d24
movq -0x848(%rbp), %rax
movl 0xe133e(%rip), %ecx     # 0x4e305b
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401d57
movq -0x848(%rbp), %rax
movl 0xe1310(%rip), %ecx     # 0x4e3060
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401d8e
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x38, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401dc3
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401df7
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401e2b
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
movl $0x100, -0x28(%rbp)     # imm = 0x100
cmpl $0x0, -0x1c(%rbp)
je 0x401e53
movl -0x28(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x401e6f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x428(%rax)
je 0x401e6f
movl -0x28(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x28(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401e92
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401ec6
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401efa
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401f39
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x438(%rax), %esi
addl $0x1, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401f6d
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401fa9
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x401fe5
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402019
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40204d
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402081
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4020b5
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4020e8
movq -0x848(%rbp), %rax
movl 0xe0f75(%rip), %ecx     # 0x4e3056
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40211c
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
movq -0x848(%rbp), %rax
movl %eax, -0x34(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402159
movq -0x848(%rbp), %rax
movl 0xe0f13(%rip), %ecx     # 0x4e3065
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40218c
movq -0x848(%rbp), %rax
movl 0xe0ee5(%rip), %ecx     # 0x4e306a
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4021c3
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x38, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4021f6
movq -0x848(%rbp), %rax
movl 0xe0e80(%rip), %ecx     # 0x4e306f
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40222a
movq -0x848(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x28(%rcx), %ecx
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40225e
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402292
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4022c6
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4022fd
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402332
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402366
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40239a
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4023ce
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402405
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402439
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40246d
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4024a1
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4024d4
movq -0x848(%rbp), %rax
movl 0xe0ba7(%rip), %ecx     # 0x4e3074
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40250b
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x28, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402542
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x28, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40257e
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4025ba
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x4025f7
movq -0x848(%rbp), %rax
movb $0x1, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
movb $0x0, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x402634
movq -0x848(%rbp), %rax
movb $0x18, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
movb $0x0, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402668
movq -0x848(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x28(%rcx), %ecx
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4026b1
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
imulq 0x18(%rcx), %rax
imulq $0x3, %rax, %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4026e5
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402719
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40274d
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402781
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
leaq -0x840(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
addq $-0x4, %rdi
movq -0x848(%rbp), %rax
movslq -0x34(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x4032e0
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x438(%rcx), %eax
jge 0x402f44
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x403340
movl %eax, -0x18(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402804
movq -0x848(%rbp), %rax
movl 0xe0859(%rip), %ecx     # 0x4e3056
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402838
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
movq -0x848(%rbp), %rax
movl %eax, -0x34(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402875
movq -0x848(%rbp), %rax
movl 0xe07f7(%rip), %ecx     # 0x4e3065
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4028a8
movq -0x848(%rbp), %rax
movl 0xe07c9(%rip), %ecx     # 0x4e306a
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4028df
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x38, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402912
movq -0x848(%rbp), %rax
movl 0xe076e(%rip), %ecx     # 0x4e3079
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402946
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40297a
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4029ae
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4029e2
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402a21
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402a7a
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
imulq $0x3e8, 0x20(%rax), %rax # imm = 0x3E8
movl $0x8, %ecx
cqto
idivq %rcx
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402aae
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402b06
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rax
shlq $0x2, %rax
movslq -0x18(%rbp), %rcx
cqto
idivq %rcx
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402b3a
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402b71
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402bb0
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402be4
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402c18
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
xorl %esi, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402c4b
movq -0x848(%rbp), %rax
movl 0xe0430(%rip), %ecx     # 0x4e3074
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402c82
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl $0x10, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x402cfd
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x840(%rbp,%rax)
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x402d7a
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x840(%rbp,%rax)
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402dc5
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402e1e
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
imulq $0x3e8, 0x20(%rax), %rax # imm = 0x3E8
movl $0x8, %ecx
cqto
idivq %rcx
movl %eax, %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x402e80
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
andl $0xff, %eax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x840(%rbp,%rax)
movl -0x18(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fe, -0x848(%rbp) # imm = 0x7FE
jg 0x402efd
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x840(%rbp,%rax)
movq -0x10(%rbp), %rax
addq $0x60, %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x848(%rbp), %rax
movb %cl, -0x83f(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x848(%rbp)
leaq -0x840(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
addq $-0x4, %rdi
movq -0x848(%rbp), %rax
movslq -0x34(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x4032e0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x4027c1
leaq -0x840(%rbp), %rdi
movslq -0x30(%rbp), %rax
addq %rax, %rdi
addq $-0x4, %rdi
movq -0x848(%rbp), %rax
movslq -0x30(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x4032e0
movl $0x800, %eax            # imm = 0x800
subq -0x848(%rbp), %rax
subq $0x8, %rax
subq $0xc, %rax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jg 0x402faa
movq $0x526c68, %rax         # imm = 0x526C68
movq (%rax), %rdi
leaq 0xe00e5(%rip), %rsi     # 0x4e307e
movb $0x0, %al
callq 0x435870
movl $0x1, %edi
callq 0x434710
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x402fcb
movq -0x848(%rbp), %rax
movl 0xe00ee(%rip), %ecx     # 0x4e30b2
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x403000
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movslq -0x14(%rbp), %rdx
xorl %esi, %esi
callq 0x4010e0
movslq -0x14(%rbp), %rax
movq %rax, -0x850(%rbp)
leaq 0x125903(%rip), %rdi    # 0x528940
callq 0x401138
movq %rax, %rcx
movq -0x850(%rbp), %rax
addq $0x8, %rcx
cmpq %rcx, %rax
jbe 0x403057
jmp 0x403057
movslq -0x14(%rbp), %rax
addq -0x848(%rbp), %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x40308a
movq -0x848(%rbp), %rax
movl 0xdffd3(%rip), %ecx     # 0x4e3056
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4030bf
leaq -0x840(%rbp), %rdi
addq -0x848(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4032e0
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
cmpq $0x7fc, -0x848(%rbp) # imm = 0x7FC
jg 0x4030f2
movq -0x848(%rbp), %rax
movl 0xdffcc(%rip), %ecx     # 0x4e30b7
movl %ecx, -0x840(%rbp,%rax)
movq -0x848(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x848(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x48fba0
cmpq $0x0, %rax
jl 0x403161
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
leaq -0x840(%rbp), %rsi
movl $0x800, %edx            # imm = 0x800
callq 0x401a30
cmpq $0x800, %rax            # imm = 0x800
jne 0x403161
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
movq -0x10(%rbp), %rax
movq 0x3e0(%rax), %rsi
xorl %edx, %edx
callq 0x48fba0
cmpq $0x0, %rax
jge 0x403175
movq $0x6, 0x1257c4(%rip) # 0x528930
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x40317c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x850, %rsp            # imm = 0x850
popq %rbp
retq
nopl (%rax,%rax)