// File: lotuskip[P]yuxtapa/client/network.cpp
// Function: (anonymous namespace)::store_id_for_server(unsigned short, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void store_id_for_server(const unsigned short id,
	const string &serverip, const string &passw)
{
	string line2add = serverip + ' ' + lex_cast(id) + ' ' + passw;
	// The above was a clean "lookup", but here we might need to replace...
	vector<string> lines;
	ifstream ifile((Config::configdir() + serversfile_name).c_str());
	string tmp;
	bool not_replaced = true;
	while(getline(ifile, tmp))
	{
		if(not_replaced && tmp.find(serverip) == 0) // this is the server
		{
			tmp = line2add;
			not_replaced = false;
		}
		lines.push_back(tmp);
	}
	ifile.close();
	if(not_replaced)
		lines.push_back(line2add);

	ofstream ofile((Config::configdir() + serversfile_name).c_str());
	while(!lines.empty())
	{
		ofile << lines.front() << endl;
		lines.erase(lines.begin());
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5a0, %rsp            # imm = 0x5A0
movw %di, %ax
movw %ax, -0x2(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
movl $0x20, %edx
callq 0x14790
movzwl -0x2(%rbp), %esi
leaq -0xb8(%rbp), %rdi
callq 0x1b3b0
jmp 0x13821
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0xbdc0
jmp 0x1383a
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x20, %edx
callq 0xbe90
jmp 0x1384e
movq -0x18(%rbp), %rdx
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x14740
jmp 0x13861
leaq -0x58(%rbp), %rdi
callq 0x5968
leaq -0x78(%rbp), %rdi
callq 0x5968
leaq -0xb8(%rbp), %rdi
callq 0x5968
leaq -0x98(%rbp), %rdi
callq 0x5968
leaq -0xe0(%rbp), %rdi
callq 0xa0e0
callq 0x161d0
movq %rax, -0x570(%rbp)
jmp 0x138a5
movq -0x570(%rbp), %rsi
leaq 0x16a35(%rip), %rdx     # 0x2a2e8
leaq -0x308(%rbp), %rdi
callq 0x14680
jmp 0x138c1
leaq -0x308(%rbp), %rdi
callq 0x5200
movq %rax, %rsi
leaq -0x2e8(%rbp), %rdi
movl $0x8, %edx
callq 0x5880
jmp 0x138e3
leaq -0x308(%rbp), %rdi
callq 0x5968
leaq -0x328(%rbp), %rdi
callq 0x56f0
movb $0x1, -0x329(%rbp)
leaq -0x2e8(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x50d0
movq %rax, -0x578(%rbp)
jmp 0x1391e
movq -0x578(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5640
movb %al, -0x579(%rbp)
jmp 0x1393c
movb -0x579(%rbp), %al
testb $0x1, %al
jne 0x1394b
jmp 0x13a7c
testb $0x1, -0x329(%rbp)
je 0x13a62
movq -0x10(%rbp), %rsi
leaq -0x328(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0x5940
cmpq $0x0, %rax
jne 0x13a62
leaq -0x328(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x5060
jmp 0x13988
movb $0x0, -0x329(%rbp)
jmp 0x13a62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x13a00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x139f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x139eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x5968
leaq -0x78(%rbp), %rdi
callq 0x5968
leaq -0xb8(%rbp), %rdi
callq 0x5968
leaq -0x98(%rbp), %rdi
callq 0x5968
jmp 0x13c5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x13c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x5968
jmp 0x13c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x13c2d
leaq -0xe0(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0xd530
jmp 0x13a77
jmp 0x13902
leaq -0x2e8(%rbp), %rdi
callq 0x50e0
jmp 0x13a8a
testb $0x1, -0x329(%rbp)
je 0x13aa7
leaq -0xe0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xd530
jmp 0x13aa5
jmp 0x13aa7
callq 0x161d0
movq %rax, -0x588(%rbp)
jmp 0x13ab5
movq -0x588(%rbp), %rsi
leaq 0x16825(%rip), %rdx     # 0x2a2e8
leaq -0x550(%rbp), %rdi
callq 0x14680
jmp 0x13ad1
leaq -0x550(%rbp), %rdi
callq 0x5200
movq %rax, %rsi
leaq -0x530(%rbp), %rdi
movl $0x10, %edx
callq 0x5550
jmp 0x13af3
leaq -0x550(%rbp), %rdi
callq 0x5968
leaq -0xe0(%rbp), %rdi
callq 0xd4f0
xorb $-0x1, %al
testb $0x1, %al
jne 0x13b16
jmp 0x13beb
leaq -0xe0(%rbp), %rdi
callq 0x14810
movq %rax, %rsi
leaq -0x530(%rbp), %rdi
callq 0x5430
movq %rax, -0x590(%rbp)
jmp 0x13b3a
movq -0x590(%rbp), %rdi
movq 0x14458(%rip), %rsi     # 0x27fa0
callq 0x5510
jmp 0x13b4f
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
callq 0xabb0
movq %rax, -0x560(%rbp)
leaq -0x558(%rbp), %rdi
leaq -0x560(%rbp), %rsi
callq 0xd400
movq -0x5a0(%rbp), %rdi
movq -0x558(%rbp), %rsi
callq 0xd5a0
movq %rax, -0x598(%rbp)
jmp 0x13b98
movq -0x598(%rbp), %rax
movq %rax, -0x568(%rbp)
jmp 0x13aff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x5968
jmp 0x13c2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x5730
jmp 0x13c2d
leaq -0x530(%rbp), %rdi
callq 0x5730
leaq -0x328(%rbp), %rdi
callq 0x5968
leaq -0x2e8(%rbp), %rdi
callq 0x5150
leaq -0xe0(%rbp), %rdi
callq 0xa100
leaq -0x38(%rbp), %rdi
callq 0x5968
addq $0x5a0, %rsp            # imm = 0x5A0
popq %rbp
retq
leaq -0x328(%rbp), %rdi
callq 0x5968
leaq -0x2e8(%rbp), %rdi
callq 0x5150
leaq -0xe0(%rbp), %rdi
callq 0xa100
leaq -0x38(%rbp), %rdi
callq 0x5968
movq -0xc0(%rbp), %rdi
callq 0x5830
nopw %cs:(%rax,%rax)