// File: /workspace/github_cpp_makefile_star2_O2/EstherJin[P]TetrisRemake/main.cc
// Function: main
int main(int argc, char *argv[]) {
  cin.exceptions(ios::eofbit|ios::failbit);
  bool textOnly = false;
  int startlvl = 0;
  string script1 = "sequence1.txt";
  string script2 = "sequence2.txt";
  unsigned int seed = 1;

  for (int i = 1; i < argc; ++i) {
    string argvv = argv[i];
    if (argvv == "-text"){
      textOnly = true;
    } else if (argvv == "-startlevel"){
      ++i;
      if (i < argc){
        startlvl = stoi(argv[i]);
        if (!((startlvl >= 0) && (startlvl <= 4))) {
          startlvl = 0;
        }
      }
    } else if (argvv == "-scriptfile1"){
      ++i;
      if (i < argc){
        script1 = argv[i];
      }
    } else if (argvv == "-scriptfile2"){
      ++i;
      if (i < argc){
        script2 = argv[i];
      }
    } else if (argvv == "-seed"){
      ++i;
      if (i < argc){
        int seedd = stoi(argv[i]);
        if (seedd >= 0) {
          seed = seedd;
        }
      }
    }
  }

  string cmd;
  Interpreter interpret;
  Game g{startlvl, textOnly, script1, script2, seed};
  g.print(cout);
  int turn = 1;

  try {
  while (true) {
    cin >> cmd;
	if (cin.eof()) break;
    string comm;
    interpret.processCommands(cmd, &g, &turn);
  }
  }
  catch (ios::failure &) {}
  catch (int i){}
  cout << "Thanks for playing!"<< endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r14
movl %edi, %r15d
movq 0x1474e(%rip), %rcx     # 0x19fd8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
pushq $0x6
popq %rsi
callq 0x50d0
leaq 0xb761(%rip), %rsi      # 0x11004
leaq 0x78(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x5d02
leaq 0xb756(%rip), %rsi      # 0x11012
leaq 0x58(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x5d02
pushq $0x1
popq %rbx
leaq 0x108(%rsp), %r13
leaq 0x98(%rsp), %rbp
movl %ebx, 0x4(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
cmpl %r15d, %ebx
jge 0x5a50
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x5d02
movq %r13, %rdi
leaq 0xb70a(%rip), %rsi      # 0x11020
callq 0x5d3d
testb %al, %al
je 0x5932
movb $0x1, %al
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x5140
incl %ebx
jmp 0x58f1
movq %r13, %rdi
leaq 0xb6ea(%rip), %rsi      # 0x11026
callq 0x5d3d
testb %al, %al
je 0x5987
incl %ebx
cmpl %r15d, %ebx
jge 0x5926
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
movq %rbp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x5d02
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x5d4a
movl %eax, %r12d
movq %rbp, %rdi
callq 0x5140
cmpl $0x5, %r12d
movl $0x0, %eax
cmovael %eax, %r12d
jmp 0x5926
movq %r13, %rdi
leaq 0xb6a1(%rip), %rsi      # 0x11032
callq 0x5d3d
testb %al, %al
je 0x59b7
incl %ebx
cmpl %r15d, %ebx
jge 0x5926
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
leaq 0x78(%rsp), %rdi
callq 0x54b0
jmp 0x5926
movq %r13, %rdi
leaq 0xb67e(%rip), %rsi      # 0x1103f
callq 0x5d3d
testb %al, %al
je 0x59eb
incl %ebx
cmpl %r15d, %ebx
jge 0x5926
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
leaq 0x58(%rsp), %rdi
callq 0x54b0
jmp 0x5926
movq %r13, %rdi
leaq 0xb657(%rip), %rsi      # 0x1104c
callq 0x5d3d
testb %al, %al
je 0x5926
incl %ebx
cmpl %r15d, %ebx
jge 0x5926
movslq %ebx, %rax
movq (%r14,%rax,8), %rsi
movq %rbp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x5d02
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x5d4a
movl %eax, 0x8(%rsp)
movq %rbp, %rdi
callq 0x5140
movl 0x8(%rsp), %ecx
testl %ecx, %ecx
movl 0x4(%rsp), %eax
cmovnsl %ecx, %eax
movl %eax, 0x4(%rsp)
jmp 0x5926
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x98(%rsp), %rdi
callq 0xa4ac
leaq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x5380
leaq 0xc8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x5380
movzbl 0x10(%rsp), %edx
andl $0x1, %edx
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rcx
leaq 0xc8(%rsp), %r8
movl %r12d, %esi
movl 0x4(%rsp), %r9d
callq 0x8c04
leaq 0xc8(%rsp), %rdi
callq 0x5140
leaq 0xe8(%rsp), %rdi
callq 0x5140
movq 0x144e0(%rip), %rsi     # 0x19fc0
leaq 0x108(%rsp), %rdi
callq 0x8eac
leaq 0xc(%rsp), %rax
movl $0x1, (%rax)
leaq 0x38(%rsp), %r15
leaq 0x188(%rsp), %r12
leaq 0x98(%rsp), %r13
leaq 0x108(%rsp), %rbp
leaq 0x18(%rsp), %rbx
movq 0x144b7(%rip), %r14     # 0x19fd8
movq %r14, %rdi
movq %r15, %rsi
callq 0x5340
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x20(%r14,%rax)
jne 0x5c55
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x5380
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0xc(%rsp), %rcx
callq 0xb514
movq %r12, %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x5140
jmp 0x5b1a
jmp 0x5bd6
jmp 0x5be8
jmp 0x5cbe
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x5140
jmp 0x5ba2
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x5140
jmp 0x5cce
movq %rax, %rbx
jmp 0x5cce
movq %rax, %rbx
jmp 0x5cdb
movq %rax, %rbx
jmp 0x5cef
movq %rax, %rbx
jmp 0x5cf9
jmp 0x5be8
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5140
jmp 0x5beb
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x5ce0
movq %rdx, %r14
movq %rax, %rbx
jmp 0x5c13
movq %rdx, %r14
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x5140
leaq 0x18(%rsp), %rdi
callq 0x5140
jmp 0x5c2d
movq %rax, %rbx
jmp 0x5ce5
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x2, %r14d
jne 0x5c42
movq %rbx, %rdi
callq 0x5110
callq 0x5410
jmp 0x5c55
cmpl $0x1, %r14d
jne 0x5cc1
movq %rbx, %rdi
callq 0x5110
callq 0x5410
movq 0x14364(%rip), %rdi     # 0x19fc0
leaq 0xb3ef(%rip), %rsi      # 0x11052
callq 0x52b0
movq %rax, %rdi
callq 0x5160
leaq 0x108(%rsp), %rdi
callq 0x5d66
leaq 0x98(%rsp), %rdi
callq 0x5edc
leaq 0x38(%rsp), %rdi
callq 0x5140
leaq 0x58(%rsp), %rdi
callq 0x5140
leaq 0x78(%rsp), %rdi
callq 0x5140
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5cbe
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x5d66
leaq 0x98(%rsp), %rdi
callq 0x5edc
leaq 0x38(%rsp), %rdi
callq 0x5140
leaq 0x58(%rsp), %rdi
callq 0x5140
leaq 0x78(%rsp), %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x5450
nop