// File: /workspace/github_cpp_makefile_star2_O2/dadocolussi[P]gdc-nanomap/demo/demo.cpp
// Function: main
int
main(int argc, char** argv)
{
	std::vector<int> input
	{
		1, 11, 111, 1111, 11111, 111111, 1111111, 11111111,
		2, 22, 222, 2222, 22222, 222222, 2222222, 22222222
	};
	std::vector<int> haystack(10 * 1000 * 1000);
	std::srand(9203854);
	std::generate(haystack.begin(), haystack.end(), []() { return std::rand(); });
	um um_needles;
	gdc::nanomap_factory<int, int, 16> factory;
	nm& nm_needles = factory.get();
	
	for (auto i : input)
	{
		um_needles[i] = i;
		nm_needles[i] = i;
	}
	
	// Warmup
	run_um(um_needles, haystack);
	run_um(um_needles, haystack);
	// Final run
	auto t0 = std::chrono::high_resolution_clock::now();
	run_um(um_needles, haystack);
	auto t1 = std::chrono::high_resolution_clock::now();
	auto duration_um = std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0);
	std::cout << "unordered_map duration: " << duration_um.count() << " ms" << std::endl;
	
	run_nm(nm_needles, haystack);
	run_nm(nm_needles, haystack);
	t0 = std::chrono::high_resolution_clock::now();
	run_nm(nm_needles, haystack);
	t1 = std::chrono::high_resolution_clock::now();
	auto duration_nm = std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0);
	std::cout << "gdc::nanomap duration: " << duration_nm.count() << " ms" << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movups 0xc9f(%rip), %xmm0      # 0x2034
leaq 0x70(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0xc7f(%rip), %xmm0      # 0x2024
movaps %xmm0, 0x20(%rsi)
movups 0xc64(%rip), %xmm0      # 0x2014
movaps %xmm0, 0x10(%rsi)
movups 0xc49(%rip), %xmm0      # 0x2004
movaps %xmm0, (%rsi)
leaq 0x20(%rsp), %rdi
pushq $0x10
popq %rdx
leaq 0x38(%rsp), %rcx
callq 0x1634
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movl $0x989680, %esi         # imm = 0x989680
callq 0x166a
movl $0x8c708e, %edi         # imm = 0x8C708E
callq 0x1110
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
cmpq %r14, %rbx
je 0x140a
callq 0x1050
movl %eax, (%rbx)
addq $0x4, %rbx
jmp 0x13f8
leaq 0x68(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x88(%rsp), %rax
leaq 0xc8(%rsp), %rcx
movl $0x10, -0x58(%rcx)
movq %rax, -0x50(%rcx)
movq %rcx, -0x48(%rcx)
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r13
leaq 0x38(%rsp), %rbx
leaq 0x4(%rsp), %r14
leaq 0x70(%rsp), %r15
cmpq %r13, %r12
je 0x1496
movl (%r12), %ebp
movl %ebp, 0x4(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1a44
movl %ebp, (%rax)
movl 0x4(%rsp), %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x16bc
movl %ebp, (%rax)
addq $0x4, %r12
jmp 0x1465
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12ec
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12ec
callq 0x1030
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12ec
callq 0x1030
movq %rax, %r14
movq 0x2afe(%rip), %rdi      # 0x3fd8
leaq 0xb63(%rip), %rsi       # 0x2044
callq 0x1120
movq %rax, %rdi
subq %rbx, %r14
movl $0xf4240, %ecx          # imm = 0xF4240
movq %r14, %rax
cqto
idivq %rcx
movq %rax, %rsi
callq 0x1100
leaq 0xb55(%rip), %rsi       # 0x205d
movq %rax, %rdi
callq 0x1120
movq %rax, %rdi
callq 0x1090
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x131f
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x131f
callq 0x1030
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x131f
callq 0x1030
movq %rax, %r14
movq 0x2a7c(%rip), %rdi      # 0x3fd8
leaq 0xafe(%rip), %rsi       # 0x2061
callq 0x1120
movq %rax, %rdi
subq %rbx, %r14
movl $0xf4240, %ecx          # imm = 0xF4240
movq %r14, %rax
cqto
idivq %rcx
movq %rax, %rsi
callq 0x1100
leaq 0xad3(%rip), %rsi       # 0x205d
movq %rax, %rdi
callq 0x1120
movq %rax, %rdi
callq 0x1090
leaq 0x38(%rsp), %rdi
callq 0x1792
leaq 0x8(%rsp), %rdi
callq 0x1940
leaq 0x20(%rsp), %rdi
callq 0x1940
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15d9
movq %rax, %rbx
jmp 0x15f0
jmp 0x15d9
jmp 0x15d9
jmp 0x15d9
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1792
leaq 0x8(%rsp), %rdi
callq 0x1940
leaq 0x20(%rsp), %rdi
callq 0x1940
movq %rbx, %rdi
callq 0x11b0