// File: /workspace/github_cpp_makefile_star2_O2/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 0x2828
cmpl $0x1, %eax
jne 0x3775
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2828
cmpw $0x3d, (%r15)
jne 0x3784
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2828
cmpl $0x2, %eax
jne 0x3790
cmpl $0x6d7062, (%rsp)       # imm = 0x6D7062
jne 0x379c
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x20(%r14)
testl %eax, %eax
jne 0x3917
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3c32(%rip), %rdi      # 0x739b
xorl %eax, %eax
callq 0x2050
jmp 0x394a
leaq 0x3c10(%rip), %rdx      # 0x738c
movq %rsp, %rcx
jmp 0x3942
leaq 0x3c0e(%rip), %rdx      # 0x7399
jmp 0x393a
leaq 0x3f84(%rip), %rdx      # 0x771b
jmp 0x393a
leaq 0x3c26(%rip), %rsi      # 0x73c9
movq %rsp, %rdi
pushq $0xf
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x3851
leaq 0x3c1b(%rip), %rsi      # 0x73d8
movq %rsp, %rdi
pushq $0xe
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x3851
leaq 0x3c4c(%rip), %rsi      # 0x7423
movq %rsp, %rdi
pushq $0x6
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x3906
leaq 0x3c38(%rip), %rsi      # 0x7429
movq %rsp, %rdi
pushq $0xf
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x388b
leaq 0x3c2d(%rip), %rsi      # 0x7438
movq %rsp, %rdi
pushq $0xe
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x388b
leaq 0x3c9e(%rip), %rsi      # 0x74bf
movq %rsp, %rdi
pushq $0xd
popq %rdx
callq 0x21d0
testl %eax, %eax
je 0x3974
movq 0x8(%rbx), %rdx
movl 0x2c(%rbx), %ecx
leaq 0x3ccb(%rip), %rdi      # 0x750d
movq %rsp, %rsi
xorl %eax, %eax
callq 0x2050
jmp 0x394a
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x24(%r14)
cmpl $0x80, %eax
jl 0x3917
movl 0x2c(%rbx), %esi
leaq 0x3b6f(%rip), %rdi      # 0x73e6
xorl %eax, %eax
callq 0x2050
movl $0x7f, 0x24(%r14)
jmp 0x3917
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x2c(%r14)
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2828
cmpw $0x2f, (%r15)
jne 0x395a
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2828
cmpl $0x2, %eax
jne 0x3963
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x30(%r14)
cmpl $0x0, 0x2c(%r14)
je 0x39aa
testl %eax, %eax
jne 0x3917
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3b82(%rip), %rdi      # 0x7483
jmp 0x3769
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x28(%r14)
leaq 0x800(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2828
xorl %eax, %eax
cmpw $0x3b, (%r14)
je 0x394d
leaq 0x3bfa(%rip), %rdx      # 0x7534
leaq 0x800(%rsp), %rcx
movq %rbx, %rsi
callq 0x49e6
pushq $-0x1
popq %rax
addq $0xc00, %rsp            # imm = 0xC00
popq %rbx
popq %r14
popq %r15
retq
leaq 0x3ae5(%rip), %rdx      # 0x7446
jmp 0x393a
leaq 0x3db1(%rip), %rdx      # 0x771b
leaq 0x400(%rsp), %rcx
jmp 0x3942
leaq 0x400(%rsp), %rdi
callq 0x22f0
movl %eax, 0x34(%r14)
cmpl $0x10, %eax
jl 0x3917
movl 0x2c(%rbx), %edx
leaq 0x3b38(%rip), %rdi      # 0x74cc
movl %eax, %esi
xorl %eax, %eax
callq 0x2050
movl $0x9, 0x34(%r14)
jmp 0x3917
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3a90(%rip), %rdi      # 0x7448
jmp 0x3769
nop