// File: /workspace/github_c_makefile_star2_O1/LenShustek[P]miditones/miditones.c
// Function: main
int main (int argc, char *argv[]) {
   int argno;
   char *filebasename;
   int basenamelen;
#define MAXPATH 120
   char filename[MAXPATH];

   printf ("MIDITONES V%s, (C) 2011-2021 Len Shustek\n", VERSION);
   if (argc == 1) {     // no arguments
      SayUsage (argv[0]);
      return 1; }

   argno = HandleOptions (argc, argv); // process options
   if (argno == 0) {
      fprintf (stderr, "\n*** No basefilename given\n\n");
      SayUsage (argv[0]);
      exit (4); }
   filebasename = argv[argno];
   
   // strip off trailing .mid or .MID extension if provided by user
   basenamelen = strlength(filebasename);
   if (basenamelen > 4 &&
         (charcmp (filebasename + basenamelen - 4, ".mid") ||
          charcmp (filebasename + basenamelen - 4, ".MID"))) {
      filebasename[basenamelen - 4] = 0; }

   if (logparse || loggen) { // open the log file
      miditones_strlcpy (filename, filebasename, MAXPATH);
      miditones_strlcat (filename, ".log", MAXPATH);
      logfile = fopen (filename, "w");
      if (!logfile) {
         fprintf (stderr, "Unable to open log file %s\n", filename);
         return 1; }
      fprintf (logfile, "MIDITONES V%s log file\n", VERSION);
      print_command_line(logfile, argc, argv); }
   if (loggen) {
      fprintf(logfile, "\nThere are %d independent time-ordered streams in this log file:\n", logparse ? 3 : 2);
      if (logparse) fprintf(logfile, " - the parsed MIDI events, marked with #\n");
      fprintf(logfile, " - the MIDI play/stop events being queued, announced with ->\n"
              " - the generated bytestream commands pulled from the queue, announced with <-\n\n"); }

   // open the input file
   miditones_strlcpy (filename, filebasename, MAXPATH);
   miditones_strlcat (filename, ".mid", MAXPATH);
   infile = fopen (filename, "rb");
   if (!infile) {
      fprintf (stderr, "Unable to open input file %s\n", filename);
      return 1; }

   // Read the whole input file into memory
   fseek (infile, 0, SEEK_END); // find its size
   buflen = ftell (infile);
   fseek (infile, 0, SEEK_SET);
   buffer = (byte *) malloc (buflen + 1);
   if (!buffer) {
      fprintf (stderr, "Unable to allocate %ld bytes for the file\n", buflen);
      return 1; }
   fread (buffer, buflen, 1, infile);
   fclose (infile);
   if (logparse) fprintf (logfile, "Processing %s, %ld bytes\n", filename, buflen);

   if (!parseonly) { // create the output file
      miditones_strlcpy (filename, filebasename, MAXPATH);
      if (binaryoutput) {
         miditones_strlcat (filename, ".bin", MAXPATH);
         outfile = fopen (filename, "wb"); }
      else {
         miditones_strlcat (filename,  asm_output ? (scorename ? ".inc" : ".asm") : (scorename ? ".h" : ".c"), MAXPATH);
         outfile = fopen (filename, "w"); }
      if (!outfile) {
         fprintf (stderr, "Unable to open output file %s\n", filename);
         return 1; }
      file_header.f1 = (volume_output ? HDR_F1_VOLUME_PRESENT : 0)
                       | (instrumentoutput ? HDR_F1_INSTRUMENTS_PRESENT : 0)
                       | (percussion_translate ? HDR_F1_PERCUSSION_PRESENT : 0);
      file_header.num_tgens = num_tonegens;
      if (!binaryoutput) {      /* create header of C file that initializes score data */
         time_t rawtime;
         time (&rawtime);
         fprintf (outfile, "%s Playtune bytestream for file \"%s.mid\" ", comment, filebasename);
         fprintf (outfile, "created by MIDITONES V%s on %s", VERSION,
                  asctime (localtime (&rawtime)));
         print_command_line (outfile, argc, argv);
         if (channel_mask != 0xffff)
            fprintf (outfile, "%s   Only the masked channels were processed: %04X\n", comment, channel_mask);
         if (keyshift != 0)
            fprintf (outfile, "%s   Keyshift was %d chromatic notes\n", comment, keyshift);
         if (define_progmem) {
            fprintf (outfile, "#ifdef __AVR__\n");
            fprintf (outfile, "#include <avr/pgmspace.h>\n");
            fprintf (outfile, "#else\n");
            fprintf (outfile, "#define PROGMEM\n");
            fprintf (outfile, "#endif\n"); }
         if (asm_output) // create the assembler label for the score
            fprintf(outfile, "\n%s:\n%s", filebasename, byteop);
         else fprintf (outfile, "const unsigned char PROGMEM %s [] = {\n",
                  scorename ? filebasename : "score");
         if (do_header) {       // write the initialization for the file header
            fprintf (outfile, "'P','t', 6, %s%02X, %s%02X, ", hex, file_header.f1, hex, file_header.f2);
            fflush (outfile);
            file_header_num_tgens_position = ftell (outfile);   // remember where the number of tone generators is
            fprintf (outfile, "%2d%s %s (Playtune file header)\n%s", file_header.num_tgens, asm_output ? "" : ",", comment, byteop);
            outfile_bytecount += 6; } }
      else if (do_header) {     // write the binary file header
         int i;
         for (i = 0; i < sizeof (file_header); ++i)
            fputc (((byte *) &file_header)[i], outfile);
         file_header_num_tgens_position = (char *) &file_header.num_tgens - (char *) &file_header;
         outfile_bytecount += sizeof (file_header); } }

   // process the MIDI file header
   hdrptr = buffer;   // point to the file and track headers
   process_file_header ();
   printf ("  Processing %d tracks.\n", num_tracks);
   if (num_tracks > MAX_TRACKS) midi_error ("Too many tracks", buffer);

   // initialize for processing of all the tracks
   tempo = DEFAULT_TEMPO;
   for (int tracknum = 0; tracknum < num_tracks; ++tracknum) {
      track[tracknum].tempo = DEFAULT_TEMPO;
      process_track_header (tracknum);
      find_next_note (tracknum);     /* position to the first note on/off */
      /* if we are in "parse only" mode, do the whole track,
         so we do them one at a time instead of time-synchronized. */
      if (parseonly)
         while (track[tracknum].cmd != CMD_TRACKDONE)
            find_next_note (tracknum); }
#if 0
   // TEMP test queuing routines
   show_queue_cmd(12, CMD_PLAYNOTE, 100);
   show_queue_cmd(12, CMD_PLAYNOTE, 101);
   show_queue_cmd(12, CMD_PLAYNOTE, 103);
   show_queue_cmd(20, CMD_STOPNOTE, 101);
   show_queue_cmd(15, CMD_STOPNOTE, 103);
   show_queue_cmd(21, CMD_PLAYNOTE, 104);
   show_queue_cmd(20, CMD_STOPNOTE, 100);
   show_queue_cmd(20, CMD_STOPNOTE, 104);
   show_queue_cmd(22, CMD_PLAYNOTE, 109);
   flush_queue();
#endif
   if (!parseonly) {

      process_track_data();    // do all the tracks interleaved, like a 1950's multiway merge

      // generate the ending commentary
      if (!binaryoutput) {
         fprintf(outfile, "\n%s This %ld byte score contains %d notes and uses %d tone generator%s.\n",
                 comment, outfile_bytecount, note_on_commands, num_tonegens_used,
                 num_tonegens_used == 1 ? "" : "s");
         fprintf(outfile, "%s It encodes %u.%03u seconds of music with %d tempo change%s.\n",
            comment, (unsigned)(timenow_usec / 1000000), (unsigned)(timenow_usec / 1000 % 1000),
            tempo_changes, tempo_changes == 1 ? "" : "s");
         if (notes_skipped)
            fprintf(outfile, "%s %d notes had to be skipped.\n", comment, notes_skipped); }
      printf("  %s %d tone generators were used.\n",
             num_tonegens_used < num_tonegens ? "Only" : "All", num_tonegens_used);
      if (notes_skipped)
         printf("  %d notes were skipped because there weren't enough tone generators.\n",
                notes_skipped);
      if (consecutive_delays)
         printf("  %d consecutive delays could be eliminated\n", consecutive_delays);
      if (events_delayed)
         printf("  %d \"stop note\" commands were delayed because the %d-element output queue is too small\n",
                events_delayed, QUEUE_SIZE);
      if (noteinfo_overflow + noteinfo_notfound > 0)
         printf("  %d notes couldn't be recorded in the track status, so then %d notes couldn't be found\n"
                "  (Consider recompiling with MAX_TRACKNOTES bigger than %d, to allow more simultaneous notes.)\n",
                noteinfo_overflow, noteinfo_notfound, MAX_CHANNELNOTES);
      printf("  %ld bytes of score data were generated, ", outfile_bytecount);
      printf("encoding %u.%03u seconds of music with %d tempo change%s.\n",
             (unsigned)(timenow_usec / 1000000), (unsigned)(timenow_usec / 1000 % 1000), 
             tempo_changes, tempo_changes == 1 ? "" : "s");
      if (delaymin_usec)
         printf("  %ld delays were removed because the minimum delay of  %u msec caused events to be merged\n",
                delays_saved, (unsigned)(delaymin_usec / 1000));
      if (loggen) {
         fprintf(logfile, "%d note-on commands, %d instrument changes.\n",
                 note_on_commands, instrument_changes);
         fprintf(logfile, "%d stop-notes without start-notes, %d start-notes without stop-notes\n",
                 stopnotes_without_playnotes, playnotes_without_stopnotes);
         if (attacktime_usec > 0) fprintf(logfile, "%d sustain phases done, and %d skipped because the notes were too short\n",
                                             sustainphases_done, sustainphases_skipped); }
      if (0 && do_header) {             // rewrite the file header with the actual number of tone generators used
         if (fseek(outfile, file_header_num_tgens_position, SEEK_SET) != 0)
            fprintf(stderr, "Can't seek to number of tone generators in the header\n");
         else {
            if (binaryoutput)
               putc(num_tonegens_used, outfile);
            else
               fprintf(outfile, "%2d", num_tonegens_used); } }
      fclose(outfile); }

   if (loggen || logparse)
      fclose (logfile);
   printf ("  Done.\n");
   return 0; }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movl %edi, %ebp
leaq 0x2300(%rip), %rdi      # 0x650c
leaq 0x2323(%rip), %rsi      # 0x6536
xorl %eax, %eax
callq 0x1080
cmpl $0x1, %ebp
je 0x4bd1
movl %ebp, %edi
movq %r14, %rsi
callq 0x154e
testl %eax, %eax
je 0x4c46
cltq
movq (%r14,%rax,8), %rbx
movq $-0x1, %rcx
cmpb $0x0, 0x1(%rbx,%rcx)
leaq 0x1(%rcx), %rcx
jne 0x4242
cmpq $0x5, %rcx
jb 0x42a5
movl %ecx, %eax
leaq (%rbx,%rax), %rdx
addq $-0x4, %rdx
xorl %esi, %esi
leaq 0xea4(%rip), %rdi       # 0x510a
movb (%rdx,%rsi), %r8b
cmpb (%rsi,%rdi), %r8b
jne 0x427b
incq %rsi
cmpq $0x4, %rsi
jne 0x4266
jmp 0x42a0
movl %ecx, %ecx
addq %rbx, %rcx
addq $-0x4, %rcx
xorl %edx, %edx
leaq 0x22ca(%rip), %rsi      # 0x6557
movb (%rcx,%rdx), %dil
cmpb (%rdx,%rsi), %dil
jne 0x42a5
incq %rdx
cmpq $0x4, %rdx
jne 0x428d
movb $0x0, -0x4(%rbx,%rax)
cmpb $0x0, 0x4f19(%rip)      # 0x91c5
jne 0x42bb
cmpb $0x1, 0x4f0e(%rip)      # 0x91c3
jne 0x4350
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0x77, %rcx
je 0x42de
movb (%rbx,%rax), %dl
movb %dl, 0x10(%rsp,%rax)
leaq 0x1(%rax), %rcx
testb %dl, %dl
jne 0x42bd
addq %rsp, %rcx
addq $0x10, %rcx
jmp 0x42e6
leaq (%rsp,%rax), %rcx
addq $0x10, %rcx
cmpq $0x77, %rax
jne 0x42ef
movb $0x0, (%rcx)
leaq 0xe7c(%rip), %rsi       # 0x5172
leaq 0x10(%rsp), %r15
movl $0x78, %edx
movq %r15, %rdi
callq 0x1ca8
leaq 0x224d(%rip), %rsi      # 0x655c
movq %r15, %rdi
callq 0x1120
movq %rax, 0x4eba(%rip)      # 0x91d8
testq %rax, %rax
je 0x4c01
leaq 0x224c(%rip), %rsi      # 0x657a
leaq 0x2201(%rip), %rdx      # 0x6536
movq %rax, %rdi
xorl %eax, %eax
callq 0x10b0
movq 0x4e92(%rip), %rdi      # 0x91d8
movl %ebp, %esi
movq %r14, %rdx
callq 0x1b0e
cmpb $0x1, 0x4e6c(%rip)      # 0x91c3
jne 0x43bb
movq 0x4e78(%rip), %rdi      # 0x91d8
movzbl 0x4e5e(%rip), %edx      # 0x91c5
orl $0x2, %edx
leaq 0x2221(%rip), %rsi      # 0x6592
xorl %eax, %eax
callq 0x10b0
cmpb $0x1, 0x4e46(%rip)      # 0x91c5
jne 0x439e
movq 0x4e50(%rip), %rcx      # 0x91d8
leaq 0x2245(%rip), %rdi      # 0x65d4
movl $0x29, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4e33(%rip), %rcx      # 0x91d8
leaq 0x2252(%rip), %rdi      # 0x65fe
movl $0x8c, %esi
movl $0x1, %edx
callq 0x1150
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0x77, %rcx
je 0x43de
movb (%rbx,%rax), %dl
movb %dl, 0x10(%rsp,%rax)
leaq 0x1(%rax), %rcx
testb %dl, %dl
jne 0x43bd
addq %rsp, %rcx
addq $0x10, %rcx
jmp 0x43e6
leaq (%rsp,%rax), %rcx
addq $0x10, %rcx
cmpq $0x77, %rax
jne 0x43ef
movb $0x0, (%rcx)
leaq 0xd14(%rip), %rsi       # 0x510a
leaq 0x10(%rsp), %r15
movl $0x78, %edx
movq %r15, %rdi
callq 0x1ca8
leaq 0x227c(%rip), %rsi      # 0x668b
movq %r15, %rdi
callq 0x1120
movq %rax, 0x78ea(%rip)      # 0xbd08
testq %rax, %rax
je 0x4bd8
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1110
movq 0x78cb(%rip), %rdi      # 0xbd08
callq 0x10c0
movq %rax, 0x4d9f(%rip)      # 0x91e8
movq 0x78b8(%rip), %rdi      # 0xbd08
xorl %esi, %esi
xorl %edx, %edx
callq 0x1110
movq 0x4d88(%rip), %r15      # 0x91e8
leaq 0x1(%r15), %rdi
callq 0x10e0
movq %rax, 0x4d70(%rip)      # 0x91e0
testq %rax, %rax
je 0x4beb
movq 0x7888(%rip), %rcx      # 0xbd08
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1050
movq 0x7871(%rip), %rdi      # 0xbd08
callq 0x1060
cmpb $0x1, 0x4d22(%rip)      # 0x91c5
jne 0x44c6
movq 0x4d2c(%rip), %rdi      # 0x91d8
movq 0x4d35(%rip), %rcx      # 0x91e8
leaq 0x221d(%rip), %rsi      # 0x66d7
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x10b0
cmpb $0x0, 0x4cf9(%rip)      # 0x91c6
jne 0x4853
xorl %ecx, %ecx
movq %rcx, %rax
cmpq $0x77, %rcx
je 0x44f6
movb (%rbx,%rax), %dl
movb %dl, 0x10(%rsp,%rax)
leaq 0x1(%rax), %rcx
testb %dl, %dl
jne 0x44d5
addq %rsp, %rcx
addq $0x10, %rcx
jmp 0x44fe
leaq (%rsp,%rax), %rcx
addq $0x10, %rcx
cmpq $0x77, %rax
jne 0x4507
movb $0x0, (%rcx)
cmpb $0x0, 0x4cb2(%rip)      # 0x91c0
je 0x4520
leaq 0x21df(%rip), %r15      # 0x66f6
leaq 0x21d3(%rip), %rsi      # 0x66f1
jmp 0x455d
leaq 0xc24(%rip), %rax       # 0x514b
leaq 0x21cb(%rip), %rcx      # 0x66f9
testb $0x1, 0x4c99(%rip)      # 0x91ce
cmovneq %rax, %rcx
leaq 0x21be(%rip), %rax      # 0x66fe
leaq 0x21ba(%rip), %rsi      # 0x6701
cmovneq %rax, %rsi
cmpb $0x0, 0x4c78(%rip)      # 0x91ca
cmovneq %rcx, %rsi
leaq 0x1fff(%rip), %r15      # 0x655c
leaq 0x10(%rsp), %r12
movl $0x78, %edx
movq %r12, %rdi
callq 0x1ca8
movq %r12, %rdi
movq %r15, %rsi
callq 0x1120
movq %rax, 0x4c6f(%rip)      # 0x91f0
testq %rax, %rax
je 0x4c14
movb 0x4c3b(%rip), %al       # 0x91cb
shlb $0x7, %al
movb 0x4c2b(%rip), %cl       # 0x91c4
shlb $0x6, %cl
orb %al, %cl
movb 0x4c24(%rip), %al       # 0x91c8
shlb $0x5, %al
orb %cl, %al
movb %al, 0x4b64(%rip)       # 0x9113
movb 0x4b37(%rip), %al       # 0x90ec
movb %al, 0x4b5a(%rip)       # 0x9115
cmpb $0x0, 0x4bfe(%rip)      # 0x91c0
je 0x4604
cmpb $0x1, 0x4bf6(%rip)      # 0x91c1
jne 0x4853
xorl %ebx, %ebx
leaq 0x4b36(%rip), %r14      # 0x9110
movzbl (%rbx,%r14), %edi
movq 0x4c0a(%rip), %rsi      # 0x91f0
callq 0x1090
incq %rbx
cmpq $0x6, %rbx
jne 0x45da
movq $0x5, 0x7711(%rip) # 0xbd10
jmp 0x484b
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x10d0
movq 0x4bd5(%rip), %rdi      # 0x91f0
movq 0x4aae(%rip), %rdx      # 0x90d0
leaq 0x20fa(%rip), %rsi      # 0x6723
movq %rbx, %rcx
xorl %eax, %eax
callq 0x10b0
movq 0x4bb6(%rip), %r12      # 0x91f0
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1070
leaq 0x20fc(%rip), %rsi      # 0x674d
leaq 0x1ede(%rip), %rdx      # 0x6536
movq %r12, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x10b0
movq 0x4b84(%rip), %rdi      # 0x91f0
movl %ebp, %esi
movq %r14, %rdx
callq 0x1b0e
movl 0x4a74(%rip), %ecx      # 0x90f0
cmpl $0xffff, %ecx           # imm = 0xFFFF
je 0x46a0
movq 0x4b65(%rip), %rdi      # 0x91f0
movq 0x4a3e(%rip), %rdx      # 0x90d0
leaq 0x20d3(%rip), %rsi      # 0x676c
xorl %eax, %eax
callq 0x10b0
movl 0x4ac6(%rip), %ecx      # 0x916c
testl %ecx, %ecx
je 0x46c6
movq 0x4b3f(%rip), %rdi      # 0x91f0
movq 0x4a18(%rip), %rdx      # 0x90d0
leaq 0x20e1(%rip), %rsi      # 0x67a0
xorl %eax, %eax
callq 0x10b0
cmpb $0x1, 0x4af5(%rip)      # 0x91c2
jne 0x4764
movq 0x4b16(%rip), %rcx      # 0x91f0
leaq 0x20e5(%rip), %rdi      # 0x67c6
movl $0xf, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4af9(%rip), %rcx      # 0x91f0
leaq 0x20d8(%rip), %rdi      # 0x67d6
movl $0x1a, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4adc(%rip), %rcx      # 0x91f0
leaq 0x20d6(%rip), %rdi      # 0x67f1
movl $0x6, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4abf(%rip), %rcx      # 0x91f0
leaq 0x20c0(%rip), %rdi      # 0x67f8
movl $0x10, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4aa2(%rip), %rcx      # 0x91f0
leaq 0x20b4(%rip), %rdi      # 0x6809
movl $0x7, %esi
movl $0x1, %edx
callq 0x1150
movq 0x4a85(%rip), %rdi      # 0x91f0
cmpb $0x1, 0x4a58(%rip)      # 0x91ca
jne 0x478e
movq 0x4965(%rip), %rcx      # 0x90e0
leaq 0x208f(%rip), %rsi      # 0x6811
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10b0
jmp 0x47ae
leaq 0x20ab(%rip), %rdx      # 0x6840
cmpb $0x0, 0x4a32(%rip)      # 0x91ce
cmovneq %rbx, %rdx
leaq 0x2072(%rip), %rsi      # 0x6819
xorl %eax, %eax
callq 0x10b0
cmpb $0x1, 0x4a0c(%rip)      # 0x91c1
jne 0x4853
movq 0x4a2e(%rip), %rdi      # 0x91f0
movq 0x490f(%rip), %rdx      # 0x90d8
movzbl 0x4943(%rip), %ecx      # 0x9113
movzbl 0x493c(%rip), %r9d      # 0x9114
leaq 0x2067(%rip), %rsi      # 0x6846
movq %rdx, %r8
xorl %eax, %eax
callq 0x10b0
movq 0x4a00(%rip), %rdi      # 0x91f0
callq 0x10f0
movq 0x49f4(%rip), %rdi      # 0x91f0
callq 0x10c0
movq %rax, 0x7508(%rip)      # 0xbd10
movq 0x49e1(%rip), %rdi      # 0x91f0
movzbl 0x48ff(%rip), %edx      # 0x9115
leaq 0x1e6d(%rip), %rax      # 0x668a
leaq 0x2062(%rip), %rcx      # 0x6886
cmpb $0x0, 0x499f(%rip)      # 0x91ca
cmovneq %rax, %rcx
movq 0x489a(%rip), %r8       # 0x90d0
movq 0x48a3(%rip), %r9       # 0x90e0
leaq 0x201f(%rip), %rsi      # 0x6863
xorl %eax, %eax
callq 0x10b0
addq $0x6, 0x4935(%rip)      # 0x9188
movq 0x4986(%rip), %rax      # 0x91e0
movq %rax, 0x748f(%rip)      # 0xbcf0
callq 0x30e4
movl 0x748c(%rip), %esi      # 0xbcf8
leaq 0x2015(%rip), %rdi      # 0x6888
xorl %eax, %eax
callq 0x1080
cmpl $0x19, 0x7477(%rip)     # 0xbcf8
jge 0x4c4b
movq $0x7a120, 0x746e(%rip) # imm = 0x7A120
cmpl $0x0, 0x745f(%rip)      # 0xbcf8
jle 0x48ee
xorl %ebx, %ebx
leaq 0x4b1c(%rip), %r14      # 0x93c0
leaq (%rbx,%rbx,2), %r15
shlq $0x4, %r15
movq $0x7a120, 0x18(%r15,%r14) # imm = 0x7A120
movl %ebx, %edi
callq 0x321f
movl %ebx, %edi
callq 0x3336
cmpb $0x1, 0x48fc(%rip)      # 0x91c6
jne 0x48df
addq %r14, %r15
cmpb $-0x1, 0x24(%r15)
je 0x48df
movl %ebx, %edi
callq 0x3336
jmp 0x48cf
incq %rbx
movslq 0x740f(%rip), %rax      # 0xbcf8
cmpq %rax, %rbx
jl 0x48a4
cmpb $0x0, 0x48d1(%rip)      # 0x91c6
jne 0x4ba3
callq 0x3c87
cmpb $0x0, 0x48b9(%rip)      # 0x91c0
jne 0x49e0
movq 0x48dc(%rip), %rdi      # 0x91f0
movq 0x47b5(%rip), %rdx      # 0x90d0
movq 0x4866(%rip), %rcx      # 0x9188
movl 0x4817(%rip), %r8d      # 0x9140
movl 0x4808(%rip), %r9d      # 0x9138
cmpl $0x1, %r9d
leaq 0x1d4f(%rip), %r14      # 0x668a
leaq 0x1f42(%rip), %rbx      # 0x6884
movq %rbx, %rax
cmoveq %r14, %rax
movq %rax, (%rsp)
leaq 0x1f5d(%rip), %rsi      # 0x68b1
xorl %eax, %eax
callq 0x10b0
movq 0x488e(%rip), %rdi      # 0x91f0
movq 0x4767(%rip), %rdx      # 0x90d0
movl 0x4829(%rip), %eax      # 0x9198
imulq $0x431bde83, %rax, %rcx # imm = 0x431BDE83
shrq $0x32, %rcx
imulq $0x10624dd3, %rax, %r8  # imm = 0x10624DD3
shrq $0x26, %r8
imulq $0x83126f, %r8, %rax    # imm = 0x83126F
shrq $0x21, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r8d
movl 0x4810(%rip), %r9d      # 0x91b0
cmpl $0x1, %r9d
cmoveq %r14, %rbx
movq %rbx, (%rsp)
leaq 0x1f47(%rip), %rsi      # 0x68fa
xorl %eax, %eax
callq 0x10b0
movl 0x4784(%rip), %ecx      # 0x9144
testl %ecx, %ecx
je 0x49e0
movq 0x4825(%rip), %rdi      # 0x91f0
movq 0x46fe(%rip), %rdx      # 0x90d0
leaq 0x1f61(%rip), %rsi      # 0x693a
xorl %eax, %eax
callq 0x10b0
movl 0x4752(%rip), %edx      # 0x9138
cmpl 0x4700(%rip), %edx      # 0x90ec
leaq 0x1f8b(%rip), %rax      # 0x697e
leaq 0x1f89(%rip), %rsi      # 0x6983
cmovlq %rax, %rsi
leaq 0x1f55(%rip), %rdi      # 0x695a
xorl %eax, %eax
callq 0x1080
movl 0x4732(%rip), %esi      # 0x9144
testl %esi, %esi
je 0x4a24
leaq 0x1f6a(%rip), %rdi      # 0x6987
xorl %eax, %eax
callq 0x1080
movl 0x4732(%rip), %esi      # 0x915c
testl %esi, %esi
je 0x4a3c
leaq 0x1f99(%rip), %rdi      # 0x69ce
xorl %eax, %eax
callq 0x1080
movl 0x4706(%rip), %esi      # 0x9148
testl %esi, %esi
je 0x4a59
leaq 0x1fae(%rip), %rdi      # 0x69fb
movl $0x64, %edx
xorl %eax, %eax
callq 0x1080
movl 0x4705(%rip), %esi      # 0x9164
movl 0x4703(%rip), %edx      # 0x9168
movl %edx, %eax
addl %esi, %eax
jle 0x4a7e
leaq 0x1fe2(%rip), %rdi      # 0x6a54
movl $0x10, %ecx
xorl %eax, %eax
callq 0x1080
movq 0x4703(%rip), %rsi      # 0x9188
leaq 0x2080(%rip), %rdi      # 0x6b0c
xorl %eax, %eax
callq 0x1080
movl 0x46ff(%rip), %eax      # 0x9198
imulq $0x431bde83, %rax, %rsi # imm = 0x431BDE83
shrq $0x32, %rsi
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
shrq $0x26, %rdx
imulq $0x83126f, %rdx, %rax   # imm = 0x83126F
shrq $0x21, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %edx
movl 0x46e8(%rip), %ecx      # 0x91b0
cmpl $0x1, %ecx
leaq 0x1bb8(%rip), %rax      # 0x668a
leaq 0x1dab(%rip), %r8       # 0x6884
cmoveq %rax, %r8
leaq 0x2053(%rip), %rdi      # 0x6b37
xorl %eax, %eax
callq 0x1080
movq 0x467e(%rip), %rax      # 0x9170
testq %rax, %rax
je 0x4b21
movq 0x46ba(%rip), %rsi      # 0x91b8
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
mulq %rcx
shrq $0x4, %rdx
leaq 0x2058(%rip), %rdi      # 0x6b72
xorl %eax, %eax
callq 0x1080
cmpb $0x1, 0x469b(%rip)      # 0x91c3
jne 0x4b97
movq 0x46a7(%rip), %rdi      # 0x91d8
movl 0x4609(%rip), %edx      # 0x9140
movl 0x45ff(%rip), %ecx      # 0x913c
leaq 0x208a(%rip), %rsi      # 0x6bce
xorl %eax, %eax
callq 0x10b0
movq 0x4686(%rip), %rdi      # 0x91d8
movl 0x45f4(%rip), %edx      # 0x914c
movl 0x45f2(%rip), %ecx      # 0x9150
leaq 0x2096(%rip), %rsi      # 0x6bfb
xorl %eax, %eax
callq 0x10b0
cmpq $0x0, 0x460c(%rip)      # 0x9180
je 0x4b97
movq 0x465b(%rip), %rdi      # 0x91d8
movl 0x45d5(%rip), %edx      # 0x9158
movl 0x45cb(%rip), %ecx      # 0x9154
leaq 0x20b1(%rip), %rsi      # 0x6c41
xorl %eax, %eax
callq 0x10b0
movq 0x4652(%rip), %rdi      # 0x91f0
callq 0x1060
cmpb $0x0, 0x4619(%rip)      # 0x91c3
jne 0x4bb5
cmpb $0x1, 0x4612(%rip)      # 0x91c5
jne 0x4bc1
movq 0x461c(%rip), %rdi      # 0x91d8
callq 0x1060
leaq 0x20c2(%rip), %rdi      # 0x6c8a
callq 0x1040
xorl %eax, %eax
jmp 0x4c36
callq 0x12a7
jmp 0x4c31
movq 0x4419(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x1aa5(%rip), %rsi      # 0x668e
jmp 0x4c25
movq 0x4406(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x1ab0(%rip), %rsi      # 0x66ac
movq %r15, %rdx
jmp 0x4c2a
movq 0x43f0(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x194c(%rip), %rsi      # 0x655e
jmp 0x4c25
movq 0x43dd(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x1adf(%rip), %rsi      # 0x6704
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x10b0
movl $0x1, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x127d
movq 0x458e(%rip), %rsi      # 0x91e0
leaq 0x1c48(%rip), %rdi      # 0x68a1
callq 0x1b89