// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
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 0x686c
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 0x686c
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 0x686c
addq $0x10, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x78(%rsp)
movups %xmm0, 0x88(%rsp)
movups %xmm0, 0x98(%rsp)
movq (%r14), %r13
cmpq %r13, 0x8(%r14)
movq %rbx, 0x28(%rsp)
je 0x5bf9
xorl %ebx, %ebx
movl $0x28, %r12d
leaq 0x48(%rsp), %rbp
xorl %r15d, %r15d
leaq (%r12,%r13), %rsi
addq $-0x20, %rsi
movl -0x8(%rsi), %eax
cmpl %r15d, %eax
cmoval %eax, %r15d
leaq 0x108(%rsp), %rdi
callq 0x66dc
leaq (%r12,%r13), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x66dc
leaq (%r12,%r13), %rsi
addq $0x20, %rsi
movq %rbp, %rdi
callq 0x66dc
incq %rbx
movq (%r14), %r13
movq 0x8(%r14), %rax
subq %r13, %rax
sarq $0x3, %rax
movabsq $-0x30c30c30c30c30c3, %rcx # imm = 0xCF3CF3CF3CF3CF3D
imulq %rcx, %rax
addq $0xa8, %r12
cmpq %rax, %rbx
jb 0x5b84
incl %r15d
movq 0x28(%rsp), %rbx
jmp 0x5bff
movl $0x1, %r15d
leaq 0x138(%rsp), %rsi
movq %rbx, %rdi
callq 0x5274
leaq 0x150(%rsp), %rsi
movq %rbx, %rdi
callq 0x740a
leaq 0xd8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5274
leaq 0xf0(%rsp), %rsi
movq %rbx, %rdi
callq 0x740a
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x5274
leaq 0x90(%rsp), %rsi
movq %rbx, %rdi
callq 0x740a
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
testq %r15, %r15
je 0x5c8e
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rcx
xorl %esi, %esi
movq %r15, %rdx
callq 0x7498
movq (%r14), %r15
cmpq %r15, 0x8(%r14)
je 0x5dac
movl $0x48, %ebp
xorl %ebx, %ebx
leaq (%r15,%rbp), %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 0x7784
movq 0x110(%rsp), %rcx
movq 0x118(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5ce2
movl 0x20(%rax), %eax
jmp 0x5ce7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq (%r12,%r13,8), %r12
movl %eax, 0x4(%r12)
leaq (%r15,%rbp), %rsi
addq $-0x20, %rsi
leaq 0xa8(%rsp), %rdi
callq 0x7784
movq 0xb0(%rsp), %rcx
movq 0xb8(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5d20
movl 0x20(%rax), %eax
jmp 0x5d25
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x8(%r12)
leaq (%r15,%rbp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x7784
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
cmpq (%rcx,%rdx,8), %rax
je 0x5d4d
movl 0x20(%rax), %eax
jmp 0x5d52
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xc(%r12)
movq 0x20(%r15,%rbp), %rdi
xorl %esi, %esi
callq 0x32c0
movss %xmm0, 0x10(%r12)
movq 0x40(%r15,%rbp), %rdi
xorl %esi, %esi
callq 0x32c0
movss %xmm0, 0x14(%r12)
incq %rbx
movq (%r14), %r15
movq 0x8(%r14), %rax
subq %r15, %rax
sarq $0x3, %rax
movabsq $-0x30c30c30c30c30c3, %rcx # imm = 0xCF3CF3CF3CF3CF3D
imulq %rcx, %rax
addq $0xa8, %rbp
cmpq %rax, %rbx
jb 0x5ca2
leaq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x6792
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5dca
callq 0x31d0
leaq 0x48(%rsp), %rdi
callq 0x682a
leaq 0xa8(%rsp), %rdi
callq 0x682a
leaq 0x108(%rsp), %rdi
callq 0x682a
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5e0e
movq %rax, %rbx
jmp 0x5e3c
movq %rax, %rbx
jmp 0x5e2f
jmp 0x5e22
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5e25
callq 0x31d0
jmp 0x5e25
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x682a
leaq 0xa8(%rsp), %rdi
callq 0x682a
leaq 0x108(%rsp), %rdi
callq 0x682a
movq %rbx, %rdi
callq 0x3350
movq %rax, %rdi
callq 0x4185
nop