// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1c8, %rsp            # imm = 0x1C8
movq %rsi, %r12
movl %edi, %r15d
movq 0x1556e(%rip), %rcx     # 0x1afd8
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl $0x6, 0x1c(%rcx,%rax)
movl 0x20(%rcx,%rax), %esi
callq 0x5460
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd56b(%rip), %rsi      # 0x13004
leaq 0xd571(%rip), %rdx      # 0x13011
leaq 0xa8(%rsp), %rdi
callq 0x65c6
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd552(%rip), %rsi      # 0x13012
leaq 0xd558(%rip), %rdx      # 0x1301f
leaq 0x88(%rsp), %rdi
callq 0x65c6
cmpl $0x2, %r15d
jl 0x5dfd
movl $0x1, %r14d
leaq 0x158(%rsp), %rbx
leaq 0x148(%rsp), %r13
leaq 0x38(%rsp), %rbp
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x1, 0xc(%rsp)
movq %r12, 0x10(%rsp)
movslq %r14d, %rax
movq (%r12,%rax,8), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x6342
movq %r13, %rdi
leaq 0xd4ec(%rip), %rsi      # 0x13020
callq 0x50b0
testl %eax, %eax
je 0x5c67
movq %r13, %rdi
leaq 0xd4db(%rip), %rsi      # 0x13026
callq 0x50b0
testl %eax, %eax
je 0x5c73
movq %r13, %rdi
leaq 0xd4d0(%rip), %rsi      # 0x13032
callq 0x50b0
testl %eax, %eax
je 0x5d40
movq %r13, %rdi
leaq 0xd4c6(%rip), %rsi      # 0x1303f
callq 0x50b0
testl %eax, %eax
je 0x5d8c
movq %r13, %rdi
leaq 0xd4bc(%rip), %rsi      # 0x1304c
callq 0x50b0
testl %eax, %eax
jne 0x5dd2
incl %r14d
cmpl %r15d, %r14d
jge 0x5dd2
movslq %r14d, %rax
movq (%r12,%rax,8), %rsi
movq %rbp, %rdi
leaq 0xc8(%rsp), %rdx
callq 0x6342
movq 0x38(%rsp), %rbx
callq 0x5050
movq %rax, %rbp
movl (%rax), %eax
movl %eax, 0x1c(%rsp)
movl $0x0, (%rbp)
movq %rbx, %rdi
leaq 0x68(%rsp), %rsi
movl $0xa, %edx
callq 0x5390
cmpq %rbx, 0x68(%rsp)
je 0x6015
movq %rax, %r12
addq $-0x80000000, %rax      # imm = 0x80000000
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
jb 0x6009
movl (%rbp), %eax
cmpl $0x22, %eax
je 0x6009
testl %eax, %eax
jne 0x5c2a
movl 0x1c(%rsp), %eax
movl %eax, (%rbp)
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x5c46
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x52c0
testl %r12d, %r12d
movl 0xc(%rsp), %eax
cmovnsl %r12d, %eax
movl %eax, 0xc(%rsp)
leaq 0x158(%rsp), %rbx
movq 0x10(%rsp), %r12
jmp 0x5d36
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x5dd2
incl %r14d
cmpl %r15d, %r14d
jge 0x5dd2
movslq %r14d, %rax
movq (%r12,%rax,8), %rsi
movq %rbp, %rdi
leaq 0xc8(%rsp), %rdx
callq 0x6342
movq 0x38(%rsp), %r12
callq 0x5050
movq %rax, %rbp
movl (%rax), %ebx
movl $0x0, (%rax)
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
movl $0xa, %edx
callq 0x5390
cmpq %r12, 0x68(%rsp)
je 0x5ffd
movq %rax, %rcx
addq $-0x80000000, %rax      # imm = 0x80000000
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
cmpq %rdx, %rax
jb 0x5ff1
movl (%rbp), %eax
cmpl $0x22, %eax
je 0x5ff1
testl %eax, %eax
movq 0x10(%rsp), %r12
jne 0x5cfc
movl %ebx, (%rbp)
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x5d1e
movq %rcx, %rbx
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %rbx, %rcx
cmpl $0x5, %ecx
movl $0x0, %eax
cmovael %eax, %ecx
movq %rcx, 0x20(%rsp)
leaq 0x158(%rsp), %rbx
leaq 0x38(%rsp), %rbp
jmp 0x5dd2
incl %r14d
cmpl %r15d, %r14d
jge 0x5dd2
movslq %r14d, %rax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %r12
movq 0xb0(%rsp), %rbp
movq %r12, %rdi
callq 0x5120
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
leaq 0x38(%rsp), %rbp
movq %r12, %rcx
movq 0x10(%rsp), %r12
movq %rax, %r8
callq 0x5400
jmp 0x5dd2
incl %r14d
cmpl %r15d, %r14d
jge 0x5dd2
movslq %r14d, %rax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %r12
movq 0x90(%rsp), %rbp
movq %r12, %rdi
callq 0x5120
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
leaq 0x38(%rsp), %rbp
movq %r12, %rcx
movq 0x10(%rsp), %r12
movq %rax, %r8
callq 0x5400
movq 0x148(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5def
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x52c0
incl %r14d
cmpl %r15d, %r14d
jl 0x5b18
jmp 0x5e17
movq $0x0, 0x20(%rsp)
movl $0x1, 0xc(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x38(%rsp), %rdi
callq 0xad44
leaq 0x138(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %rdi
callq 0x6530
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x6530
movzbl 0x28(%rsp), %edx
andl $0x1, %edx
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rcx
leaq 0x108(%rsp), %r8
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %r9d
callq 0x9168
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x5ed9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5ef6
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x150cb(%rip), %rsi     # 0x1afc8
leaq 0x148(%rsp), %rdi
callq 0x95ca
leaq 0x34(%rsp), %rax
movl $0x1, (%rax)
leaq 0xd8(%rsp), %rbx
leaq 0xf8(%rsp), %r14
leaq 0x68(%rsp), %r15
leaq 0xe8(%rsp), %r12
leaq 0x148(%rsp), %rbp
movq 0x15097(%rip), %r13     # 0x1afd8
movq %r13, %rdi
movq %r15, %rsi
callq 0x5350
movq (%r13), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x20(%r13,%rax)
jne 0x6188
movq %rbx, 0xc8(%rsp)
movq $0x0, 0xd0(%rsp)
movb $0x0, 0xd8(%rsp)
movq %r14, 0xe8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x6530
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x34(%rsp), %rcx
callq 0xc4f4
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x5fcb
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xc8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5f3a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x5f3a
leaq 0xd06e(%rip), %rdi      # 0x13066
callq 0x53b0
leaq 0xd062(%rip), %rdi      # 0x13066
callq 0x51a0
leaq 0xd056(%rip), %rdi      # 0x13066
callq 0x53b0
leaq 0xd04a(%rip), %rdi      # 0x13066
callq 0x51a0
jmp 0x60b1
movq %rax, %r15
cmpl $0x0, (%rbp)
jne 0x60c2
movl 0x1c(%rsp), %eax
movl %eax, (%rbp)
jmp 0x60c2
jmp 0x62ba
movq %rax, %r15
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x6069
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x6069
movq %rax, %r15
movq 0x128(%rsp), %rdi
cmpq %rbx, %rdi
je 0x62ca
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x62ca
movq %rax, %r15
jmp 0x62ca
movq %rax, %r15
jmp 0x62d4
movq %rax, %r15
jmp 0x6315
movq %rax, %r15
jmp 0x633a
jmp 0x60b1
movq %rax, %r15
jmp 0x60de
movq %rax, %r15
cmpl $0x0, (%rbp)
jne 0x60c2
movl %ebx, (%rbp)
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x60de
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x62f0
movq 0x158(%rsp), %rsi
jmp 0x62e8
movq %rax, %r15
jmp 0x62f0
movq %rdx, %r12
movq %rax, %r15
jmp 0x6137
movq %rdx, %r12
movq %rax, %r15
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6137
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xc8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x615c
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x615c
movq %rdx, %r12
movq %rax, %r15
cmpl $0x2, %r12d
jne 0x6171
movq %r15, %rdi
callq 0x5110
callq 0x5430
jmp 0x6188
cmpl $0x1, %r12d
jne 0x62bd
movq %r15, %rdi
callq 0x5110
callq 0x5430
movq 0x14e39(%rip), %rbx     # 0x1afc8
leaq 0xcebc(%rip), %rsi      # 0x13052
movl $0x13, %edx
movq %rbx, %rdi
callq 0x5310
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x5280
movsbl %al, %esi
movq 0x14e07(%rip), %rdi     # 0x1afc8
callq 0x5030
movq %rax, %rdi
callq 0x51c0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
leaq 0xb8(%rsp), %rbx
leaq 0x98(%rsp), %r14
je 0x61f0
callq 0x63de
movq 0x1a8(%rsp), %rdi
testq %rdi, %rdi
je 0x6202
callq 0x63de
leaq 0x188(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6223
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x168(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6244
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x38(%rsp), %rdi
callq 0x644e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x626a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x6287
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xa8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x62a4
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x52c0
xorl %eax, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x62ba
movq %rax, %r15
leaq 0x148(%rsp), %rdi
callq 0x6380
leaq 0x38(%rsp), %rdi
callq 0x644e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x62f0
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x6315
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x52c0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x633a
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %r15, %rdi
callq 0x5480