// File: /workspace/github_cpp_makefile_star2_O1/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 0x2880
cmpl $0x1, %eax
jne 0x37cb
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2880
cmpw $0x3d, (%r15)
jne 0x37e9
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2880
cmpl $0x2, %eax
jne 0x3804
cmpl $0x6d7062, (%rsp)       # imm = 0x6D7062
jne 0x381f
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x20(%r14)
testl %eax, %eax
jne 0x39ca
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3bcc(%rip), %rdi      # 0x738b
xorl %eax, %eax
callq 0x2050
jmp 0x3a0b
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x410e(%rip), %rdi      # 0x78e8
leaq 0x3b9b(%rip), %rsi      # 0x737c
movq %rsp, %rdx
jmp 0x3a04
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x40f0(%rip), %rdi      # 0x78e8
leaq 0x3b8a(%rip), %rsi      # 0x7389
jmp 0x39fc
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x40d5(%rip), %rdi      # 0x78e8
leaq 0x3ef1(%rip), %rsi      # 0x770b
jmp 0x39fc
movabsq $0x5f746c7561666564, %rcx # imm = 0x5F746C7561666564
xorq (%rsp), %rcx
movabsq $0x656d756c6f765f, %rax # imm = 0x656D756C6F765F
movq 0x7(%rsp), %rdx
xorq %rax, %rdx
orq %rcx, %rdx
je 0x3904
movabsq $0x76746c7561666564, %rcx # imm = 0x76746C7561666564
xorq (%rsp), %rcx
addq $0x15, %rax
xorq 0x6(%rsp), %rax
orq %rcx, %rax
je 0x3904
movl $0x66697264, %eax       # imm = 0x66697264
xorl (%rsp), %eax
movzwl 0x4(%rsp), %ecx
xorl $0x74, %ecx
orl %eax, %ecx
je 0x39b9
movabsq $0x6769735f656d6974, %rcx # imm = 0x6769735F656D6974
xorq (%rsp), %rcx
movabsq $0x65727574616e67, %rax # imm = 0x65727574616E67
movq 0x7(%rsp), %rdx
xorq %rax, %rdx
orq %rcx, %rdx
je 0x393e
movabsq $0x6e676973656d6974, %rcx # imm = 0x6E676973656D6974
xorq (%rsp), %rcx
xorq 0x6(%rsp), %rax
orq %rcx, %rax
je 0x393e
movabsq $0x6168635f6964696d, %rax # imm = 0x6168635F6964696D
xorq (%rsp), %rax
movabsq $0x6c656e6e616863, %rcx # imm = 0x6C656E6E616863
xorq 0x5(%rsp), %rcx
orq %rax, %rcx
je 0x3a55
movq 0x8(%rbx), %rdx
movl 0x2c(%rbx), %ecx
leaq 0x3c08(%rip), %rdi      # 0x74fd
movq %rsp, %rsi
xorl %eax, %eax
callq 0x2050
jmp 0x3a0b
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x24(%r14)
cmpl $0x80, %eax
jl 0x39ca
movl 0x2c(%rbx), %esi
leaq 0x3aac(%rip), %rdi      # 0x73d6
xorl %eax, %eax
callq 0x2050
movl $0x7f, 0x24(%r14)
jmp 0x39ca
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x2c(%r14)
leaq 0x800(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2880
cmpw $0x2f, (%r15)
jne 0x3a1d
leaq 0x400(%rsp), %rsi
movq %rbx, %rdi
callq 0x2880
cmpl $0x2, %eax
jne 0x3a35
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x30(%r14)
cmpl $0x0, 0x2c(%r14)
je 0x3a8f
testl %eax, %eax
jne 0x39ca
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x3abf(%rip), %rdi      # 0x7473
jmp 0x37bf
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x28(%r14)
leaq 0x800(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2880
xorl %eax, %eax
cmpw $0x3b, (%r14)
je 0x3a10
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x3ef3(%rip), %rdi      # 0x78e8
leaq 0x3b28(%rip), %rsi      # 0x7524
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 0x3ebc(%rip), %rdi      # 0x78e8
leaq 0x3a03(%rip), %rsi      # 0x7436
jmp 0x39fc
movq 0x8(%rbx), %rcx
movl 0x2c(%rbx), %r8d
leaq 0x3ea4(%rip), %rdi      # 0x78e8
leaq 0x3cc0(%rip), %rsi      # 0x770b
leaq 0x400(%rsp), %rdx
jmp 0x3a04
leaq 0x400(%rsp), %rdi
callq 0x22c0
movl %eax, 0x34(%r14)
cmpl $0x10, %eax
jl 0x39ca
movl 0x2c(%rbx), %edx
leaq 0x3a43(%rip), %rdi      # 0x74bc
movl %eax, %esi
xorl %eax, %eax
callq 0x2050
movl $0x9, 0x34(%r14)
jmp 0x39ca
movq 0x8(%rbx), %rsi
movl 0x2c(%rbx), %edx
leaq 0x399b(%rip), %rdi      # 0x7438
jmp 0x37bf