// File: Linkerist[P]xs/src/io.cc
// Function: list_to_file()
void
list_to_file(void)
{
 // don't write empty files FIXME: unlink file?
 string __listfile = get_listfile();

 if (default_list.empty()) {
  unlink(__listfile.c_str());
  return;
 }

 struct stat buf;
 if (stat(__listfile.c_str(), &buf) == 0) {
  string backup_file = __listfile + "~";
  if (rename(__listfile.c_str(), backup_file.c_str()) == -1)
   fprintf(stderr,"warning: could not create backupfile\n");
 }

 ofstream listfile(__listfile.c_str());
 if (!listfile)
  fatal_exit("couldn't write listfile");

 //for (vector<pair<string, string> > li = default_list.begin(); li != default_list.end(); ++li)
 for (listit li = default_list.begin(); li != default_list.end(); ++li)
  listfile << li->first << " " << li->second << endl;

 listfile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
leaq -0x20(%rbp), %rdi
callq 0x4d60
leaq 0xf805(%rip), %rdi      # 0x17540
callq 0x8b50
testb $0x1, %al
jne 0x7d46
jmp 0x7d63
leaq -0x20(%rbp), %rdi
callq 0x41a0
movq %rax, %rdi
callq 0x41f0
movl $0x1, -0x24(%rbp)
jmp 0x7ffc
leaq -0x20(%rbp), %rdi
callq 0x41a0
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x43a0
cmpl $0x0, %eax
jne 0x7e0a
leaq 0x8298(%rip), %rdx      # 0x10023
leaq -0xd8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x6010
jmp 0x7d9d
leaq -0x20(%rbp), %rdi
callq 0x41a0
movq %rax, -0x328(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x41a0
movq -0x328(%rbp), %rdi
movq %rax, %rsi
callq 0x4270
cmpl $-0x1, %eax
jne 0x7dfe
movq 0xf1f4(%rip), %rax      # 0x16fc8
movq (%rax), %rdi
leaq 0x83e9(%rip), %rsi      # 0x101c7
movb $0x0, %al
callq 0x45d0
jmp 0x7dfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x801a
leaq -0xd8(%rbp), %rdi
callq 0x4828
leaq -0x20(%rbp), %rdi
callq 0x41a0
movq %rax, %rsi
leaq -0x2e8(%rbp), %rdi
movl $0x10, %edx
callq 0x4460
jmp 0x7e29
movq -0x2e8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2e8(%rbp,%rax), %rdi
callq 0x41e0
movb %al, -0x329(%rbp)
jmp 0x7e49
movb -0x329(%rbp), %al
testb $0x1, %al
jne 0x7e58
jmp 0x7f09
leaq -0x309(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x4740
movq -0x338(%rbp), %rdx
leaq 0x8374(%rip), %rsi      # 0x101ed
leaq -0x308(%rbp), %rdi
callq 0x5e40
jmp 0x7e87
leaq -0x308(%rbp), %rdi
callq 0x5630
jmp 0x7e95
leaq -0x308(%rbp), %rdi
callq 0x4828
leaq -0x309(%rbp), %rdi
callq 0x4450
jmp 0x7f09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x800e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x7ef8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x4828
leaq -0x309(%rbp), %rdi
callq 0x4450
jmp 0x800e
leaq 0xf630(%rip), %rdi      # 0x17540
callq 0x8c20
movq %rax, -0x318(%rbp)
leaq 0xf61d(%rip), %rdi      # 0x17540
callq 0x8c50
movq %rax, -0x320(%rbp)
leaq -0x318(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x8dc0
testb $0x1, %al
jne 0x7f4b
jmp 0x7fdb
leaq -0x318(%rbp), %rdi
callq 0x8e00
movq %rax, %rsi
leaq -0x2e8(%rbp), %rdi
callq 0x4380
movq %rax, -0x340(%rbp)
jmp 0x7f6f
movq -0x340(%rbp), %rdi
leaq 0x90f8(%rip), %rsi      # 0x11075
callq 0x43c0
movq %rax, -0x348(%rbp)
jmp 0x7f8b
leaq -0x318(%rbp), %rdi
callq 0x8e00
movq -0x348(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x4380
movq %rax, -0x350(%rbp)
jmp 0x7fb3
movq -0x350(%rbp), %rdi
movq 0xefe7(%rip), %rsi      # 0x16fa8
callq 0x4420
jmp 0x7fc8
jmp 0x7fca
leaq -0x318(%rbp), %rdi
callq 0x8e20
jmp 0x7f1c
leaq -0x2e8(%rbp), %rdi
callq 0x45c0
jmp 0x7fe9
leaq -0x2e8(%rbp), %rdi
callq 0x4610
movl $0x0, -0x24(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4828
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
leaq -0x2e8(%rbp), %rdi
callq 0x4610
leaq -0x20(%rbp), %rdi
callq 0x4828
movq -0xe0(%rbp), %rdi
callq 0x4730
nop