// File: /workspace/github_cpp_makefile_star2_O1/loadzero[P]geoloc/geoloc/locations.hpp
// Function: save_locations(BinaryFile&, std::vector<Location, std::allocator<Location>> const&)
inline void save_locations(BinaryFile &file, 
                           const std::vector<Location> &locations)
{
    unsigned maxid = 0;

    StringTable country;
    StringTable region;
    StringTable city;

    for (size_t i = 0; i < locations.size(); ++i)
    {
        const Location &loc = locations[i];

        maxid = std::max(loc.id, maxid);

        country.insert(loc.country);
        region.insert(loc.region);
        city.insert(loc.city);
    }

    save_string_table(file, country);
    save_string_table(file, region);
    save_string_table(file, city);

    std::vector<PackedLocation> packed;
    packed.resize(maxid + 1);

    for (size_t i = 0; i < locations.size(); ++i)
    {
        const Location &loc = locations[i];

        PackedLocation &ploc = packed[loc.id];

        ploc.id = loc.id;
        ploc.country = country.index_of(loc.country);
        ploc.region = region.index_of(loc.region);
        ploc.city = city.index_of(loc.city);
        ploc.lat = strtof(loc.lat.c_str(), 0);
        ploc.lon = strtof(loc.lon.c_str(), 0);
    }

    file.save_pod_vector(packed);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %r14
movq %rdi, %r13
leaq 0xc(%rsp), %rax
leaq 0x30(%rsp), %r10
leaq 0x108(%rsp), %r15
leaq 0x10(%rsp), %r12
leaq 0xa8(%rsp), %rcx
leaq 0x48(%rsp), %r8
leaq 0xe(%rsp), %r9
movl $0xa, %esi
movq %r15, %rdi
movq %r12, %rdx
pushq %rax
pushq %r10
callq 0x67dc
addq $0x10, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x50(%r15)
leaq 0xd(%rsp), %rax
leaq 0xa8(%rsp), %rdi
leaq 0xe(%rsp), %r15
leaq 0x48(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0xc(%rsp), %r9
movl $0xa, %esi
movq %r15, %rdx
pushq %rax
pushq %r12
callq 0x67dc
addq $0x10, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%rsp)
movups %xmm0, 0xe8(%rsp)
movups %xmm0, 0xf8(%rsp)
leaq 0xf(%rsp), %rax
leaq 0x48(%rsp), %rdi
leaq 0xc(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0xd(%rsp), %r9
movl $0xa, %esi
pushq %rax
pushq %r15
callq 0x67dc
addq $0x10, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x78(%rsp)
movups %xmm0, 0x88(%rsp)
movups %xmm0, 0x98(%rsp)
movq (%r14), %r12
cmpq %r12, 0x8(%r14)
movq %r13, 0x28(%rsp)
je 0x5b5f
xorl %ebp, %ebp
movl $0x28, %r15d
leaq 0x48(%rsp), %r13
xorl %ebx, %ebx
leaq (%r12,%r15), %rsi
addq $-0x20, %rsi
movl -0x8(%rsi), %eax
cmpl %ebx, %eax
cmoval %eax, %ebx
leaq 0x108(%rsp), %rdi
callq 0x6654
leaq (%r12,%r15), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x6654
leaq (%r12,%r15), %rsi
addq $0x20, %rsi
movq %r13, %rdi
callq 0x6654
incq %rbp
movq (%r14), %r12
movq 0x8(%r14), %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x30c30c30c30c30c3, %rcx # imm = 0xCF3CF3CF3CF3CF3D
imulq %rcx, %rax
addq $0xa8, %r15
cmpq %rax, %rbp
jb 0x5aed
incl %ebx
movq 0x28(%rsp), %r13
jmp 0x5b64
movl $0x1, %ebx
leaq 0x138(%rsp), %rsi
movq %r13, %rdi
callq 0x51e0
leaq 0x150(%rsp), %rsi
movq %r13, %rdi
callq 0x738a
leaq 0xd8(%rsp), %rsi
movq %r13, %rdi
callq 0x51e0
leaq 0xf0(%rsp), %rsi
movq %r13, %rdi
callq 0x738a
leaq 0x78(%rsp), %rsi
movq %r13, %rdi
callq 0x51e0
leaq 0x90(%rsp), %rsi
movq %r13, %rdi
callq 0x738a
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x18(%rsp), %rsi
movq %rsi, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movq %rbx, %rdx
subq %rcx, %rdx
jbe 0x5c0d
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rcx
callq 0x7418
jmp 0x5c21
jae 0x5c21
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %rax
cmpq %rax, %rsi
je 0x5c21
movq %rax, 0x18(%rsp)
movq (%r14), %r15
cmpq %r15, 0x8(%r14)
je 0x5d3f
movl $0x48, %ebx
xorl %ebp, %ebp
leaq (%r15,%rbx), %rsi
addq $-0x40, %rsi
movl -0x8(%rsi), %eax
movq 0x10(%rsp), %r12
leaq (%rax,%rax,2), %r13
movl %eax, (%r12,%r13,8)
leaq 0x108(%rsp), %rdi
callq 0x7702
movq 0x110(%rsp), %rcx
movq 0x118(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5c75
movl 0x20(%rax), %eax
jmp 0x5c7a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq (%r12,%r13,8), %r12
movl %eax, 0x4(%r12)
leaq (%r15,%rbx), %rsi
addq $-0x20, %rsi
leaq 0xa8(%rsp), %rdi
callq 0x7702
movq 0xb0(%rsp), %rcx
movq 0xb8(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5cb3
movl 0x20(%rax), %eax
jmp 0x5cb8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x8(%r12)
leaq (%r15,%rbx), %rsi
leaq 0x48(%rsp), %rdi
callq 0x7702
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5ce0
movl 0x20(%rax), %eax
jmp 0x5ce5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xc(%r12)
movq 0x20(%r15,%rbx), %rdi
xorl %esi, %esi
callq 0x32c0
movss %xmm0, 0x10(%r12)
movq 0x40(%r15,%rbx), %rdi
xorl %esi, %esi
callq 0x32c0
movss %xmm0, 0x14(%r12)
incq %rbp
movq (%r14), %r15
movq 0x8(%r14), %rax
subq %r15, %rax
sarq $0x3, %rax
movabsq $-0x30c30c30c30c30c3, %rcx # imm = 0xCF3CF3CF3CF3CF3D
imulq %rcx, %rax
addq $0xa8, %rbx
cmpq %rax, %rbp
jb 0x5c35
leaq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x6702
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5d5d
callq 0x31d0
leaq 0x48(%rsp), %rdi
callq 0x679a
leaq 0xa8(%rsp), %rdi
callq 0x679a
leaq 0x108(%rsp), %rdi
callq 0x679a
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5da1
movq %rax, %rbx
jmp 0x5dcf
movq %rax, %rbx
jmp 0x5dc2
jmp 0x5db5
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5db8
callq 0x31d0
jmp 0x5db8
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x679a
leaq 0xa8(%rsp), %rdi
callq 0x679a
leaq 0x108(%rsp), %rdi
callq 0x679a
movq %rbx, %rdi
callq 0x3350
movq %rax, %rdi
callq 0x40f4