// File: /workspace/github_cpp_makefile_star2_O2/EstherJin[P]TetrisRemake/interpreter.cc
// Function: Interpreter::processCommands(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Game*, int*)
void Interpreter::processCommands(string cmd, Game *g, int *turn){
  string command = "";
  int n = 1;
  if ((cmd[0] >= '0') && (cmd[0] <= '9')) {
    int i = 1;
    n = cmd[0] - '0';
    while ((cmd[i] >= '0') && (cmd[i] <= '9')){
      n = n * 10 + (cmd[i] - '0');
      ++i;
    }
    cmd = cmd.substr(i);
  }
  map<string, vector<string>>::iterator it;
  for(it = commands.begin(); it != commands.end(); it++) {
    string key = it->first;
    vector<string> commands = it->second;
    int size = commands.size();
    for(int i = 0; i < size; ++i){
      if (cmd == commands.at(i)){
        command = key;
      }
    }
  }
  if (command != ""){
    if (command == "norandom"){
      string file;
      cin >> file;
      g->processCommand(command, file, n, *turn);
      g->print(cout);
    } else if (command == "sequence"){
      string file;
      cin >> file;
      ifstream f{file};
      if (f){
        string comm;
        streambuf *cinbuf = cin.rdbuf();
        cin.rdbuf(f.rdbuf());
        while(f >> comm){
          processCommands(comm, g, turn);
        }
        cin.rdbuf(cinbuf);
      }
    } else if (command == "drop") {
      try{
      g->processCommand(command, n, *turn);
      g->print(cout);
      } catch(int i){
        *turn = (*turn % 2) + 1;
        g->print(cout);
      } catch(char const* str){
        cout << "Restart? Yes/No:";
        string s;
        while (cin >> s){
          if (s == "Yes"){
            *turn = 1;
            g->processCommand(command, n, *turn);
            return;
          }
        }
        throw 1;
      }
    } else if (command == "restart") {
      *turn = 1;
      g->processCommand(command, n, *turn);
      g->print(cout);
    } else if ((command == "left")||(command == "right")||(command == "down")) {
      try{
      g->processCommand(command, n, *turn);
      g->print(cout);
      } catch(int i){
        *turn = (*turn % 2) + 1;
        g->print(cout);
      } catch(char const* str){
        *turn = 1;
        g->processCommand(command, n, *turn);
      } catch(char const* str){
        cout << "Restart? Yes/No:";
        string s;
        while (cin >> s){
          if (s == "Yes"){
            *turn = 1;
            g->processCommand(command, n, *turn);
            return;
          }
        }
        throw 1;
      }
    } else {
      g->processCommand(command, n, *turn);
      g->print(cout);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rcx, (%rsp)
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, 0x38(%rsp)
leaq 0x6235(%rip), %rsi      # 0x11770
leaq 0x18(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
callq 0x5d02
movq (%r13), %rax
movzbl (%rax), %r14d
leal -0x30(%r14), %ecx
cmpb $0x9, %cl
movq %rbx, 0x8(%rsp)
ja 0xb588
addl $-0x30, %r14d
pushq $0x1
popq %rdx
movzbl (%rax,%rdx), %ecx
leal -0x30(%rcx), %esi
cmpb $0x9, %sil
ja 0xb592
imull $0xa, %r14d, %esi
leal (%rsi,%rcx), %r14d
addl $-0x30, %r14d
incq %rdx
jmp 0xb56a
pushq $0x1
popq %rax
movq %rax, 0x10(%rsp)
jmp 0xb5c5
leaq 0x1b0(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r13, %rsi
callq 0x52f0
movq %r14, 0x10(%rsp)
leaq 0x1b0(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x5330
movq %rbx, %rdi
callq 0x5140
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rcx
addq $0x8, %rax
movq %rax, 0x60(%rsp)
leaq 0x1b0(%rsp), %rbp
leaq 0x40(%rsp), %rbx
leaq 0x18(%rsp), %r12
cmpq 0x60(%rsp), %rcx
je 0xb682
leaq 0x20(%rcx), %rsi
movq %rcx, %r14
movq %rbp, %rdi
callq 0x5380
movq %r14, 0x68(%rsp)
leaq 0x40(%r14), %rsi
movq %rbx, %rdi
callq 0xbda8
movq 0x48(%rsp), %r14
subq 0x40(%rsp), %r14
shrq $0x5, %r14
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %r15d, %r15d
cmpq %r15, %r14
je 0xb660
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbe24
movq %r13, %rdi
movq %rax, %rsi
callq 0xbdfb
testb %al, %al
je 0xb65b
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5190
incq %r15
jmp 0xb631
movq %rbx, %rdi
callq 0x5f56
movq %rbp, %rdi
callq 0x5140
movq 0x68(%rsp), %rdi
callq 0x51f0
movq %rax, %rcx
jmp 0xb5e9
leaq 0x60e7(%rip), %rsi      # 0x11770
leaq 0x18(%rsp), %rdi
callq 0xbe45
testb %al, %al
je 0xb970
leaq 0x5c18(%rip), %rsi      # 0x112ba
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
je 0xb762
leaq 0x1c0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xe909(%rip), %rdi      # 0x19fd8
leaq 0x1b0(%rsp), %rsi
callq 0x5340
movq 0x8(%rsp), %rbx
leaq 0x130(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5380
leaq 0x110(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5380
movq 0x10(%rsp), %rcx
movq (%rsp), %rax
movl (%rax), %r8d
leaq 0x130(%rsp), %rsi
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
callq 0x96a2
leaq 0x110(%rsp), %rdi
callq 0x5140
leaq 0x130(%rsp), %rdi
callq 0x5140
movq 0xe873(%rip), %rsi      # 0x19fc0
movq %rbx, %rdi
callq 0x8eac
leaq 0x1b0(%rsp), %rdi
jmp 0xb96b
leaq 0x5e13(%rip), %rsi      # 0x1157c
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
movq 0x8(%rsp), %rbp
je 0xb866
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xe840(%rip), %rbx      # 0x19fd8
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x5340
leaq 0x1b0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x53f0
movq 0x1b0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x1d0(%rsp,%rax)
jne 0xb959
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movq 0xe8(%rbx,%rax), %r14
leaq 0x1c0(%rsp), %rsi
callq 0x5470
leaq 0x1b0(%rsp), %r15
leaq 0xf0(%rsp), %r12
leaq 0x190(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x5340
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xb93a
movq %r13, %rdi
movq %r12, %rsi
callq 0x5380
movq 0x38(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq (%rsp), %rcx
callq 0xb514
movq %r13, %rdi
callq 0x5140
jmp 0xb820
leaq 0x5a2e(%rip), %rsi      # 0x1129b
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
je 0xb8ce
leaq 0xd0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
leaq 0xd0(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq 0x10(%rsp), %rdx
callq 0x9340
leaq 0xd0(%rsp), %rdi
callq 0x5140
movq 0xe6ff(%rip), %rsi      # 0x19fc0
movq %rbx, %rdi
callq 0x8eac
jmp 0xb970
leaq 0x59dd(%rip), %rsi      # 0x112b2
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
je 0xb98c
movq (%rsp), %rax
movl $0x1, (%rax)
leaq 0x170(%rsp), %rbx
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
callq 0x9340
movq %rbx, %rdi
callq 0x5140
movq 0xe690(%rip), %rsi      # 0x19fc0
movq %r14, %rdi
callq 0x8eac
jmp 0xb970
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5470
leaq 0xf0(%rsp), %rdi
callq 0x5140
leaq 0x1b0(%rsp), %rdi
callq 0x5080
leaq 0x40(%rsp), %rdi
callq 0x5140
leaq 0x18(%rsp), %rdi
callq 0x5140
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58ec(%rip), %rsi      # 0x1127f
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
jne 0xb9cb
leaq 0x58dc(%rip), %rsi      # 0x11284
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
jne 0xb9cb
leaq 0x58f0(%rip), %rsi      # 0x112ad
leaq 0x18(%rsp), %rdi
callq 0x5d3d
testb %al, %al
je 0xba1e
leaq 0x90(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
leaq 0x90(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq 0x10(%rsp), %rdx
callq 0x9340
leaq 0x90(%rsp), %rdi
callq 0x5140
movq 0xe5af(%rip), %rsi      # 0x19fc0
movq %rbx, %rdi
callq 0x8eac
jmp 0xb970
leaq 0x150(%rsp), %rbx
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
callq 0x9340
jmp 0xb921
movq %rax, %r12
leaq 0x150(%rsp), %rdi
jmp 0xbd2b
movq %rdx, %rbx
movq %rax, %r12
leaq 0x90(%rsp), %rdi
callq 0x5140
jmp 0xba8e
movq %rax, %r12
leaq 0x170(%rsp), %rdi
jmp 0xbd2b
movq %rdx, %rbx
movq %rax, %r12
cmpl $0x2, %ebx
jne 0xbac1
movq %r12, %rdi
callq 0x5110
movq (%rsp), %rsi
movl (%rsi), %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
incl %edx
movl %edx, (%rsi)
movq 0xe50e(%rip), %rsi      # 0x19fc0
movq 0x8(%rsp), %rdi
callq 0x8eac
jmp 0xbc42
cmpl $0x1, %ebx
jne 0xbd30
movq %r12, %rdi
callq 0x5110
movq (%rsp), %rax
movl $0x1, (%rax)
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
leaq 0x70(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x9340
leaq 0x70(%rsp), %rdi
jmp 0xbc3d
movq %rax, %r12
leaq 0x70(%rsp), %rdi
jmp 0xbc91
jmp 0xbc7f
jmp 0xbc7f
movq %rdx, %rbx
movq %rax, %r12
leaq 0xd0(%rsp), %rdi
callq 0x5140
jmp 0xbb46
jmp 0xbce8
movq %rdx, %rbx
movq %rax, %r12
cmpl $0x2, %ebx
jne 0xbb79
movq %r12, %rdi
callq 0x5110
movq (%rsp), %rsi
movl (%rsi), %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
incl %edx
movl %edx, (%rsi)
movq 0xe456(%rip), %rsi      # 0x19fc0
movq 0x8(%rsp), %rdi
callq 0x8eac
jmp 0xbc42
cmpl $0x1, %ebx
jne 0xbd30
movq %r12, %rdi
callq 0x5110
movq 0xe42f(%rip), %rdi      # 0x19fc0
leaq 0x5a06(%rip), %rsi      # 0x1159e
callq 0x52b0
leaq 0x1c0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0xe420(%rip), %rbx      # 0x19fd8
leaq 0x1b0(%rsp), %r14
leaq 0x59e8(%rip), %r15      # 0x115af
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5340
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xbc4c
movq %r14, %rdi
movq %r15, %rsi
callq 0x5d3d
testb %al, %al
je 0xbbc7
movq (%rsp), %rax
movl $0x1, (%rax)
leaq 0xb0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x5380
movq (%rsp), %rax
movl (%rax), %ecx
leaq 0xb0(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x9340
leaq 0xb0(%rsp), %rdi
callq 0x5140
leaq 0x1b0(%rsp), %rdi
callq 0x5140
callq 0x5410
jmp 0xb970
pushq $0x4
popq %rdi
callq 0x5170
movl $0x1, (%rax)
movq 0xe337(%rip), %rsi      # 0x19f98
movq %rax, %rdi
xorl %edx, %edx
callq 0x5440
movq %rax, %r12
leaq 0xb0(%rsp), %rdi
callq 0x5140
jmp 0xbc89
jmp 0xbc7f
movq %rax, %r12
jmp 0xbc96
jmp 0xbc86
movq %rax, %r12
leaq 0x1b0(%rsp), %rdi
callq 0x5140
callq 0x5410
jmp 0xbd30
jmp 0xbca2
movq %rax, %r12
jmp 0xbd05
movq %rax, %r12
leaq 0x110(%rsp), %rdi
callq 0x5140
jmp 0xbcbc
movq %rax, %r12
leaq 0x130(%rsp), %rdi
callq 0x5140
jmp 0xbd23
jmp 0xbd0c
jmp 0xbd11
movq %rax, %r12
jmp 0xbd3a
jmp 0xbd0c
movq %rax, %r12
leaq 0x190(%rsp), %rdi
callq 0x5140
jmp 0xbceb
movq %rax, %r12
leaq 0xf0(%rsp), %rdi
callq 0x5140
leaq 0x1b0(%rsp), %rdi
callq 0x5080
leaq 0x40(%rsp), %rdi
jmp 0xbd2b
movq %rax, %r12
jmp 0xbd30
movq %rax, %r12
jmp 0xbd23
movq %rax, %r12
leaq 0x40(%rsp), %rdi
callq 0x5f56
leaq 0x1b0(%rsp), %rdi
callq 0x5140
leaq 0x18(%rsp), %rdi
callq 0x5140
movq %r12, %rdi
callq 0x5450