// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkio.cc
// Function: readCARFile(char*, ATOM_NETWORK*, bool)
bool readCARFile(char *filename, ATOM_NETWORK *cell, bool radial){
  string garbage; //this is a garbage string to read line
  int i,j;

  fstream input;
  input.open(filename);
  if(input.is_open()==true){
    // Read the header information
    cout << "Reading input file: " << filename << endl;
    getline(input, garbage); // skip the first comment line

    string PBCline;

    input >> PBCline; getline(input, garbage);
    if(PBCline.compare("PBC=ON") != 0)
      {
      cerr << "This .car file does not have a periodic structure. Exiting...\n";
      return false;
      };

    getline(input, garbage); // skipping two next lines
    getline(input, garbage);

    input >> garbage;
    input >> cell->a >> cell->b >> cell->c;
    input >> cell->alpha >> cell->beta >> cell->gamma;
    string SYMMline;
    input >> SYMMline;
    getline(input,garbage);

    if(SYMMline.compare("(P1)") !=0)
      {
      cerr << "The current .car reader does only work for (P1) symmetry.\n";
      return false;
      };

    cell->name = filename;
    cell->initialize();

    bool end=false;
    int na=0;
    while(!end)
      {
      string str1, str2, str3, str4;

      input >> str1;

      if(str1.compare("end") == 0 || str1.compare("END") == 0)
        {
        end = true;
        } else
        {
        ATOM newAtom;
        input >> newAtom.x >> newAtom.y >> newAtom.z;
        input >> str2 >> str3 >> str4;
        input >> newAtom.type >> newAtom.charge;

        if(!CAR_USE_ATOM_TYPE_OVER_NAME) newAtom.type = str1;

        Point newCoords = cell->xyz_to_abc(newAtom.x, newAtom.y, newAtom.z);
        newAtom.a_coord = newCoords[0]; newAtom.b_coord = newCoords[1]; newAtom.c_coord = newCoords[2];
        newAtom.radius = lookupRadius(newAtom.type, radial);
        cell->atoms.push_back(newAtom);
        na++;
        };

      };

    cell->numAtoms = na;
    cout << na << " atoms read." << endl;

    input.close();
  }
  else{
    cerr << "Error: CAR failed to open " << filename << endl;
//    abort();
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movl %edx, %ebx
movq %rsi, %rbp
movq %rdi, %r15
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
leaq 0x1c8(%rsp), %rdi
callq 0x4520
leaq 0x1c8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x43d0
leaq 0x248(%rsp), %rdi
callq 0x4120
testb %al, %al
je 0x28612
movq 0x16c9e3(%rip), %r12    # 0x194fc0
leaq 0x125b6a(%rip), %rsi    # 0x14e14e
movl $0x14, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x28655
movq %r15, %rdi
callq 0x41e0
movq 0x16c9bb(%rip), %rdi    # 0x194fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2866e
movq 0x16c9d7(%rip), %rbx    # 0x194ff0
leaq 0x125c87(%rip), %rsi    # 0x14e2a7
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x28764
movq %r15, %rdi
callq 0x41e0
movq 0x16c9ab(%rip), %rdi    # 0x194ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2877b
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16c933(%rip), %rdi    # 0x194fc0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
movq 0x1c8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1c8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x47e0
leaq 0x100(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0x1c8(%rsp), %r14
leaq 0xf0(%rsp), %rsi
movq %r14, %rdi
callq 0x4560
movq 0x1c8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1c8(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x47e0
leaq 0x125aea(%rip), %rsi    # 0x14e21d
leaq 0xf0(%rsp), %rdi
callq 0x4170
testl %eax, %eax
je 0x287ae
movq 0x16c8a5(%rip), %rdi    # 0x194ff0
leaq 0x125ad2(%rip), %rsi    # 0x14e224
movl $0x3e, %edx
callq 0x44e0
xorl %r14d, %r14d
jmp 0x28cf9
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16c857(%rip), %rdi    # 0x194ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
xorl %r14d, %r14d
jmp 0x28d16
movq 0x1c8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1c8(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x47e0
movq 0x1c8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1c8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x47e0
leaq 0x1c8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4560
leaq 0x8(%rbp), %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x42a0
leaq 0x10(%rbp), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x18(%rbp), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x20(%rbp), %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x42a0
leaq 0x28(%rbp), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0x30(%rbp), %rsi
movq %rax, %rdi
callq 0x42a0
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1c8(%rsp), %r14
leaq 0xd0(%rsp), %rsi
movq %r14, %rdi
callq 0x4560
movq 0x1c8(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %edx
leaq 0x1c8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x47e0
leaq 0x12598e(%rip), %rsi    # 0x14e263
leaq 0xd0(%rsp), %rdi
callq 0x4170
testl %eax, %eax
sete %r14b
je 0x28907
movq 0x16c6ff(%rip), %rdi    # 0x194ff0
leaq 0x125970(%rip), %rsi    # 0x14e268
movl $0x3a, %edx
callq 0x44e0
jmp 0x28cd4
movl %r14d, (%rsp)
leaq 0x320(%rbp), %r14
movq 0x328(%rbp), %r12
movq %r15, %rdi
callq 0x41e0
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x4670
movq %rbp, %rdi
callq 0x51db4
movl %ebx, 0x4(%rsp)
leaq 0xc0(%rsp), %rbx
movq %rbp, 0x28(%rsp)
leaq 0x2f0(%rbp), %rax
movq %rax, 0x110(%rsp)
xorl %r14d, %r14d
leaq 0x1c8(%rsp), %r13
leaq 0x70(%rsp), %r15
xorl %ebp, %ebp
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %r14, 0x78(%rsp)
movb %r14b, 0x80(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %r14, 0x58(%rsp)
movb %r14b, 0x60(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movb %r14b, 0x40(%rsp)
movq %rbx, 0xb0(%rsp)
movq %r14, 0xb8(%rsp)
movb %r14b, 0xc0(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x4560
movq %r15, %rdi
leaq 0x12dacf(%rip), %rsi    # 0x1564ac
callq 0x4170
movb $0x1, %r12b
testl %eax, %eax
je 0x28bdf
movq %r15, %rdi
leaq 0x1258ac(%rip), %rsi    # 0x14e2a3
callq 0x4170
testl %eax, %eax
je 0x28bdf
leaq 0x130(%rsp), %r12
movq %r12, %rdi
callq 0x51264
movq %r13, %rdi
movq %r12, %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x138(%rsp), %rsi
callq 0x42a0
movq %rax, %rdi
leaq 0x140(%rsp), %rsi
callq 0x42a0
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x4560
movq %r13, %rdi
leaq 0x170(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x42a0
movsd 0x130(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
movsd 0x140(%rsp), %xmm2
leaq 0x118(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x52eec
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x148(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x1, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x150(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x2, %esi
callq 0x83f9a
movsd (%rax), %xmm0
movsd %xmm0, 0x158(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0xf3ce
movzbl 0x4(%rsp), %esi
leaq 0x90(%rsp), %rdi
callq 0x21d5e
movsd %xmm0, 0x160(%rsp)
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x28b80
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x110(%rsp), %rdi
movq %r12, %rsi
callq 0xe9a8
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x28bb5
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x28bda
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x4470
incl %ebp
xorl %r12d, %r12d
movq 0xb0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28bfc
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28c18
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28c34
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x28c56
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
testb %r12b, %r12b
je 0x2896e
movq 0x28(%rsp), %rax
movl %ebp, 0x110(%rax)
movq 0x16c34f(%rip), %rdi    # 0x194fc0
movl %ebp, %esi
leaq 0x18(%rsp), %r13
leaq 0x100(%rsp), %r12
callq 0x4750
movl (%rsp), %r14d
movq %rax, %rbx
leaq 0x125507(%rip), %rsi    # 0x14e19a
movl $0xc, %edx
movq %rax, %rdi
callq 0x44e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0x1c8(%rsp), %rdi
callq 0x4090
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x28cf9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x28d16
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1c8(%rsp), %rdi
callq 0x4110
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x28d3a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movl %r14d, %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x28d51
movq %rax, %r14
jmp 0x28e2b
jmp 0x28d8d
movq %rax, %r14
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x28da7
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x28da7
movq %rax, %r14
jmp 0x28e82
movq %rax, %r14
jmp 0x28db4
movq %rax, %r14
jmp 0x28e50
jmp 0x28da4
movq %rax, %r14
jmp 0x28e75
movq %rax, %r14
leaq 0x130(%rsp), %rdi
callq 0x2f5e8
movq 0xb0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28dd1
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28ded
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28e09
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x28e2b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x28e50
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x28e75
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1c8(%rsp), %rdi
callq 0x4110
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x28e9e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq %r14, %rdi
callq 0x4780