// File: Luthaf[P]zeopp/networkio.cc
// Function: readCUCFile(char*, ATOM_NETWORK*, bool)
bool readCUCFile(char *filename, ATOM_NETWORK *cell, bool radial){
  fstream input;
  input.open(filename);
  char garbage[256];
  int numAtoms;

  if(!input.is_open()){
    cout << "\n" << "Failed to open .cuc input file " << filename << "\n";
    cout << "Exiting ..." << "\n";
//    exit(1);
    return false;
  }
  else{
    cout << "Reading input file " << filename << "\n";

    // Read and store information about the unit cell
    cell->name = filename;
    cell->name.erase(cell->name.end()-4, cell->name.end());
    input.getline(garbage, 256);
    input >> garbage;
    input >> cell->a >> cell->b >> cell->c;
    input >> cell->alpha >> cell->beta >> cell->gamma;
    cell->initialize(); // Initializes the unit cell vectors using the
			// angles and side lengths

    // Read and store information about each atom
    numAtoms = 0;
    while(!input.eof()){
      ATOM newAtom;
      input >> newAtom.type;
      if(newAtom.type.empty())
	break;

      changeAtomType(&newAtom); // Converts to atom type
      input >> newAtom.a_coord >> newAtom.b_coord >> newAtom.c_coord;
      newAtom.a_coord = trans_to_origuc(newAtom.a_coord);
      newAtom.b_coord = trans_to_origuc(newAtom.b_coord);
      newAtom.c_coord = trans_to_origuc(newAtom.c_coord);
      Point newCoords = cell->abc_to_xyz (newAtom.a_coord,newAtom.b_coord,newAtom.c_coord);
      newAtom.x = newCoords[0]; newAtom.y = newCoords[1]; newAtom.z = newCoords[2];
      newAtom.radius = lookupRadius(newAtom.type, radial);
      newAtom.label=newAtom.type;
      cell->atoms.push_back(newAtom);
      numAtoms++;
    }
    cell->numAtoms= numAtoms;
    input.close();
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x510, %rsp            # imm = 0x510
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x5660
movq -0x10(%rbp), %rax
movq %rax, -0x458(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x47640
movl %eax, -0x44c(%rbp)
jmp 0x4f898
movl -0x44c(%rbp), %edx
movq -0x458(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x54b0
jmp 0x4f8b3
leaq -0x230(%rbp), %rdi
callq 0x58b0
movb %al, -0x459(%rbp)
jmp 0x4f8c7
movb -0x459(%rbp), %al
testb $0x1, %al
jne 0x4f998
jmp 0x4f8d7
movq 0x2236e2(%rip), %rdi    # 0x272fc0
leaq 0x1a9d40(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x468(%rbp)
jmp 0x4f8f3
movq -0x468(%rbp), %rdi
leaq 0x1a3a06(%rip), %rsi    # 0x1f3307
callq 0x5540
movq %rax, -0x470(%rbp)
jmp 0x4f90f
movq -0x470(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5540
movq %rax, -0x478(%rbp)
jmp 0x4f928
movq -0x478(%rbp), %rdi
leaq 0x1a9cef(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x4f93d
movq 0x22367c(%rip), %rdi    # 0x272fc0
leaq 0x1a32b8(%rip), %rsi    # 0x1f2c03
callq 0x5540
movq %rax, -0x480(%rbp)
jmp 0x4f959
movq -0x480(%rbp), %rdi
leaq 0x1a9cbe(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x4f96e
movb $0x0, -0x1(%rbp)
movl $0x1, -0x348(%rbp)
jmp 0x4fe9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x4feb6
movq 0x223621(%rip), %rdi    # 0x272fc0
leaq 0x1a37f2(%rip), %rsi    # 0x1f3198
callq 0x5540
movq %rax, -0x488(%rbp)
jmp 0x4f9b4
movq -0x488(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x5540
movq %rax, -0x490(%rbp)
jmp 0x4f9cd
movq -0x490(%rbp), %rdi
leaq 0x1a9c4a(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x4f9e2
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
callq 0x5710
jmp 0x4f9f8
movq -0x18(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
movq %rdi, -0x4a0(%rbp)
callq 0x52d0
movq %rax, -0x360(%rbp)
leaq -0x360(%rbp), %rdi
movl $0x4, %esi
callq 0x594e0
movq %rax, -0x358(%rbp)
leaq -0x350(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x59520
movq -0x18(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
callq 0x52d0
movq %rax, -0x370(%rbp)
leaq -0x368(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x59520
movq -0x4a0(%rbp), %rdi
movq -0x350(%rbp), %rsi
movq -0x368(%rbp), %rdx
callq 0x5130
movq %rax, -0x498(%rbp)
jmp 0x4fa8e
movq -0x498(%rbp), %rax
movq %rax, -0x378(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x340(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x51d0
jmp 0x4fab6
leaq -0x230(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x59560
jmp 0x4facb
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
leaq -0x230(%rbp), %rdi
callq 0x5420
movq %rax, -0x4a8(%rbp)
jmp 0x4fae8
movq -0x4a8(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
callq 0x5420
movq %rax, -0x4b0(%rbp)
jmp 0x4fb05
movq -0x4b0(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
callq 0x5420
jmp 0x4fb1b
movq -0x18(%rbp), %rsi
addq $0x20, %rsi
leaq -0x230(%rbp), %rdi
callq 0x5420
movq %rax, -0x4b8(%rbp)
jmp 0x4fb38
movq -0x4b8(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x28, %rsi
callq 0x5420
movq %rax, -0x4c0(%rbp)
jmp 0x4fb55
movq -0x4c0(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
callq 0x5420
jmp 0x4fb6b
movq -0x18(%rbp), %rdi
callq 0x96250
jmp 0x4fb76
movl $0x0, -0x344(%rbp)
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x230(%rbp,%rax), %rdi
callq 0x5960
movb %al, -0x4c1(%rbp)
jmp 0x4fba0
movb -0x4c1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4fbb1
jmp 0x4fe6e
leaq -0x410(%rbp), %rdi
callq 0x954b0
jmp 0x4fbbf
leaq -0x3d0(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x56a0
jmp 0x4fbd4
leaq -0x410(%rbp), %rdi
addq $0x40, %rdi
callq 0x5850
testb $0x1, %al
jne 0x4fbea
jmp 0x4fc10
movl $0x3, -0x348(%rbp)
jmp 0x4fe23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
jmp 0x4fe60
leaq -0x410(%rbp), %rdi
callq 0x4fed0
jmp 0x4fc1e
leaq -0x3f8(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x5420
movq %rax, -0x4d0(%rbp)
jmp 0x4fc3a
movq -0x4d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x5420
movq %rax, -0x4d8(%rbp)
jmp 0x4fc56
movq -0x4d8(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x5420
jmp 0x4fc6b
movsd -0x3f8(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x4e0(%rbp)
jmp 0x4fc82
movsd -0x4e0(%rbp), %xmm0
movsd %xmm0, -0x3f8(%rbp)
movsd -0x3f0(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x4e8(%rbp)
jmp 0x4fca9
movsd -0x4e8(%rbp), %xmm0
movsd %xmm0, -0x3f0(%rbp)
movsd -0x3e8(%rbp), %xmm0
callq 0xe9290
movsd %xmm0, -0x4f0(%rbp)
jmp 0x4fcd0
movsd -0x4f0(%rbp), %xmm0
movsd %xmm0, -0x3e8(%rbp)
movq -0x18(%rbp), %rsi
movsd -0x3f8(%rbp), %xmm0
movsd -0x3f0(%rbp), %xmm1
movsd -0x3e8(%rbp), %xmm2
leaq -0x428(%rbp), %rdi
callq 0x97170
jmp 0x4fd0a
leaq -0x428(%rbp), %rdi
xorl %esi, %esi
callq 0xe9d70
movq %rax, -0x4f8(%rbp)
jmp 0x4fd21
movq -0x4f8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x410(%rbp)
leaq -0x428(%rbp), %rdi
movl $0x1, %esi
callq 0xe9d70
movq %rax, -0x500(%rbp)
jmp 0x4fd4e
movq -0x500(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x408(%rbp)
leaq -0x428(%rbp), %rdi
movl $0x2, %esi
callq 0xe9d70
movq %rax, -0x508(%rbp)
jmp 0x4fd7b
movq -0x508(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x400(%rbp)
leaq -0x3d0(%rbp), %rsi
leaq -0x448(%rbp), %rdi
callq 0x5220
jmp 0x4fda3
movzbl -0x19(%rbp), %esi
andl $0x1, %esi
leaq -0x448(%rbp), %rdi
callq 0x466e0
movsd %xmm0, -0x510(%rbp)
jmp 0x4fdc0
movsd -0x510(%rbp), %xmm0
movsd %xmm0, -0x3e0(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x5300
leaq -0x3d0(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x5060
jmp 0x4fdf1
movq -0x18(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
leaq -0x410(%rbp), %rsi
callq 0xf190
jmp 0x4fe0a
movl -0x344(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x344(%rbp)
movl $0x0, -0x348(%rbp)
leaq -0x410(%rbp), %rdi
callq 0xf200
movl -0x348(%rbp), %eax
testl %eax, %eax
je 0x4fe3d
jmp 0x4fe3b
jmp 0x4fe6e
jmp 0x4fb80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x238(%rbp)
movl %eax, -0x23c(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x5300
leaq -0x410(%rbp), %rdi
callq 0xf200
jmp 0x4feb6
movl -0x344(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x110(%rax)
leaq -0x230(%rbp), %rdi
callq 0x50a0
jmp 0x4fe8c
jmp 0x4fe8e
movb $0x1, -0x1(%rbp)
movl $0x1, -0x348(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x5150
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x510, %rsp            # imm = 0x510
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x5150
movq -0x238(%rbp), %rdi
callq 0x58f0
nop