// File: /workspace/github_cpp_makefile_star2_O2/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 $0x3e8, %rsp            # imm = 0x3E8
movl %edx, %r12d
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1d8(%rsp), %rdi
callq 0x4540
leaq 0x1d8(%rsp), %rdi
pushq $0x18
popq %rdx
movq %r14, %rsi
callq 0x4410
leaq 0x258(%rsp), %rdi
callq 0x4130
testb %al, %al
je 0x2026a
movq 0x12fdf4(%rip), %rdi    # 0x14ffc0
leaq 0xdcf7b(%rip), %rsi     # 0xfd14e
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x4480
movq %rax, %rdi
callq 0x4230
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40e0
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1d8(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x4580
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40e0
leaq 0xdcfde(%rip), %rsi     # 0xfd21d
leaq 0x100(%rsp), %rdi
callq 0x4190
testl %eax, %eax
je 0x20297
movq 0x12fd99(%rip), %rdi    # 0x14fff0
leaq 0xdcfc6(%rip), %rsi     # 0xfd224
callq 0x4480
xorl %ebp, %ebp
jmp 0x20667
movq 0x12fd7f(%rip), %rdi    # 0x14fff0
leaq 0xdd02f(%rip), %rsi     # 0xfd2a7
callq 0x4480
movq %rax, %rdi
movq %r14, %rsi
callq 0x4480
movq %rax, %rdi
callq 0x4230
xorl %ebp, %ebp
jmp 0x20674
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40e0
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40e0
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4580
leaq 0x8(%rbx), %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x42d0
leaq 0x10(%rbx), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x18(%rbx), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x20(%rbx), %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x42d0
leaq 0x28(%rbx), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0x30(%rbx), %rsi
movq %rax, %rdi
callq 0x42d0
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x1d8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4580
leaq 0x1d8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x40e0
leaq 0xdcf02(%rip), %rsi     # 0xfd263
leaq 0xe0(%rsp), %rdi
callq 0x4190
testl %eax, %eax
sete %bpl
je 0x2038e
movq 0x12fc73(%rip), %rdi    # 0x14fff0
leaq 0xdcee4(%rip), %rsi     # 0xfd268
callq 0x4480
jmp 0x2065a
leaq 0x320(%rbx), %rdi
movq %r14, %rsi
callq 0x4810
movq %rbx, %rdi
callq 0x3e5a4
movl %ebp, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
leaq 0x2f0(%rbx), %rax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
leaq 0x1d8(%rsp), %r15
leaq 0xa8(%rsp), %r13
movzbl %r12b, %eax
movl %eax, 0x14(%rsp)
leaq 0x1b8(%rsp), %r14
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
testb $0x1, %r12b
jne 0x20617
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
andq $0x0, 0x90(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movb %bl, 0xb8(%rsp)
movb %bl, 0x98(%rsp)
movb %bl, 0x78(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
andq $0x0, 0x50(%rsp)
movb %bl, 0x58(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x4580
movq %r13, %rdi
leaq 0xe4f7e(%rip), %rsi     # 0x1053ec
callq 0x4190
movb $0x1, %r12b
testl %eax, %eax
je 0x205e9
movq %r13, %rdi
leaq 0xdce1b(%rip), %rsi     # 0xfd2a3
callq 0x4190
testl %eax, %eax
je 0x205e9
leaq 0x120(%rsp), %r12
movq %r12, %rdi
callq 0x3dc5a
movq %r15, %rdi
movq %r12, %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x128(%rsp), %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x130(%rsp), %rsi
callq 0x42d0
movq %r15, %rdi
leaq 0x88(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
callq 0x4580
movq %r15, %rdi
leaq 0x160(%rsp), %rsi
callq 0x4580
movq %rax, %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x42d0
movsd 0x120(%rsp), %xmm0
movsd 0x128(%rsp), %xmm1
movsd 0x130(%rsp), %xmm2
leaq 0xc8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3f1ce
leaq 0xc8(%rsp), %rdi
xorl %esi, %esi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x138(%rsp)
leaq 0xc8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x140(%rsp)
leaq 0xc8(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x63c78
movsd (%rax), %xmm0
movsd %xmm0, 0x148(%rsp)
movq %r14, %rdi
leaq 0x160(%rsp), %rsi
callq 0x45d0
movq %r14, %rbp
movq %r14, %rdi
movl 0x14(%rsp), %esi
callq 0x1b1bb
movsd %xmm0, 0x150(%rsp)
movq %rbp, %rdi
callq 0x4210
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0xa7d8
incl 0xc(%rsp)
movq %r12, %rdi
callq 0xa808
xorl %r12d, %r12d
leaq 0x48(%rsp), %rdi
callq 0x4210
leaq 0x68(%rsp), %rdi
callq 0x4210
leaq 0x88(%rsp), %rdi
callq 0x4210
movq %r13, %rdi
callq 0x4210
jmp 0x203e7
movq 0x18(%rsp), %rax
movl 0xc(%rsp), %esi
movl %esi, 0x110(%rax)
movq 0x12f993(%rip), %rdi    # 0x14ffc0
callq 0x4760
movl 0x10(%rsp), %ebp
leaq 0xdcb5d(%rip), %rsi     # 0xfd19a
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4230
leaq 0x1d8(%rsp), %rdi
callq 0x4080
leaq 0xe0(%rsp), %rdi
callq 0x4210
leaq 0x100(%rsp), %rdi
callq 0x4210
leaq 0x1d8(%rsp), %rdi
callq 0x4120
leaq 0x20(%rsp), %rdi
callq 0x4210
movl %ebp, %eax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x206a1
movq %rax, %rbx
jmp 0x2070e
jmp 0x206bf
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
callq 0x4210
jmp 0x206d3
movq %rax, %rbx
jmp 0x20735
movq %rax, %rbx
jmp 0x206e0
movq %rax, %rbx
jmp 0x2071b
movq %rax, %rbx
jmp 0x20728
jmp 0x206d0
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0xa808
leaq 0x48(%rsp), %rdi
callq 0x4210
leaq 0x68(%rsp), %rdi
callq 0x4210
leaq 0x88(%rsp), %rdi
callq 0x4210
leaq 0xa8(%rsp), %rdi
callq 0x4210
leaq 0xe0(%rsp), %rdi
callq 0x4210
leaq 0x100(%rsp), %rdi
callq 0x4210
leaq 0x1d8(%rsp), %rdi
callq 0x4120
leaq 0x20(%rsp), %rdi
callq 0x4210
movq %rbx, %rdi
callq 0x4780