// File: mikeakohn[P]drumsplusplus/build/../src/Song.cxx
// Function: Song::parse_pattern(Tokens*)
int Song::parse_pattern(Tokens *tokens)
{
  int token_type;
  char token[1024], token1[1024];
  Beat beats[256];
  int ptr;
  char value[1024];
  float low_beat = 0;
  float next_beat = 0;
  int i, count, num_notes;
  int beat_time;
  int time_signature_beats;
  //int time_signature_base;
  int midi_channel;

  beat_time = 60000000 / song_info.bpm;
  time_signature_beats = song_info.time_signature_beats;
  //time_signature_base = song_info.time_signature_base;
  midi_channel = song_info.midi_channel;

  token_type = tokens->get(token);

  if (token_type != TOKEN_ALPHA)
  {
    printf("Error: Pattern is not alphanumeric at %s:%d\n",
      tokens->get_filename(), tokens->get_line());
    return -1;
  }

  if (patterns.find(token) != patterns.end())
  {
    printf("Error: Pattern %s is already defined at %s:%d\n",
      token, tokens->get_filename(), tokens->get_line());
    return -1;
  }

  std::string pattern_name = token;

  const int index = patterns.size();
  Pattern &pattern = patterns[pattern_name];

  pattern_names[index] = token;

  pattern.set_name(pattern_name);
  pattern.set_index(index);

#ifdef DEBUG
printf("parsing pattern: %s %d\n", token, index);
#endif

  token_type = tokens->get(token);

  if (strcmp(token, "{") != 0)
  {
    print_error(tokens, "{", token);
    return -1;
  }

  ptr = 0;
  num_notes = 0;

  while(1)
  {
    token_type = tokens->get(token);

    if (strcmp(token, "}") == 0) { break;}

    // Check if there are some modifications to the global song values.
    if (strcmp(token, "set") == 0)
    {
      token_type = tokens->get(token);

      if (token_type != TOKEN_ALPHA)
      {
        print_error(tokens, "variable to set", token);
        return -1;
      }

      token_type = tokens->get(token1);

      if (strcmp(token1, "=") != 0)
      {
        print_error(tokens, "=", token1);
        return -1;
      }

      token_type = tokens->get(token1);

      if (token_type != TOKEN_NUMBER)
      {
        print_error(tokens, "a number", token1);
        return -1;
      }

      i = atoi(token1);

      if (i == 0)
      {
        print_error(tokens, "a non-zero integer", token1);
        return -1;
      }

      if (strcmp(token, "bpm") == 0)
      {
        beat_time = 60000000 / i;
      }
        else
      if (strcmp(token, "timesignature") == 0)
      {
        time_signature_beats = i;

        token_type = tokens->get(token1);

        if (strcmp(token1, "/") != 0)
        {
          print_error(tokens, "/", token1);
          return -1;
        }

        token_type = tokens->get(token1);

        if (token_type != TOKEN_NUMBER)
        {
          print_error(tokens, "a number", token1);
          return -1;
        }

        i = atoi(token1);

        if (i == 0)
        {
          print_error(tokens, "a non-zero integer", token1);
          return -1;
        }

        //time_signature_base = i;
      }
        else
      if (strcmp(token, "midi_channel") == 0)
      {
        midi_channel = i;

        if (midi_channel > 15)
        {
          printf("Warning: MIDI channel %d is higher than max 15; line %d\n",
            midi_channel, tokens->get_line());
          midi_channel = 9;
        }
      }
        else
      {
        printf("Warning: Cannot set '%s' in pattern.\n", token);
      }

      token_type = tokens->get(token);

      if (strcmp(token, ";") != 0)
      {
        print_error(tokens, ";", token);
        return -1;
      }

      continue;
    }

    // Read next line of beat information for an instrument from a pattern.
    if (token_type == TOKEN_NUMBER)
    {
      beats[ptr].channel = midi_channel;

      if (add_beats(tokens, beats, ptr, atoi(token), midi_channel) == -1)
      {
        return -1;
      }
    }
      else
    {
      if (defines.find(token) == defines.end())
      {
        printf("Error: %s is undefined at %s:%d\n",
          token, tokens->get_filename(), tokens->get_line());
        return -1;
      }

      strcpy(value, defines[token].c_str());

      if (Utility::is_number(value) == false)
      {
        printf("Error: %s is not a number at %s:%d\n",
          token, tokens->get_filename(), tokens->get_line());
        return -1;
      }

      beats[ptr].channel = midi_channel;

      if (add_beats(tokens, beats, ptr, atoi(value), midi_channel) == -1)
      {
        return -1;
      }
    }
  }

#ifdef DEBUG
for (int n = 0; n < ptr; n++)
{
  printf("beat: %d %d %f %d\n",
    beats[n].instrument,
    beats[n].channel,
    beats[n].value,
    beats[n].volume);
}
#endif

  // Convert beat information to the pattern format.  This looks like
  // basically a slow sorting algorithm.
  while(1)
  {
    low_beat = time_signature_beats + 1;
    next_beat = time_signature_beats + 1;
    count = 0;

    // Find the next lowest beat value and a count of how many
    // times that beat value exists.
    for (i = 0; i < ptr; i++)
    {
      if (beats[i].value > 0)
      {
        if (beats[i].value < low_beat)
        {
          low_beat = beats[i].value;
          count = 0;
        }

        if (beats[i].value == low_beat) { count++; }
      }
    }

    // If no more beats were found, break from adding to the pattern list.
    if (count == 0)
    {
      if (ptr == 0)
      {
        // If this is the first beat, add an empty pattern?
        int duration = (int)((time_signature_beats) * beat_time);

        pattern.add(0, 0, midi_channel, duration);
      }

      break;
    }

    // Find the next lowest value.  It seems like this whole process
    // could be done without doing this.
    for (i = 0; i < ptr; i++)
    {
      if (beats[i].value > 0)
      {
        if (beats[i].value < next_beat && beats[i].value != low_beat)
        {
          next_beat = beats[i].value;
        }
      }
    }

    // Scan through all the beats, and if it is equal to the current
    // lowest, add it to the pattern.  Then clear it out so it doesn't
    // get counted again.
    for (i = 0; i < ptr; i++)
    {
      if (beats[i].value == low_beat)
      {
        if (num_notes == 0 && low_beat != 1)
        {
          int duration = (int)((low_beat - 1) * beat_time);

          pattern.add(0, 0, midi_channel, duration);
        }

        int duration = 0;


        if (count == 1)
        {
          duration = (int)((next_beat - low_beat) * beat_time);
        }

        pattern.add(beats[i].instrument,
                    beats[i].volume,
                    beats[i].channel,
                    duration);

        beats[i].value = 0;

        count--;
      }
    }

    num_notes++;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e60, %rsp           # imm = 0x1E60
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq %rcx, -0x1d40(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1c34(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1c38(%rbp)
movl $0x3938700, %eax        # imm = 0x3938700
cltd
idivl 0x20(%rcx)
movl %eax, %ecx
movq -0x1d40(%rbp), %rax
movl %ecx, -0x1c48(%rbp)
movl 0x2c(%rax), %ecx
movl %ecx, -0x1c4c(%rbp)
movl 0x34(%rax), %eax
movl %eax, -0x1c50(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
je 0x5ff3
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0x1d48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0x1d48(%rbp), %rsi
movl %eax, %edx
leaq 0xa763(%rip), %rdi      # 0x10743
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f1e
movq -0x1d40(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x1d58(%rbp)
leaq -0x1c79(%rbp), %rdi
movq %rdi, -0x1d50(%rbp)
callq 0x23d0
movq -0x1d50(%rbp), %rdx
leaq -0x1c78(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x8f10
jmp 0x6034
movq -0x1d58(%rbp), %rdi
leaq -0x1c78(%rbp), %rsi
callq 0x90d0
movq %rax, -0x1d60(%rbp)
jmp 0x6050
movq -0x1d40(%rbp), %rdi
movq -0x1d60(%rbp), %rax
movq %rax, -0x1c58(%rbp)
addq $0x78, %rdi
callq 0x9100
movq %rax, -0x1c98(%rbp)
leaq -0x1c58(%rbp), %rdi
leaq -0x1c98(%rbp), %rsi
callq 0x90a0
movb %al, -0x1d61(%rbp)
leaq -0x1c78(%rbp), %rdi
callq 0x2150
leaq -0x1c79(%rbp), %rdi
callq 0x2260
movb -0x1d61(%rbp), %al
testb $0x1, %al
jne 0x60b5
jmp 0x6149
leaq -0x420(%rbp), %rax
movq %rax, -0x1d78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0x1d70(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0x1d78(%rbp), %rsi
movq -0x1d70(%rbp), %rdx
movl %eax, %ecx
leaq 0xa67d(%rip), %rdi      # 0x10770
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
jmp 0x6138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
leaq -0x1c78(%rbp), %rdi
callq 0x2150
leaq -0x1c79(%rbp), %rdi
callq 0x2260
jmp 0x6f2a
leaq -0x1cb9(%rbp), %rdi
movq %rdi, -0x1d80(%rbp)
callq 0x23d0
movq -0x1d80(%rbp), %rdx
leaq -0x1cb8(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x8f10
jmp 0x6178
leaq -0x1cb9(%rbp), %rdi
callq 0x2260
movq -0x1d40(%rbp), %rdi
addq $0x78, %rdi
movq %rdi, -0x1d90(%rbp)
callq 0x9130
movq -0x1d90(%rbp), %rdi
movl %eax, -0x1cc0(%rbp)
leaq -0x1cb8(%rbp), %rsi
callq 0x8cf0
movq %rax, -0x1d88(%rbp)
jmp 0x61bd
movq -0x1d40(%rbp), %rdi
movq -0x1d88(%rbp), %rax
movq %rax, -0x1cc8(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x1da0(%rbp)
addq $0xd8, %rdi
leaq -0x1cc0(%rbp), %rsi
callq 0x8c10
movq %rax, -0x1d98(%rbp)
jmp 0x61fc
movq -0x1da0(%rbp), %rsi
movq -0x1d98(%rbp), %rdi
callq 0x2300
jmp 0x6211
movq -0x1cc8(%rbp), %rdi
leaq -0x1cb8(%rbp), %rsi
callq 0x9150
jmp 0x6226
movq -0x1cc8(%rbp), %rdi
movl -0x1cc0(%rbp), %esi
callq 0x9180
jmp 0x623a
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1da4(%rbp)
jmp 0x6252
movl -0x1da4(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x420(%rbp), %rdi
leaq 0xa536(%rip), %rsi      # 0x1079f
callq 0x2320
cmpl $0x0, %eax
je 0x62e3
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa51a(%rip), %rdx      # 0x1079f
leaq -0x420(%rbp), %rcx
callq 0x7e10
jmp 0x6293
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
leaq -0x1cb9(%rbp), %rdi
callq 0x2260
jmp 0x6f2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
jmp 0x6f10
movl $0x0, -0x1824(%rbp)
movl $0x0, -0x1c44(%rbp)
jmp 0x62f9
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1da8(%rbp)
jmp 0x6311
movl -0x1da8(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x420(%rbp), %rdi
leaq 0xa479(%rip), %rsi      # 0x107a1
callq 0x2320
cmpl $0x0, %eax
jne 0x6337
jmp 0x6b50
leaq -0x420(%rbp), %rdi
leaq 0xa46a(%rip), %rsi      # 0x107af
callq 0x2320
cmpl $0x0, %eax
jne 0x6749
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1dac(%rbp)
jmp 0x636b
movl -0x1dac(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
je 0x63b0
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa417(%rip), %rdx      # 0x107a3
leaq -0x420(%rbp), %rcx
callq 0x7e10
jmp 0x639a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1db0(%rbp)
jmp 0x63c8
movl -0x1db0(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x820(%rbp), %rdi
leaq 0xa04a(%rip), %rsi      # 0x10429
callq 0x2320
cmpl $0x0, %eax
je 0x641f
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa02e(%rip), %rdx      # 0x10429
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x6409
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1db4(%rbp)
jmp 0x6437
movl -0x1db4(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x647c
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa35b(%rip), %rdx      # 0x107b3
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x6466
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
leaq -0x820(%rbp), %rdi
callq 0x2380
movl %eax, -0x1c3c(%rbp)
cmpl $0x0, -0x1c3c(%rbp)
jne 0x64cd
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa313(%rip), %rdx      # 0x107bc
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x64b7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
leaq -0x420(%rbp), %rdi
leaq 0x9f50(%rip), %rsi      # 0x1042b
callq 0x2320
cmpl $0x0, %eax
jne 0x64fc
movl $0x3938700, %eax        # imm = 0x3938700
cltd
idivl -0x1c3c(%rbp)
movl %eax, -0x1c48(%rbp)
jmp 0x66d5
leaq -0x420(%rbp), %rdi
leaq 0x9fc2(%rip), %rsi      # 0x104cc
callq 0x2320
cmpl $0x0, %eax
jne 0x6646
movl -0x1c3c(%rbp), %eax
movl %eax, -0x1c4c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1db8(%rbp)
jmp 0x653c
movl -0x1db8(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x820(%rbp), %rdi
leaq 0x9f87(%rip), %rsi      # 0x104da
callq 0x2320
cmpl $0x0, %eax
je 0x6593
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x9f6b(%rip), %rdx      # 0x104da
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x657d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1dbc(%rbp)
jmp 0x65ab
movl -0x1dbc(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x65f0
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa1e7(%rip), %rdx      # 0x107b3
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x65da
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
leaq -0x820(%rbp), %rdi
callq 0x2380
movl %eax, -0x1c3c(%rbp)
cmpl $0x0, -0x1c3c(%rbp)
jne 0x6641
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xa19f(%rip), %rdx      # 0x107bc
leaq -0x820(%rbp), %rcx
callq 0x7e10
jmp 0x662b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
jmp 0x66d3
leaq -0x420(%rbp), %rdi
leaq 0x9eff(%rip), %rsi      # 0x10553
callq 0x2320
cmpl $0x0, %eax
jne 0x66b8
movl -0x1c3c(%rbp), %eax
movl %eax, -0x1c50(%rbp)
cmpl $0xf, -0x1c50(%rbp)
jle 0x66b6
movl -0x1c50(%rbp), %eax
movl %eax, -0x1dc4(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movl %eax, -0x1dc0(%rbp)
jmp 0x6690
movl -0x1dc0(%rbp), %edx
movl -0x1dc4(%rbp), %esi
leaq 0xa12c(%rip), %rdi      # 0x107cf
xorl %eax, %eax
callq 0x2060
jmp 0x66ac
movl $0x9, -0x1c50(%rbp)
jmp 0x66d1
leaq 0xa149(%rip), %rdi      # 0x10808
xorl %eax, %eax
leaq -0x420(%rbp), %rsi
callq 0x2060
jmp 0x66cf
jmp 0x66d1
jmp 0x66d3
jmp 0x66d5
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1dc8(%rbp)
jmp 0x66ed
movl -0x1dc8(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x420(%rbp), %rdi
leaq 0x9ec4(%rip), %rsi      # 0x105c8
callq 0x2320
cmpl $0x0, %eax
je 0x6744
movq -0x1d40(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x9ea8(%rip), %rdx      # 0x105c8
leaq -0x420(%rbp), %rcx
callq 0x7e10
jmp 0x672e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
jmp 0x62f7
cmpl $0x2, -0x1c(%rbp)
jne 0x67db
movl -0x1c50(%rbp), %ecx
movslq -0x1824(%rbp), %rax
shlq $0x4, %rax
movl %ecx, -0x1818(%rbp,%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x1dd8(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x2380
movq -0x1d40(%rbp), %rdi
movq -0x1dd8(%rbp), %rsi
movl %eax, %r8d
movl -0x1c50(%rbp), %r9d
leaq -0x1820(%rbp), %rdx
leaq -0x1824(%rbp), %rcx
callq 0x7f10
movl %eax, -0x1dcc(%rbp)
jmp 0x67b5
movl -0x1dcc(%rbp), %eax
cmpl $-0x1, %eax
jne 0x67d6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
jmp 0x6b4b
movq -0x1d40(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x1de8(%rbp)
leaq -0x1cf9(%rbp), %rdi
movq %rdi, -0x1de0(%rbp)
callq 0x23d0
movq -0x1de0(%rbp), %rdx
leaq -0x1cf8(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x8f10
jmp 0x681e
movq -0x1de8(%rbp), %rdi
leaq -0x1cf8(%rbp), %rsi
callq 0x8ee0
movq %rax, -0x1df0(%rbp)
jmp 0x683a
movq -0x1d40(%rbp), %rdi
movq -0x1df0(%rbp), %rax
movq %rax, -0x1cd8(%rbp)
addq $0xa8, %rdi
callq 0x8a70
movq %rax, -0x1d08(%rbp)
leaq -0x1cd8(%rbp), %rdi
leaq -0x1d08(%rbp), %rsi
callq 0x91a0
movb %al, -0x1df1(%rbp)
leaq -0x1cf8(%rbp), %rdi
callq 0x2150
leaq -0x1cf9(%rbp), %rdi
callq 0x2260
movb -0x1df1(%rbp), %al
testb $0x1, %al
jne 0x68a2
jmp 0x6950
leaq -0x420(%rbp), %rax
movq %rax, -0x1e08(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0x1e00(%rbp)
jmp 0x68c2
movq -0x18(%rbp), %rdi
callq 0x89f0
movl %eax, -0x1e0c(%rbp)
jmp 0x68d3
movl -0x1e0c(%rbp), %ecx
movq -0x1e00(%rbp), %rdx
movq -0x1e08(%rbp), %rsi
leaq 0x9f40(%rip), %rdi      # 0x1082e
xorl %eax, %eax
callq 0x2060
jmp 0x68f7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
jmp 0x693f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
leaq -0x1cf8(%rbp), %rdi
callq 0x2150
leaq -0x1cf9(%rbp), %rdi
callq 0x2260
jmp 0x6f10
movq -0x1d40(%rbp), %rax
leaq -0x1c30(%rbp), %rcx
movq %rcx, -0x1e28(%rbp)
addq $0xa8, %rax
movq %rax, -0x1e20(%rbp)
leaq -0x1d29(%rbp), %rdi
movq %rdi, -0x1e18(%rbp)
callq 0x23d0
movq -0x1e18(%rbp), %rdx
leaq -0x1d28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x8f10
jmp 0x69a1
movq -0x1e20(%rbp), %rdi
leaq -0x1d28(%rbp), %rsi
callq 0x8fc0
movq %rax, -0x1e30(%rbp)
jmp 0x69bd
movq -0x1e30(%rbp), %rdi
callq 0x2100
movq -0x1e28(%rbp), %rdi
movq %rax, %rsi
callq 0x21f0
leaq -0x1d28(%rbp), %rdi
callq 0x2150
leaq -0x1d29(%rbp), %rdi
callq 0x2260
leaq -0x1c30(%rbp), %rdi
callq 0xf480
movb %al, -0x1e31(%rbp)
jmp 0x6a04
movb -0x1e31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x6ac6
leaq -0x420(%rbp), %rax
movq %rax, -0x1e48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0x1e40(%rbp)
jmp 0x6a38
movq -0x18(%rbp), %rdi
callq 0x89f0
movl %eax, -0x1e4c(%rbp)
jmp 0x6a49
movl -0x1e4c(%rbp), %ecx
movq -0x1e40(%rbp), %rdx
movq -0x1e48(%rbp), %rsi
leaq 0x9deb(%rip), %rdi      # 0x1084f
xorl %eax, %eax
callq 0x2060
jmp 0x6a6d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
jmp 0x6ab5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c88(%rbp)
movl %eax, -0x1c8c(%rbp)
leaq -0x1d28(%rbp), %rdi
callq 0x2150
leaq -0x1d29(%rbp), %rdi
callq 0x2260
jmp 0x6f10
movl -0x1c50(%rbp), %ecx
movslq -0x1824(%rbp), %rax
shlq $0x4, %rax
movl %ecx, -0x1818(%rbp,%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x1e58(%rbp)
leaq -0x1c30(%rbp), %rdi
callq 0x2380
movq -0x1d40(%rbp), %rdi
movq -0x1e58(%rbp), %rsi
movl %eax, %r8d
movl -0x1c50(%rbp), %r9d
leaq -0x1820(%rbp), %rdx
leaq -0x1824(%rbp), %rcx
callq 0x7f10
movl %eax, -0x1e50(%rbp)
jmp 0x6b28
movl -0x1e50(%rbp), %eax
cmpl $-0x1, %eax
jne 0x6b49
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x1ccc(%rbp)
jmp 0x6f02
jmp 0x6b4b
jmp 0x62f7
jmp 0x6b52
jmp 0x6b54
movl -0x1c4c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1c34(%rbp)
movl -0x1c4c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x1c38(%rbp)
movl $0x0, -0x1c40(%rbp)
movl $0x0, -0x1c3c(%rbp)
movl -0x1c3c(%rbp), %eax
cmpl -0x1824(%rbp), %eax
jge 0x6c65
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x6c4f
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm1
movss -0x1c34(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6c1a
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movss %xmm0, -0x1c34(%rbp)
movl $0x0, -0x1c40(%rbp)
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
ucomiss -0x1c34(%rbp), %xmm0
jne 0x6c4d
jp 0x6c4d
movl -0x1c40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c40(%rbp)
jmp 0x6c4f
jmp 0x6c51
movl -0x1c3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c3c(%rbp)
jmp 0x6b92
cmpl $0x0, -0x1c40(%rbp)
jne 0x6cb3
cmpl $0x0, -0x1824(%rbp)
jne 0x6cae
movl -0x1c4c(%rbp), %eax
movl -0x1c48(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x1d30(%rbp)
movq -0x1cc8(%rbp), %rdi
movzbl -0x1c50(%rbp), %ecx
movl -0x1d30(%rbp), %r8d
xorl %edx, %edx
movl %edx, %esi
callq 0x38c0
jmp 0x6cac
jmp 0x6cae
jmp 0x6ef1
movl $0x0, -0x1c3c(%rbp)
movl -0x1c3c(%rbp), %eax
cmpl -0x1824(%rbp), %eax
jge 0x6d75
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x6d5f
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm1
movss -0x1c38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6d5d
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
ucomiss -0x1c34(%rbp), %xmm0
jne 0x6d3c
jp 0x6d3c
jmp 0x6d5d
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movss %xmm0, -0x1c38(%rbp)
jmp 0x6d5f
jmp 0x6d61
movl -0x1c3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c3c(%rbp)
jmp 0x6cbd
movl $0x0, -0x1c3c(%rbp)
movl -0x1c3c(%rbp), %eax
cmpl -0x1824(%rbp), %eax
jge 0x6edd
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
ucomiss -0x1c34(%rbp), %xmm0
jne 0x6ec7
jp 0x6ec7
cmpl $0x0, -0x1c44(%rbp)
jne 0x6e2b
movss -0x1c34(%rbp), %xmm0
movss 0x95a6(%rip), %xmm1     # 0x1037c
ucomiss %xmm1, %xmm0
jne 0x6ddf
jp 0x6ddf
jmp 0x6e2b
movss -0x1c34(%rbp), %xmm0
movss 0x9591(%rip), %xmm1     # 0x10380
addss %xmm1, %xmm0
cvtsi2ssl -0x1c48(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1d34(%rbp)
movq -0x1cc8(%rbp), %rdi
movzbl -0x1c50(%rbp), %ecx
movl -0x1d34(%rbp), %r8d
xorl %edx, %edx
movl %edx, %esi
callq 0x38c0
jmp 0x6e29
jmp 0x6e2b
movl $0x0, -0x1d38(%rbp)
cmpl $0x1, -0x1c40(%rbp)
jne 0x6e64
movss -0x1c38(%rbp), %xmm0
subss -0x1c34(%rbp), %xmm0
cvtsi2ssl -0x1c48(%rbp), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1d38(%rbp)
movq -0x1cc8(%rbp), %rdi
movslq -0x1c3c(%rbp), %rax
shlq $0x4, %rax
movzbl -0x181c(%rbp,%rax), %esi
movzbl -0x1814(%rbp,%rax), %edx
movzbl -0x1818(%rbp,%rax), %ecx
movl -0x1d38(%rbp), %r8d
callq 0x38c0
jmp 0x6e9c
movslq -0x1c3c(%rbp), %rcx
leaq -0x1820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl -0x1c40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c40(%rbp)
jmp 0x6ec9
movl -0x1c3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c3c(%rbp)
jmp 0x6d7f
movl -0x1c44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c44(%rbp)
jmp 0x6b52
movl $0x0, -0x4(%rbp)
movl $0x1, -0x1ccc(%rbp)
leaq -0x1cb8(%rbp), %rdi
callq 0x2150
jmp 0x6f1e
leaq -0x1cb8(%rbp), %rdi
callq 0x2150
jmp 0x6f2a
movl -0x4(%rbp), %eax
addq $0x1e60, %rsp           # imm = 0x1E60
popq %rbp
retq
movq -0x1c88(%rbp), %rdi
callq 0x23c0
nopw %cs:(%rax,%rax)