// File: antoniogarro[P]Hara/gtp.cpp
// Function: GTP::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int GTP::parse(const std::string &command_str)
{  
  std::stringstream auxstream(command_str);
  std::string auxstring;
  float auxint;
  int id;
  cmd_args.clear();
  cmd_int_args.clear();
  
  //TODO: findfirstof(#) and eliminate
  //TODO: handle empty lines
  
  auxstream >> auxstring;
  std::stringstream tempstream(auxstring);
  
  if (tempstream >> id) {
    //TODO:handle negative IDs??
    cmd_id = auxstring;
    cmd_id.append(" ");
    auxstream >> cmd_name;
  } else {
    cmd_id = " ";
    cmd_name = auxstring;
  }
  
  cmd = string_to_cmd(cmd_name);
  
  while (auxstream.good()) {
    auxstream >> auxstring;
    cmd_args.insert(cmd_args.end(), auxstring);
    
    tempstream.clear(); //!!!!
    tempstream.str(auxstring);
    tempstream >> auxint;
    cmd_int_args.insert(cmd_int_args.end(), auxint);
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3a0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0xa720
movq -0x3a8(%rbp), %rsi
movl %eax, %edx
leaq -0x198(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x33b0
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x3380
movq -0x3a0(%rbp), %rdi
addq $0x48, %rdi
callq 0xa740
movq -0x3a0(%rbp), %rdi
addq $0x60, %rdi
callq 0xa760
movq -0x398(%rbp), %rdi
movq -0x390(%rbp), %rsi
callq 0x3350
jmp 0x99fc
movl $0x10, %edi
movl $0x8, %esi
callq 0xa720
movl %eax, -0x3ac(%rbp)
jmp 0x9a13
movl -0x3ac(%rbp), %edx
leaq -0x358(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x33b0
jmp 0x9a2e
leaq -0x358(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3150
movq %rax, -0x3b8(%rbp)
jmp 0x9a4a
movq -0x3b8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3340
movb %al, -0x3b9(%rbp)
jmp 0x9a68
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x9a77
jmp 0x9afe
movq -0x3a0(%rbp), %rdi
addq $0x8, %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x3050
jmp 0x9a90
movq -0x3a0(%rbp), %rdi
addq $0x8, %rdi
leaq 0xa9f3(%rip), %rsi      # 0x14495
callq 0x3470
jmp 0x9aa9
movq -0x3a0(%rbp), %rsi
addq $0x28, %rsi
leaq -0x198(%rbp), %rdi
callq 0x3350
jmp 0x9ac2
jmp 0x9b32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x9cdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x31c0
jmp 0x9cdf
movq -0x3a0(%rbp), %rdi
addq $0x8, %rdi
leaq 0xa985(%rip), %rsi      # 0x14495
callq 0x3370
jmp 0x9b17
movq -0x3a0(%rbp), %rdi
addq $0x28, %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x3050
jmp 0x9b30
jmp 0x9b32
movq -0x3a0(%rbp), %rdi
movq %rdi, %rsi
addq $0x28, %rsi
callq 0x9eb0
movl %eax, -0x3c0(%rbp)
jmp 0x9b4d
movq -0x3a0(%rbp), %rax
movl -0x3c0(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x198(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x198(%rbp,%rax), %rdi
callq 0x33f0
movb %al, -0x3c1(%rbp)
jmp 0x9b7d
movb -0x3c1(%rbp), %al
testb $0x1, %al
jne 0x9b8c
jmp 0x9cb0
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x3350
jmp 0x9ba1
movq -0x3a0(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x3d8(%rbp)
callq 0xa990
movq %rax, -0x368(%rbp)
leaq -0x360(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0xa9c0
movq -0x3d8(%rbp), %rdi
movq -0x360(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0xa780
movq %rax, -0x3d0(%rbp)
jmp 0x9bf5
movq -0x3d0(%rbp), %rax
movq %rax, -0x370(%rbp)
movq -0x358(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x358(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x33e0
jmp 0x9c1f
leaq -0x358(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x32f0
jmp 0x9c34
leaq -0x358(%rbp), %rdi
leaq -0x1bc(%rbp), %rsi
callq 0x3080
jmp 0x9c49
movq -0x3a0(%rbp), %rdi
addq $0x60, %rdi
movq %rdi, -0x3e8(%rbp)
callq 0xac00
movq %rax, -0x380(%rbp)
leaq -0x378(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0xac30
movq -0x3e8(%rbp), %rdi
movq -0x378(%rbp), %rsi
leaq -0x1bc(%rbp), %rdx
callq 0xaa00
movq %rax, -0x3e0(%rbp)
jmp 0x9c9d
movq -0x3e0(%rbp), %rax
movq %rax, -0x388(%rbp)
jmp 0x9b5d
leaq -0x358(%rbp), %rdi
callq 0x31c0
leaq -0x1b8(%rbp), %rdi
callq 0x3160
leaq -0x198(%rbp), %rdi
callq 0x31c0
xorl %eax, %eax
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
leaq -0x1b8(%rbp), %rdi
callq 0x3160
leaq -0x198(%rbp), %rdi
callq 0x31c0
movq -0x1c8(%rbp), %rdi
callq 0x3410
nopw %cs:(%rax,%rax)