// File: loadzero[P]geoloc/geoloc/test.cpp
// Function: test_string_table_roundtrip()
static int test_string_table_roundtrip()
{
    {
        StringTable st;

        st.insert("aaaa");
        st.insert("aaaa");
        st.insert("aaaa");

        assert(st.size() == 1);
        assert(st.byte_size() == 5);
        assert(st.index_of("aaaa") == 0);

        assert(strcmp(st[0], "aaaa") == 0);

        st.insert("bbb");

        assert(st.size() == 2);
        assert(st.byte_size() == 9);

        assert(st.index_of("bbb") == 1);
        assert(strcmp(st[1], "bbb") == 0);

        BinaryFile bf;
        bf.open("tmp/sv.bin");

        for (size_t i = 0; i < 1000; ++i)
        {
            char buf3[1024];

            sprintf(buf3, "funky str %d %d %d\n", (int) i, (int) i * 1234,
                    (int) i * 123456);
            st.insert(buf3);
        }

        save_string_table(bf, st);
    }

    MemoryFile mf;
    mf.open("tmp/sv.bin");

    MappedStringVector mv;
    mf.load_mapped_string_vector(mv);

    assert(mv.size() == 1002);

    assert(strcmp(mv[0], "aaaa") == 0);
    assert(strcmp(mv[1], "bbb") == 0);

    for (size_t i = 0; i < 1000; ++i)
    {
        char buf3[1024];
        sprintf(buf3, "funky str %d %d %d\n", (int) i, (int) i * 1234,
                (int) i * 123456);
        assert(strcmp(mv[i+2], buf3) == 0);
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xaa0, %rsp            # imm = 0xAA0
leaq -0x60(%rbp), %rdi
callq 0x4c70
leaq -0x81(%rbp), %rdi
movq %rdi, -0x9f8(%rbp)
callq 0x22a0
movq -0x9f8(%rbp), %rdx
leaq 0x7adb(%rip), %rsi      # 0xa230
leaq -0x80(%rbp), %rdi
callq 0x2220
jmp 0x2760
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4d40
jmp 0x276f
leaq -0x80(%rbp), %rdi
callq 0x2100
jmp 0x277a
leaq -0x81(%rbp), %rdi
callq 0x21c0
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xa00(%rbp)
callq 0x22a0
movq -0xa00(%rbp), %rdx
leaq 0x7a89(%rip), %rsi      # 0xa230
leaq -0xb8(%rbp), %rdi
callq 0x2220
jmp 0x27b5
leaq -0x60(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x4d40
jmp 0x27c7
leaq -0xb8(%rbp), %rdi
callq 0x2100
jmp 0x27d5
leaq -0xb9(%rbp), %rdi
callq 0x21c0
leaq -0xe1(%rbp), %rdi
movq %rdi, -0xa08(%rbp)
callq 0x22a0
movq -0xa08(%rbp), %rdx
leaq 0x7a2e(%rip), %rsi      # 0xa230
leaq -0xe0(%rbp), %rdi
callq 0x2220
jmp 0x2810
leaq -0x60(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4d40
jmp 0x2822
leaq -0xe0(%rbp), %rdi
callq 0x2100
jmp 0x2830
leaq -0xe1(%rbp), %rdi
callq 0x21c0
leaq -0x60(%rbp), %rdi
callq 0x4e30
movq %rax, -0xa10(%rbp)
jmp 0x284e
movq -0xa10(%rbp), %rax
cmpq $0x1, %rax
jne 0x2860
jmp 0x2968
leaq 0x79ce(%rip), %rdi      # 0xa235
leaq 0x77c6(%rip), %rsi      # 0xa034
movl $0x57, %edx
leaq 0x79ca(%rip), %rcx      # 0xa244
callq 0x2120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x28b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2100
jmp 0x28b0
jmp 0x28b2
leaq -0x81(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x28f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x2100
jmp 0x28f7
jmp 0x28f9
leaq -0xb9(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x2100
jmp 0x293e
jmp 0x2940
leaq -0xe1(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2f1e
leaq -0x60(%rbp), %rdi
callq 0x4e50
movq %rax, -0xa18(%rbp)
jmp 0x297a
movq -0xa18(%rbp), %rax
cmpq $0x5, %rax
jne 0x2989
jmp 0x29a8
leaq 0x78d6(%rip), %rdi      # 0xa266
leaq 0x769d(%rip), %rsi      # 0xa034
movl $0x58, %edx
leaq 0x78a1(%rip), %rcx      # 0xa244
callq 0x2120
leaq -0x109(%rbp), %rdi
movq %rdi, -0xa20(%rbp)
callq 0x22a0
movq -0xa20(%rbp), %rdx
leaq 0x7867(%rip), %rsi      # 0xa230
leaq -0x108(%rbp), %rdi
callq 0x2220
jmp 0x29d7
leaq -0x60(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4e70
movl %eax, -0xa24(%rbp)
jmp 0x29ef
movl -0xa24(%rbp), %eax
cmpl $0x0, %eax
jne 0x29fc
jmp 0x2a52
leaq 0x7877(%rip), %rdi      # 0xa27a
leaq 0x762a(%rip), %rsi      # 0xa034
movl $0x59, %edx
leaq 0x782e(%rip), %rcx      # 0xa244
callq 0x2120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2abd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x2100
jmp 0x2abb
leaq -0x108(%rbp), %rdi
callq 0x2100
jmp 0x2a60
leaq -0x109(%rbp), %rdi
callq 0x21c0
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x4ee0
movq %rax, -0xa30(%rbp)
jmp 0x2a82
movq -0xa30(%rbp), %rdi
leaq 0x77a0(%rip), %rsi      # 0xa230
callq 0x2230
cmpl $0x0, %eax
jne 0x2a9c
jmp 0x2ace
leaq 0x77f0(%rip), %rdi      # 0xa293
leaq 0x758a(%rip), %rsi      # 0xa034
movl $0x5b, %edx
leaq 0x778e(%rip), %rcx      # 0xa244
callq 0x2120
jmp 0x2abd
leaq -0x109(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
leaq -0x131(%rbp), %rdi
movq %rdi, -0xa38(%rbp)
callq 0x22a0
movq -0xa38(%rbp), %rdx
leaq 0x77bf(%rip), %rsi      # 0xa2ae
leaq -0x130(%rbp), %rdi
callq 0x2220
jmp 0x2afd
leaq -0x60(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x4d40
jmp 0x2b0f
leaq -0x130(%rbp), %rdi
callq 0x2100
jmp 0x2b1d
leaq -0x131(%rbp), %rdi
callq 0x21c0
leaq -0x60(%rbp), %rdi
callq 0x4e30
movq %rax, -0xa40(%rbp)
jmp 0x2b3b
movq -0xa40(%rbp), %rax
cmpq $0x2, %rax
jne 0x2b4a
jmp 0x2bb0
leaq 0x7761(%rip), %rdi      # 0xa2b2
leaq 0x74dc(%rip), %rsi      # 0xa034
movl $0x5f, %edx
leaq 0x76e0(%rip), %rcx      # 0xa244
callq 0x2120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x2100
jmp 0x2b9d
jmp 0x2b9f
leaq -0x131(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
leaq -0x60(%rbp), %rdi
callq 0x4e50
movq %rax, -0xa48(%rbp)
jmp 0x2bc2
movq -0xa48(%rbp), %rax
cmpq $0x9, %rax
jne 0x2bd1
jmp 0x2bf0
leaq 0x76e9(%rip), %rdi      # 0xa2c1
leaq 0x7455(%rip), %rsi      # 0xa034
movl $0x60, %edx
leaq 0x7659(%rip), %rcx      # 0xa244
callq 0x2120
leaq -0x159(%rbp), %rdi
movq %rdi, -0xa50(%rbp)
callq 0x22a0
movq -0xa50(%rbp), %rdx
leaq 0x769d(%rip), %rsi      # 0xa2ae
leaq -0x158(%rbp), %rdi
callq 0x2220
jmp 0x2c1f
leaq -0x60(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x4e70
movl %eax, -0xa54(%rbp)
jmp 0x2c37
movl -0xa54(%rbp), %eax
cmpl $0x1, %eax
jne 0x2c44
jmp 0x2c9a
leaq 0x768a(%rip), %rdi      # 0xa2d5
leaq 0x73e2(%rip), %rsi      # 0xa034
movl $0x62, %edx
leaq 0x75e6(%rip), %rcx      # 0xa244
callq 0x2120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2d06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x2100
jmp 0x2d04
leaq -0x158(%rbp), %rdi
callq 0x2100
jmp 0x2ca8
leaq -0x159(%rbp), %rdi
callq 0x21c0
leaq -0x60(%rbp), %rdi
movl $0x1, %esi
callq 0x4ee0
movq %rax, -0xa60(%rbp)
jmp 0x2ccb
movq -0xa60(%rbp), %rdi
leaq 0x75d5(%rip), %rsi      # 0xa2ae
callq 0x2230
cmpl $0x0, %eax
jne 0x2ce5
jmp 0x2d17
leaq 0x7601(%rip), %rdi      # 0xa2ed
leaq 0x7341(%rip), %rsi      # 0xa034
movl $0x63, %edx
leaq 0x7545(%rip), %rcx      # 0xa244
callq 0x2120
jmp 0x2d06
leaq -0x159(%rbp), %rdi
callq 0x21c0
jmp 0x2f1e
leaq -0x180(%rbp), %rdi
callq 0x3170
jmp 0x2d25
leaq 0x75db(%rip), %rsi      # 0xa307
leaq -0x180(%rbp), %rdi
callq 0x31a0
jmp 0x2d3a
movq $0x0, -0x188(%rbp)
cmpq $0x3e8, -0x188(%rbp) # imm = 0x3E8
jae 0x2e55
movl -0x188(%rbp), %edx
imull $0x4d2, %edx, %ecx      # imm = 0x4D2
imull $0x1e240, %edx, %r8d    # imm = 0x1E240
leaq 0x75a2(%rip), %rsi      # 0xa312
xorl %eax, %eax
leaq -0x590(%rbp), %rdi
movq %rdi, -0xa70(%rbp)
callq 0x2050
leaq -0x5b1(%rbp), %rdi
movq %rdi, -0xa68(%rbp)
callq 0x22a0
movq -0xa70(%rbp), %rsi
movq -0xa68(%rbp), %rdx
leaq -0x5b0(%rbp), %rdi
callq 0x2220
jmp 0x2db4
leaq -0x60(%rbp), %rdi
leaq -0x5b0(%rbp), %rsi
callq 0x4d40
jmp 0x2dc6
leaq -0x5b0(%rbp), %rdi
callq 0x2100
jmp 0x2dd4
leaq -0x5b1(%rbp), %rdi
callq 0x21c0
movq -0x188(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x188(%rbp)
jmp 0x2d45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2f0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2e44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x5b0(%rbp), %rdi
callq 0x2100
jmp 0x2e42
jmp 0x2e44
leaq -0x5b1(%rbp), %rdi
callq 0x21c0
jmp 0x2f0e
leaq -0x180(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4f20
jmp 0x2e67
leaq -0x180(%rbp), %rdi
callq 0x32c0
jmp 0x2e75
leaq -0x60(%rbp), %rdi
callq 0x4f70
leaq -0x5d0(%rbp), %rdi
movq %rdi, -0xa78(%rbp)
callq 0x3340
movq -0xa78(%rbp), %rdi
leaq 0x7468(%rip), %rsi      # 0xa307
callq 0x3370
jmp 0x2ea6
leaq -0x5e0(%rbp), %rdi
callq 0x5000
jmp 0x2eb4
leaq -0x5d0(%rbp), %rdi
leaq -0x5e0(%rbp), %rsi
callq 0x5020
jmp 0x2ec9
leaq -0x5e0(%rbp), %rdi
callq 0x50b0
movq %rax, -0xa80(%rbp)
jmp 0x2ede
movq -0xa80(%rbp), %rax
cmpq $0x3ea, %rax            # imm = 0x3EA
jne 0x2eef
jmp 0x2f51
leaq 0x7430(%rip), %rdi      # 0xa326
leaq 0x7137(%rip), %rsi      # 0xa034
movl $0x7a, %edx
leaq 0x733b(%rip), %rcx      # 0xa244
callq 0x2120
leaq -0x180(%rbp), %rdi
callq 0x32c0
jmp 0x2f1c
jmp 0x2f1e
leaq -0x60(%rbp), %rdi
callq 0x4f70
jmp 0x2f29
jmp 0x30c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x5d0(%rbp), %rdi
callq 0x3500
jmp 0x30c3
xorl %eax, %eax
movl %eax, %esi
leaq -0x5e0(%rbp), %rdi
callq 0x50d0
movq %rax, -0xa88(%rbp)
jmp 0x2f6a
movq -0xa88(%rbp), %rdi
leaq 0x72b8(%rip), %rsi      # 0xa230
callq 0x2230
cmpl $0x0, %eax
jne 0x2f84
jmp 0x2fa3
leaq 0x73ad(%rip), %rdi      # 0xa338
leaq 0x70a2(%rip), %rsi      # 0xa034
movl $0x7c, %edx
leaq 0x72a6(%rip), %rcx      # 0xa244
callq 0x2120
leaq -0x5e0(%rbp), %rdi
movl $0x1, %esi
callq 0x50d0
movq %rax, -0xa90(%rbp)
jmp 0x2fbd
movq -0xa90(%rbp), %rdi
leaq 0x72e3(%rip), %rsi      # 0xa2ae
callq 0x2230
cmpl $0x0, %eax
jne 0x2fd7
jmp 0x2ff6
leaq 0x7375(%rip), %rdi      # 0xa353
leaq 0x704f(%rip), %rsi      # 0xa034
movl $0x7d, %edx
leaq 0x7253(%rip), %rcx      # 0xa244
callq 0x2120
movq $0x0, -0x5e8(%rbp)
cmpq $0x3e8, -0x5e8(%rbp) # imm = 0x3E8
jae 0x30ac
movl -0x5e8(%rbp), %edx
imull $0x4d2, %edx, %ecx      # imm = 0x4D2
imull $0x1e240, %edx, %r8d    # imm = 0x1E240
leaq 0x72e6(%rip), %rsi      # 0xa312
xorl %eax, %eax
leaq -0x9f0(%rbp), %rdi
callq 0x2050
movq -0x5e8(%rbp), %rsi
addq $0x2, %rsi
leaq -0x5e0(%rbp), %rdi
callq 0x50d0
movq %rax, -0xa98(%rbp)
jmp 0x305a
movq -0xa98(%rbp), %rdi
leaq -0x9f0(%rbp), %rsi
callq 0x2230
cmpl $0x0, %eax
jne 0x3074
jmp 0x3093
leaq 0x72f2(%rip), %rdi      # 0xa36d
leaq 0x6fb2(%rip), %rsi      # 0xa034
movl $0x84, %edx
leaq 0x71b6(%rip), %rcx      # 0xa244
callq 0x2120
jmp 0x3095
movq -0x5e8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x5e8(%rbp)
jmp 0x3001
leaq -0x5d0(%rbp), %rdi
callq 0x3500
xorl %eax, %eax
addq $0xaa0, %rsp            # imm = 0xAA0
popq %rbp
retq
jmp 0x30c5
movq -0x90(%rbp), %rdi
callq 0x2290
movq %rax, %rdi
callq 0x3330
nopl (%rax)