// File: mikeakohn[P]drumsplusplus/build/../src/Song.cxx
// Function: Song::parse_set(Tokens*)
int Song::parse_set(Tokens *tokens)
{
  int token_type;
  char token[1024];
  char equals[1024];
  char value[1024];

  token_type = tokens->get(token);

  if (token_type != TOKEN_ALPHA)
  {
    print_error(tokens, "setting name", token);
    return -1;
  }

  token_type = tokens->get(equals);

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

  token_type = tokens->get(value);

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

  if (strcmp(token, "bpm") == 0)
  {
    song_info.bpm = atoi(value);

    if (song_info.bpm == 0)
    {
      printf("Error: Tempo (bpm) must be non-zero at %s:%d\n",
        tokens->get_filename(), tokens->get_line());
      return -1;
    }
  }
    else
  if (strcmp(token, "default_volume") == 0 ||
      strcmp(token, "defaultvolume") == 0)
  {
    song_info.default_volume = atoi(value);

    if (song_info.default_volume > 127)
    {
      printf("Warning: default volume is higher than the max 127; line %d\n",
        tokens->get_line());
      song_info.default_volume = 127;
    }
  }
    else
  if (strcmp(token, "drift") == 0)
  {
     song_info.drift = atoi(value);
  }
    else
  if (strcmp(token, "time_signature") == 0 ||
      strcmp(token, "timesignature") == 0)
  {
    song_info.time_signature_beats = atoi(value);

    token_type = tokens->get(equals);

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

    token_type = tokens->get(value);

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

    song_info.time_signature_base = atoi(value);
    /* midi_file->write_time_signature(); */

    if (song_info.time_signature_beats == 0)
    {
      printf("Error: Time signature numerator must be non-zero at %s:%d\n",
        tokens->get_filename(), tokens->get_line());
      return -1;
    }
      else
    if (song_info.time_signature_base == 0)
    {
      printf("Error: Timesignature denominator must be non-zero at %s:%d\n",
        tokens->get_filename(), tokens->get_line());
      return -1;
    }
  }
    else
  if (strcmp(token, "midi_channel") == 0)
  {
    song_info.midi_channel = atoi(value);

    if (song_info.midi_channel > 15)
    {
      printf("Warning: MIDI channel %d is higher than the maximum 15; line %d\n", song_info.midi_channel, tokens->get_line());
      song_info.midi_channel = 9;
    }
  }
    else
  {
    printf("Error: Unknown setting '%s' at %s:%d.\n",
      token, tokens->get_filename(), tokens->get_line());
    return -1;
  }

  token_type = tokens->get(equals);

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

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc60, %rsp            # imm = 0xC60
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
je 0x55c1
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x420(%rbp), %rcx
leaq 0xae6c(%rip), %rdx      # 0x1041c
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
leaq -0x820(%rbp), %rdi
leaq 0xae47(%rip), %rsi      # 0x10429
callq 0x2320
cmpl $0x0, %eax
je 0x5616
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x820(%rbp), %rcx
leaq 0xae24(%rip), %rdx      # 0x10429
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
movq -0x18(%rbp), %rdi
leaq -0xc20(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x5659
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x820(%rbp), %rcx
leaq 0xb16d(%rip), %rdx      # 0x107b5
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
leaq -0x420(%rbp), %rdi
leaq 0xadc4(%rip), %rsi      # 0x1042b
callq 0x2320
cmpl $0x0, %eax
jne 0x56d0
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x20(%rax)
cmpl $0x0, 0x20(%rax)
jne 0x56cb
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0xc30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0xc30(%rbp), %rsi
movl %eax, %edx
leaq 0xad77(%rip), %rdi      # 0x1042f
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
jmp 0x59d8
leaq -0x420(%rbp), %rdi
leaq 0xad7f(%rip), %rsi      # 0x1045d
callq 0x2320
cmpl $0x0, %eax
je 0x5700
leaq -0x420(%rbp), %rdi
leaq 0xad76(%rip), %rsi      # 0x1046c
callq 0x2320
cmpl $0x0, %eax
jne 0x574a
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x24(%rax)
cmpl $0x7f, 0x24(%rax)
jle 0x5745
movq -0x18(%rbp), %rdi
callq 0x89f0
movl %eax, %esi
leaq 0xad4a(%rip), %rdi      # 0x1047a
movb $0x0, %al
callq 0x2060
movq -0xc28(%rbp), %rax
movl $0x7f, 0x24(%rax)
jmp 0x59d6
leaq -0x420(%rbp), %rdi
leaq 0xad5f(%rip), %rsi      # 0x104b7
callq 0x2320
cmpl $0x0, %eax
jne 0x577f
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x59d4
leaq -0x420(%rbp), %rdi
leaq 0xad30(%rip), %rsi      # 0x104bd
callq 0x2320
cmpl $0x0, %eax
je 0x57b3
leaq -0x420(%rbp), %rdi
leaq 0xad27(%rip), %rsi      # 0x104cc
callq 0x2320
cmpl $0x0, %eax
jne 0x590d
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
leaq -0x820(%rbp), %rdi
leaq 0xacee(%rip), %rsi      # 0x104da
callq 0x2320
cmpl $0x0, %eax
je 0x5820
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x820(%rbp), %rcx
leaq 0xaccb(%rip), %rdx      # 0x104da
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
movq -0x18(%rbp), %rdi
leaq -0xc20(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x5863
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0xc20(%rbp), %rcx
leaq 0xaf63(%rip), %rdx      # 0x107b5
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x30(%rax)
cmpl $0x0, 0x2c(%rax)
jne 0x58bd
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0xc38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0xc38(%rbp), %rsi
movl %eax, %edx
leaq 0xac32(%rip), %rdi      # 0x104dc
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
movq -0xc28(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x5906
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0xc40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0xc40(%rbp), %rsi
movl %eax, %edx
leaq 0xac24(%rip), %rdi      # 0x10517
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
jmp 0x5908
jmp 0x59d2
leaq -0x420(%rbp), %rdi
leaq 0xac38(%rip), %rsi      # 0x10553
callq 0x2320
cmpl $0x0, %eax
jne 0x5982
leaq -0xc20(%rbp), %rdi
callq 0x2380
movl %eax, %ecx
movq -0xc28(%rbp), %rax
movl %ecx, 0x34(%rax)
cmpl $0xf, 0x34(%rax)
jle 0x5980
movq -0xc28(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0xc44(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movl -0xc44(%rbp), %esi
movl %eax, %edx
leaq 0xabf5(%rip), %rdi      # 0x10560
movb $0x0, %al
callq 0x2060
movq -0xc28(%rbp), %rax
movl $0x9, 0x34(%rax)
jmp 0x59d0
leaq -0x420(%rbp), %rax
movq %rax, -0xc58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2f40
movq %rax, -0xc50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x89f0
movq -0xc58(%rbp), %rsi
movq -0xc50(%rbp), %rdx
movl %eax, %ecx
leaq 0xabe1(%rip), %rdi      # 0x105a1
movb $0x0, %al
callq 0x2060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
jmp 0x59d2
jmp 0x59d4
jmp 0x59d6
jmp 0x59d8
movq -0x18(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x2b10
movl %eax, -0x1c(%rbp)
leaq -0x820(%rbp), %rdi
leaq 0xabcf(%rip), %rsi      # 0x105c8
callq 0x2320
cmpl $0x0, %eax
je 0x5a2a
movq -0xc28(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x820(%rbp), %rcx
leaq 0xabac(%rip), %rdx      # 0x105c8
callq 0x7e10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5a31
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc60, %rsp            # imm = 0xC60
popq %rbp
retq
nopl (%rax)