// File: Altius[P]hotspot2/src/hotspot2_part2.cpp
// Function: buildIntToChromNameMap(std::basic_ifstream<char, std::char_traits<char>>&, std::map<int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::less<int>, std::allocator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*>>>&)
bool buildIntToChromNameMap(ifstream& infile, map<int, string*>& mapOut)
{
  const int BUFSIZE(100);
  char buf[BUFSIZE], *p;
  int ID;
  map<int, string*>::const_iterator it;
  int linenum(0), fieldnum;

  while (infile.getline(buf, BUFSIZE))
    {
      linenum++;
      fieldnum = 1;
      if (!(p = strtok(buf, "\t")) || !*p)
	{
	MissingField:
	  cerr << "Error:  Failed to find field " << fieldnum
	       << " on line " << linenum
	       << " of the number-to-chromosomeName mapping file."
	       << endl << endl;
	  return false;
	}
      ID = atoi(p);
      it = mapOut.find(ID);
      if (it != mapOut.end())
	{
	  cerr << "Error:  Multiple entries found in the number-to-chromosomeName mapping file\n"
	       << "with value " << ID << " in the first column; each mapping must be unique."
	       << endl << endl;
	  return false;
	}
      fieldnum++;
      if (!(p = strtok(NULL, "\t")) || !*p)
	goto MissingField;
      mapOut[ID] = new string(p);
    }
  
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x64, -0x1c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4eb0
movl $0x0, -0x9c(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x64, %edx
callq 0x2090
movq %rax, %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x22b0
testb $0x1, %al
jne 0x2d6a
jmp 0x3025
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
movl $0x1, -0xa0(%rbp)
leaq -0x80(%rbp), %rdi
leaq 0x85a5(%rip), %rsi      # 0xb333
callq 0x2310
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x2dac
movq -0x88(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x2e22
jmp 0x2dae
movq 0xe23b(%rip), %rdi      # 0x10ff0
leaq 0x825c(%rip), %rsi      # 0xb018
callq 0x21e0
movq %rax, %rdi
movl -0xa0(%rbp), %esi
callq 0x2370
movq %rax, %rdi
leaq 0x825d(%rip), %rsi      # 0xb036
callq 0x21e0
movq %rax, %rdi
movl -0x9c(%rbp), %esi
callq 0x2370
movq %rax, %rdi
leaq 0x8290(%rip), %rsi      # 0xb086
callq 0x21e0
movq %rax, %rdi
movq 0xe1a3(%rip), %rsi      # 0x10fa8
callq 0x2220
movq %rax, %rdi
movq 0xe194(%rip), %rsi      # 0x10fa8
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0x3029
movq -0x88(%rbp), %rdi
callq 0x2300
movl %eax, -0x8c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x4ed0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4f00
movq -0xa8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4f50
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4f00
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4f20
testb $0x1, %al
jne 0x2ea8
jmp 0x2f0e
movq 0xe141(%rip), %rdi      # 0x10ff0
leaq 0x81ff(%rip), %rsi      # 0xb0b5
callq 0x21e0
movq %rax, %rdi
leaq 0x823d(%rip), %rsi      # 0xb102
callq 0x21e0
movq %rax, %rdi
movl -0x8c(%rbp), %esi
callq 0x2370
movq %rax, %rdi
leaq 0x822c(%rip), %rsi      # 0xb10e
callq 0x21e0
movq %rax, %rdi
movq 0xe0b7(%rip), %rsi      # 0x10fa8
callq 0x2220
movq %rax, %rdi
movq 0xe0a8(%rip), %rsi      # 0x10fa8
callq 0x2220
movb $0x0, -0x1(%rbp)
jmp 0x3029
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x840b(%rip), %rsi      # 0xb333
callq 0x2310
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x2f46
movq -0x88(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x2f4b
jmp 0x2dae
movl $0x20, %edi
callq 0x21f0
movq %rax, -0xf0(%rbp)
movq %rax, -0xf8(%rbp)
movb $0x1, -0xd5(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x2390
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
callq 0x4f80
jmp 0x2fa7
movb $0x0, -0xd5(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x5030
movq %rax, -0x100(%rbp)
jmp 0x2fc7
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xc1(%rbp), %rdi
callq 0x2250
jmp 0x2d40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x2250
testb $0x1, -0xd5(%rbp)
jne 0x3012
jmp 0x3023
movq -0xf8(%rbp), %rdi
movl $0x20, %esi
callq 0x2200
jmp 0x3037
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x2380
nopw %cs:(%rax,%rax)