// File: /workspace/github_cpp_makefile_star2_O3/Luthaf[P]zeopp/networkio.cc
// Function: writeToCSSR(char*, ATOM_NETWORK*)
bool writeToCSSR(char *filename, ATOM_NETWORK *cell){
  fstream output;
  output.open(filename, fstream::out);
  if(!output.is_open()){
    cerr << "Error: Failed to open .cssr output file " << filename << endl;
	//cerr << "Exiting ..." << "\n";
    //exit(1);
    return false;
  }
  else{
    cout   << "Writing atom network information to " << filename << "\n";

    // Write information about the unit cell
    output << "\t\t\t\t" << cell->a << "  " << cell->b << "  " << cell->c << "\n";
    output << "\t\t" << cell->alpha<<"  "<< cell->beta <<"  " << cell->gamma <<"  SPGR =  1 P 1\t\t OPT = 1" << "\n";
    output << cell->numAtoms << "   0 " << "\n";
    output << "0 " << cell->name << "\t" << ": " << cell->name << "\n";
    output.setf(ios::fixed, ios::floatfield);
    int i;
    ATOM atm;

    // Write information about each atom
    for(i = 0; i<cell->numAtoms; i++){
      atm = cell->atoms.at(i);
      output << " " << i+1 << " " << cell->atoms.at(i).type << " " << atm.a_coord << " "
	     << atm.b_coord << " " << atm.c_coord << "  0  0  0  0  0  0  0  0  " << atm.charge <<  "\n";
    }
    output.close();
    return true;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
callq 0x4520
movq %r15, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x43d0
leaq 0x128(%rsp), %rdi
callq 0x4120
movl %eax, %ebp
testb %al, %al
je 0x2a91a
movq 0x16a6db(%rip), %r15    # 0x194fc0
leaq 0x123ade(%rip), %rsi    # 0x14e3ca
movl $0x24, %edx
movq %r15, %rdi
callq 0x44e0
testq %rbx, %rbx
je 0x2a95d
movq %rbx, %rdi
callq 0x41e0
movq 0x16a6b3(%rip), %rdi    # 0x194fc0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2a975
movq 0x16a6cf(%rip), %r14    # 0x194ff0
leaq 0x123a79(%rip), %rsi    # 0x14e3a1
movl $0x28, %edx
movq %r14, %rdi
callq 0x44e0
testq %rbx, %rbx
je 0x2add4
movq %rbx, %rdi
callq 0x41e0
movq 0x16a6a3(%rip), %rdi    # 0x194ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x44e0
jmp 0x2adec
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq 0x16a644(%rip), %rdi    # 0x194fc0
leaq 0x128c9b(%rip), %rsi    # 0x15361e
movl $0x1, %edx
callq 0x44e0
leaq 0xb8(%rsp), %rdi
leaq 0x123a53(%rip), %rsi    # 0x14e3ef
movl $0x4, %edx
callq 0x44e0
movsd 0x8(%r14), %xmm0
leaq 0xb8(%rsp), %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x122b1c(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x10(%r14), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x122af7(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x18(%r14), %xmm0
movq %rbx, %rdi
callq 0x46b0
leaq 0x128c14(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x1239d3(%rip), %rsi    # 0x14e3f1
movl $0x2, %edx
leaq 0xb8(%rsp), %rdi
callq 0x44e0
movsd 0x20(%r14), %xmm0
leaq 0xb8(%rsp), %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x122a92(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x28(%r14), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x122a6d(%rip), %rsi    # 0x14d4df
movl $0x2, %edx
movq %rax, %rdi
callq 0x44e0
movsd 0x30(%r14), %xmm0
movq %rbx, %rdi
callq 0x46b0
movq %rax, %rbx
leaq 0x12395d(%rip), %rsi    # 0x14e3f4
movl $0x19, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x128b73(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
movl 0x110(%r14), %esi
leaq 0xb8(%rsp), %rdi
callq 0x4750
movq %rax, %rbx
leaq 0x123938(%rip), %rsi    # 0x14e40e
movl $0x5, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x128b34(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rbx, %rdi
callq 0x44e0
leaq 0x123913(%rip), %rsi    # 0x14e411
movl $0x2, %edx
leaq 0xb8(%rsp), %rdi
callq 0x44e0
movq 0x320(%r14), %rsi
movq 0x328(%r14), %rdx
leaq 0xb8(%rsp), %rdi
callq 0x44e0
movq %rax, %rbx
leaq 0x1238bd(%rip), %rsi    # 0x14e3f2
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
leaq 0x127bd8(%rip), %rsi    # 0x152721
movl $0x2, %edx
movq %rbx, %rdi
callq 0x44e0
movq 0x320(%r14), %rsi
movq 0x328(%r14), %rdx
movq %rbx, %rdi
callq 0x44e0
leaq 0x128aab(%rip), %rsi    # 0x15361e
movl $0x1, %edx
movq %rax, %rdi
callq 0x44e0
movb %bpl, 0xf(%rsp)
movq 0xa8(%rsp), %rax
movq -0x18(%rax), %rax
movl $0xfffffefb, %ecx       # imm = 0xFFFFFEFB
andl 0xc0(%rsp,%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0xc0(%rsp,%rax)
leaq 0x10(%rsp), %rdi
callq 0x51264
leaq 0x50(%rsp), %r13
movl $0x40, %ebp
xorl %r12d, %r12d
leaq 0x12aa11(%rip), %rbx    # 0x1555d6
movslq 0x110(%r14), %rax
cmpq %rax, %r12
jge 0x2ad84
movq 0x2f0(%r14), %r15
movq 0x2f8(%r14), %rdx
subq %r15, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rax # imm = 0x86BCA1AF286BCA1B
imulq %rax, %rdx
cmpq %r12, %rdx
jbe 0x2ae38
leaq (%r15,%rbp), %rsi
movups -0x40(%r15,%rbp), %xmm0
movups -0x30(%r15,%rbp), %xmm1
movups -0x20(%r15,%rbp), %xmm2
movups -0x10(%r15,%rbp), %xmm3
movaps %xmm3, 0x40(%rsp)
movaps %xmm2, 0x30(%rsp)
movaps %xmm1, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %r13, %rdi
callq 0x4240
leaq (%r15,%rbp), %rsi
addq $0x20, %rsi
leaq 0x70(%rsp), %rdi
callq 0x4240
movb 0x50(%r15,%rbp), %al
movb %al, 0x50(%r13)
movups 0x40(%r15,%rbp), %xmm0
movups %xmm0, 0x40(%r13)
movl $0x1, %edx
leaq 0xb8(%rsp), %rdi
movq %rbx, %rsi
callq 0x44e0
leal 0x1(%r12), %esi
leaq 0xb8(%rsp), %rdi
callq 0x4750
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movq 0x2f0(%r14), %rax
movq 0x2f8(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %rcx # imm = 0x86BCA1AF286BCA1B
imulq %rcx, %rdx
cmpq %r12, %rdx
jbe 0x2ae38
movq (%rax,%rbp), %rsi
movq 0x8(%rax,%rbp), %rdx
movq %r15, %rdi
callq 0x44e0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movsd 0x28(%rsp), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movsd 0x30(%rsp), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x44e0
movsd 0x38(%rsp), %xmm0
movq %r15, %rdi
callq 0x46b0
movq %rax, %r15
movl $0x1a, %edx
movq %rax, %rdi
leaq 0x1236c9(%rip), %rsi    # 0x14e414
callq 0x44e0
movsd 0x98(%rsp), %xmm0
movq %r15, %rdi
callq 0x46b0
addq $0x98, %rbp
incq %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1288a4(%rip), %rsi    # 0x15361e
callq 0x44e0
jmp 0x2abc5
leaq 0xa8(%rsp), %rdi
callq 0x4090
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movb 0xf(%rsp), %bpl
je 0x2adb7
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4470
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ae17
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4470
jmp 0x2ae17
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x4710
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x4420
movsbl %al, %esi
movq 0x16a1e6(%rip), %rdi    # 0x194ff0
callq 0x4040
movq %rax, %rdi
callq 0x42c0
leaq 0xa8(%rsp), %rdi
callq 0x4110
movl %ebp, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1228b6(%rip), %rdi    # 0x14d6f5
movq %r12, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x2ae4b
movq %rax, %rbx
jmp 0x2ae5f
jmp 0x2ae52
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2f5e8
leaq 0xa8(%rsp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x4780