// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0xc00, %rsp            # imm = 0xC00
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x2884
cmpl $0x1, %eax
jne 0x37d7
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2884
cmpw $0x3d, (%r15)
jne 0x37f5
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2884
cmpl $0x2, %eax
jne 0x3810
cmpl $0x6d7062, (%rsp)       # imm = 0x6D7062
jne 0x382b
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x20(%r14)
testl %eax, %eax
jne 0x39d6
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3bb8(%rip), %rdi      # 0x7383
xorl %eax, %eax
callq 0x2050
jmp 0x3a17
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x40fa(%rip), %rdi      # 0x78e0
leaq 0x3b87(%rip), %rsi      # 0x7374
movq %rsp, %rdx
jmp 0x3a10
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x40dc(%rip), %rdi      # 0x78e0
leaq 0x3b76(%rip), %rsi      # 0x7381
jmp 0x3a08
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x40c1(%rip), %rdi      # 0x78e0
leaq 0x3edd(%rip), %rsi      # 0x7703
jmp 0x3a08
movabsq $0x5f746c7561666564, %rcx # imm = 0x5F746C7561666564
xorq (%rsp), %rcx
movabsq $0x656d756c6f765f, %rax # imm = 0x656D756C6F765F
movq 0x7(%rsp), %rdx
xorq %rax, %rdx
orq %rcx, %rdx
je 0x3910
movabsq $0x76746c7561666564, %rcx # imm = 0x76746C7561666564
xorq (%rsp), %rcx
addq $0x15, %rax
xorq 0x6(%rsp), %rax
orq %rcx, %rax
je 0x3910
movl $0x66697264, %eax       # imm = 0x66697264
xorl (%rsp), %eax
movzwl 0x4(%rsp), %ecx
xorl $0x74, %ecx
orl %eax, %ecx
je 0x39c5
movabsq $0x6769735f656d6974, %rcx # imm = 0x6769735F656D6974
xorq (%rsp), %rcx
movabsq $0x65727574616e67, %rax # imm = 0x65727574616E67
movq 0x7(%rsp), %rdx
xorq %rax, %rdx
orq %rcx, %rdx
je 0x394a
movabsq $0x6e676973656d6974, %rcx # imm = 0x6E676973656D6974
xorq (%rsp), %rcx
xorq 0x6(%rsp), %rax
orq %rcx, %rax
je 0x394a
movabsq $0x6168635f6964696d, %rax # imm = 0x6168635F6964696D
xorq (%rsp), %rax
movabsq $0x6c656e6e616863, %rcx # imm = 0x6C656E6E616863
xorq 0x5(%rsp), %rcx
orq %rax, %rcx
je 0x3a61
movq 0x8(%rbx), %rdx
movl 0x2c(%rbx), %ecx
leaq 0x3bf4(%rip), %rdi      # 0x74f5
movq %rsp, %rsi
xorl %eax, %eax
callq 0x2050
jmp 0x3a17
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x24(%r14)
cmpl $0x80, %eax
jl 0x39d6
movl 0x2c(%rbx), %esi
leaq 0x3a98(%rip), %rdi      # 0x73ce
xorl %eax, %eax
callq 0x2050
movl $0x7f, 0x24(%r14)
jmp 0x39d6
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x2c(%r14)
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2884
cmpw $0x2f, (%r15)
jne 0x3a29
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2884
cmpl $0x2, %eax
jne 0x3a41
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x30(%r14)
cmpl $0x0, 0x2c(%r14)
je 0x3a9b
testl %eax, %eax
jne 0x39d6
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3aab(%rip), %rdi      # 0x746b
jmp 0x37cb
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x28(%r14)
leaq 0x800(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2884
xorl %eax, %eax
cmpw $0x3b, (%r14)
je 0x3a1c
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x3edf(%rip), %rdi      # 0x78e0
leaq 0x3b14(%rip), %rsi      # 0x751c
leaq 0x800(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xc00, %rsp            # imm = 0xC00
popq %rbx
popq %r14
popq %r15
retq
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x3ea8(%rip), %rdi      # 0x78e0
leaq 0x39ef(%rip), %rsi      # 0x742e
jmp 0x3a08
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x3e90(%rip), %rdi      # 0x78e0
leaq 0x3cac(%rip), %rsi      # 0x7703
leaq 0x400(%rsp), %rdx
jmp 0x3a10
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x34(%r14)
cmpl $0x10, %eax
jl 0x39d6
movl 0x2c(%rbx), %edx
leaq 0x3a2f(%rip), %rdi      # 0x74b4
movl %eax, %esi
xorl %eax, %eax
callq 0x2050
movl $0x9, 0x34(%r14)
jmp 0x39d6
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3987(%rip), %rdi      # 0x7430
jmp 0x37cb