// File: mikeakohn[P]drumsplusplus/build/../src/playdpp.cxx
// Function: main
int main(int argc, char *argv[])
{
  Tokens tokens;
  MidiFile midi_file;
  MidiPlayer midi_player;
  Song *song;
  const char *infile = "";
  const char *outfile = "/dev/midi00";
  int t;
  int interactive = 0;


  if (argc == 1)
  {
    printf(DLPLAYER_INFO);
    printf(COPYRIGHT);
    printf("Usage: playdpp <infile>\n\n");
    printf("       -midi <midi_device: default is /dev/midi00>\n");
    printf("       -o <.midi file to output to: disables /dev/midi>\n");
    printf("       -i [ will show patters as they are played ]\n\n");
    exit(0);
  }

  for (t = 1; t < argc; t++)
  {
    if (strcmp(argv[t], "-i") == 0)
    {
      interactive = 1;
    }
      else
    if (strcmp(argv[t],"-midi") == 0)
    {
      outfile = argv[++t];
    }
      else
    if (strcmp(argv[t],"-o") == 0)
    {
      outfile = argv[++t];

      if (midi_file.open(outfile) != 0)
      {
        exit(1);
      }
    }
      else
    if (argv[t][0] == '-')
    {
      printf("Unknown option\n");
      exit(1);
    }
      else
    {
      infile = argv[t];
    }
  }

  if (infile[0] == 0)
  {
    printf("\nError: No input filename specified.\n\n");
    exit(1);
  }

  if (strcmp(infile, outfile) == 0)
  {
    printf("\nError: The input / output filenames cannot be the same.\n\n");
    exit(1);
  }

  printf(DLPLAYER_INFO);
  printf(COPYRIGHT);
  fflush(stdout);

  if (tokens.open(infile) != 0)
  {
    printf("Error: Couldn't open file %s\n", infile);
    exit(1);
  }

  if (!midi_file.is_open())
  {
    if (midi_player.open(outfile) != 0)
    {
      tokens.close();
      exit(1);
    }
  }

  printf("Infile: %s\n\n", infile);

  song = new Song();

  if (interactive == 1) { song->set_interactive(); }

  song->set_midi(&midi_file, &midi_player);
  song->parse(&tokens);

#ifdef DEBUG
  song->print();
#endif

  tokens.close();

  if (midi_file.is_open())
  {
    midi_file.close();
  }
    else
  {
    midi_player.close();
  }

  delete song;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2a10
leaq -0x50(%rbp), %rdi
callq 0x2f60
jmp 0x255d
leaq -0x60(%rbp), %rdi
callq 0x3740
jmp 0x2568
leaq 0xdbea(%rip), %rax      # 0x10159
movq %rax, -0x70(%rbp)
leaq 0xda8a(%rip), %rax      # 0x10004
movq %rax, -0x78(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x2629
leaq 0xda7a(%rip), %rdi      # 0x10010
xorl %eax, %eax
callq 0x2060
jmp 0x259f
leaq 0xda92(%rip), %rdi      # 0x10038
xorl %eax, %eax
callq 0x2060
jmp 0x25af
leaq 0xdaa5(%rip), %rdi      # 0x1005b
xorl %eax, %eax
callq 0x2060
jmp 0x25bf
leaq 0xdaaf(%rip), %rdi      # 0x10075
xorl %eax, %eax
callq 0x2060
jmp 0x25cf
leaq 0xdad3(%rip), %rdi      # 0x100a9
xorl %eax, %eax
callq 0x2060
jmp 0x25df
leaq 0xdafc(%rip), %rdi      # 0x100e2
xorl %eax, %eax
callq 0x2060
jmp 0x25ef
xorl %edi, %edi
callq 0x22d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x29a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x299e
movl $0x1, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2754
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xdac8(%rip), %rsi      # 0x10117
callq 0x2320
cmpl $0x0, %eax
jne 0x2665
movl $0x1, -0x80(%rbp)
jmp 0x2744
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xdaa2(%rip), %rsi      # 0x1011a
callq 0x2320
cmpl $0x0, %eax
jne 0x269f
movq -0x10(%rbp), %rax
movl -0x7c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x7c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
jmp 0x2742
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xda6e(%rip), %rsi      # 0x10120
callq 0x2320
cmpl $0x0, %eax
jne 0x2700
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movl %ecx, %edx
incl %edx
movl %edx, -0x7c(%rbp)
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x2f90
movl %eax, -0x84(%rbp)
jmp 0x26e9
movl -0x84(%rbp), %eax
cmpl $0x0, %eax
je 0x26fe
movl $0x1, %edi
callq 0x22d0
jmp 0x2740
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x272e
leaq 0xda08(%rip), %rdi      # 0x10123
xorl %eax, %eax
callq 0x2060
jmp 0x2724
movl $0x1, %edi
callq 0x22d0
movq -0x10(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
jmp 0x2740
jmp 0x2742
jmp 0x2744
jmp 0x2746
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2630
movq -0x70(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x277a
leaq 0xd9cc(%rip), %rdi      # 0x10133
xorl %eax, %eax
callq 0x2060
jmp 0x2770
movl $0x1, %edi
callq 0x22d0
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x2320
cmpl $0x0, %eax
jne 0x27a6
leaq 0xd9c7(%rip), %rdi      # 0x1015a
xorl %eax, %eax
callq 0x2060
jmp 0x279c
movl $0x1, %edi
callq 0x22d0
leaq 0xd863(%rip), %rdi      # 0x10010
xorl %eax, %eax
callq 0x2060
jmp 0x27b6
leaq 0xd87b(%rip), %rdi      # 0x10038
xorl %eax, %eax
callq 0x2060
jmp 0x27c6
movq 0x15803(%rip), %rax     # 0x17fd0
movq (%rax), %rdi
callq 0x22a0
jmp 0x27d7
movq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x2a70
movl %eax, -0x88(%rbp)
jmp 0x27ec
movl -0x88(%rbp), %eax
cmpl $0x0, %eax
je 0x2815
movq -0x70(%rbp), %rsi
leaq 0xd993(%rip), %rdi      # 0x10195
xorl %eax, %eax
callq 0x2060
jmp 0x280b
movl $0x1, %edi
callq 0x22d0
leaq -0x50(%rbp), %rdi
callq 0x29d0
movb %al, -0x89(%rbp)
jmp 0x2826
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x2869
jmp 0x2832
movq -0x78(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x3770
movl %eax, -0x90(%rbp)
jmp 0x2847
movl -0x90(%rbp), %eax
cmpl $0x0, %eax
je 0x2867
leaq -0x40(%rbp), %rdi
callq 0x2ae0
jmp 0x285d
movl $0x1, %edi
callq 0x22d0
jmp 0x2869
movq -0x70(%rbp), %rsi
leaq 0xd93f(%rip), %rdi      # 0x101b3
xorl %eax, %eax
callq 0x2060
jmp 0x287d
movl $0x130, %edi            # imm = 0x130
callq 0x2220
movq %rax, -0x98(%rbp)
jmp 0x2890
movq -0x98(%rbp), %rdi
callq 0x51f0
jmp 0x289e
movq -0x98(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpl $0x1, -0x80(%rbp)
jne 0x28de
movq -0x68(%rbp), %rdi
callq 0x29f0
jmp 0x28ba
jmp 0x28de
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x130, %esi            # imm = 0x130
callq 0x2230
jmp 0x299e
movq -0x68(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x52c0
jmp 0x28f1
movq -0x68(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x52f0
jmp 0x2900
leaq -0x40(%rbp), %rdi
callq 0x2ae0
jmp 0x290b
leaq -0x50(%rbp), %rdi
callq 0x29d0
movb %al, -0x99(%rbp)
jmp 0x291c
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0x2928
jmp 0x2935
leaq -0x50(%rbp), %rdi
callq 0x3000
jmp 0x2933
jmp 0x2942
leaq -0x60(%rbp), %rdi
callq 0x3840
jmp 0x2940
jmp 0x2942
movq -0x68(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x2970
movq -0xa8(%rbp), %rdi
callq 0x5260
movq -0xa8(%rbp), %rdi
movl $0x130, %esi            # imm = 0x130
callq 0x2230
movl $0x0, -0x4(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3760
leaq -0x50(%rbp), %rdi
callq 0x2f80
leaq -0x40(%rbp), %rdi
callq 0x2a50
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x3760
leaq -0x50(%rbp), %rdi
callq 0x2f80
leaq -0x40(%rbp), %rdi
callq 0x2a50
movq -0x58(%rbp), %rdi
callq 0x23c0
nopw %cs:(%rax,%rax)
nopl (%rax)