// File: /workspace/github_cpp_makefile_star2_O1/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 0x287e8
movq 0x16e80d(%rip), %r12    # 0x196fc0
leaq 0x127924(%rip), %rsi    # 0x1500de
movl $0x14, %edx
movq %r12, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2882b
movq %r15, %rdi
callq 0x41e0
movq 0x16e7e5(%rip), %rdi    # 0x196fc0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x28844
movq 0x16e801(%rip), %rbx    # 0x196ff0
leaq 0x127a41(%rip), %rsi    # 0x150237
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x44e0
testq %r15, %r15
je 0x2893a
movq %r15, %rdi
callq 0x41e0
movq 0x16e7d5(%rip), %rdi    # 0x196ff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x28951
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 0x16e75d(%rip), %rdi    # 0x196fc0
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 0x1278a4(%rip), %rsi    # 0x1501ad
leaq 0xf0(%rsp), %rdi
callq 0x4170
testl %eax, %eax
je 0x28984
movq 0x16e6cf(%rip), %rdi    # 0x196ff0
leaq 0x12788c(%rip), %rsi    # 0x1501b4
movl $0x3e, %edx
callq 0x44e0
xorl %r14d, %r14d
jmp 0x28edf
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 0x16e681(%rip), %rdi    # 0x196ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
xorl %r14d, %r14d
jmp 0x28efc
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 0x127748(%rip), %rsi    # 0x1501f3
leaq 0xd0(%rsp), %rdi
callq 0x4170
testl %eax, %eax
sete %r14b
je 0x28add
movq 0x16e529(%rip), %rdi    # 0x196ff0
leaq 0x12772a(%rip), %rsi    # 0x1501f8
movl $0x3a, %edx
callq 0x44e0
jmp 0x28eba
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 0x521f4
movl %ebx, 0x4(%rsp)
movq %rbp, 0x28(%rsp)
leaq 0x2f0(%rbp), %rax
movq %rax, 0x110(%rsp)
xorl %r14d, %r14d
leaq 0x1c8(%rsp), %r13
leaq 0x90(%rsp), %r15
xorl %ebp, %ebp
xorl %r12d, %r12d
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %r14, 0x98(%rsp)
movb %r14b, 0xa0(%rsp)
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 %r13, %rdi
movq %r15, %rsi
callq 0x4560
movq %r15, %rdi
leaq 0x12f793(%rip), %rsi    # 0x15834c
callq 0x4170
testl %eax, %eax
je 0x28db9
movq %r15, %rdi
leaq 0x127663(%rip), %rsi    # 0x150233
callq 0x4170
testl %eax, %eax
je 0x28db9
leaq 0x130(%rsp), %rbx
movq %rbx, %rdi
callq 0x5162c
movq %r13, %rdi
movq %rbx, %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 0x70(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4560
movq %rax, %rdi
leaq 0x30(%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 0x531ea
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x148(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x1, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x150(%rsp)
leaq 0x118(%rsp), %rdi
movl $0x2, %esi
callq 0x85478
movsd (%rax), %xmm0
movsd %xmm0, 0x158(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x170(%rsp), %rsi
movq 0x178(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0xf32a
movzbl 0x4(%rsp), %esi
leaq 0xb0(%rsp), %rdi
callq 0x21e42
movsd %xmm0, 0x160(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x28d56
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x110(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0xe936
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x28d90
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x28db5
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x4470
incl %ebp
jmp 0x28dbc
movb $0x1, %r12b
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28dd8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28df4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x28e16
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x28e3b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
testb $0x1, %r12b
je 0x28b42
movq 0x28(%rsp), %rax
movl %ebp, 0x110(%rax)
movq 0x16e169(%rip), %rdi    # 0x196fc0
movl %ebp, %esi
leaq 0x18(%rsp), %r13
leaq 0x100(%rsp), %r12
callq 0x4750
movl (%rsp), %r14d
movq %rax, %rbx
leaq 0x1272b1(%rip), %rsi    # 0x15012a
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 0x28edf
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x28efc
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x1c8(%rsp), %rdi
callq 0x4110
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x28f20
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 0x28f37
movq %rax, %r14
jmp 0x29019
jmp 0x28f73
movq %rax, %r14
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x28f8d
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x28f8d
movq %rax, %r14
jmp 0x29070
movq %rax, %r14
jmp 0x28f9a
movq %rax, %r14
jmp 0x2903e
jmp 0x28f8a
movq %rax, %r14
jmp 0x29063
movq %rax, %r14
leaq 0x130(%rsp), %rdi
callq 0x2f814
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x28fb6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28fd2
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x28ff4
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x29019
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x2903e
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x4470
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x29063
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 0x2908c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4470
movq %r14, %rdi
callq 0x4780