// File: /workspace/github_cpp_makefile_star2_O3/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 0xc68(%rip), %xmm0      # 0x3034
leaq 0x70(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0xc48(%rip), %xmm0      # 0x3024
movaps %xmm0, 0x20(%rsi)
movups 0xc2d(%rip), %xmm0      # 0x3014
movaps %xmm0, 0x10(%rsi)
movups 0xc12(%rip), %xmm0      # 0x3004
movaps %xmm0, (%rsi)
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rcx
movl $0x10, %edx
callq 0x273a
movl $0x2625a00, %edi        # imm = 0x2625A00
callq 0x2140
movq %rax, %rbx
movq %rax, 0x20(%rsp)
leaq 0x2625a00(%rax), %r15
movq %r15, 0x30(%rsp)
xorl %r14d, %r14d
movl $0x2625a00, %edx        # imm = 0x2625A00
movq %rax, %rdi
xorl %esi, %esi
callq 0x20c0
movq %r15, 0x28(%rsp)
movl $0x8c708e, %edi         # imm = 0x8C708E
callq 0x2120
callq 0x2060
movl %eax, (%rbx,%r14)
addq $0x4, %r14
cmpq $0x2625a00, %r14        # imm = 0x2625A00
jne 0x2448
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 0x8(%rsp), %r13
movq 0x10(%rsp), %rbp
cmpq %rbp, %r13
je 0x24ee
leaq 0x4(%rsp), %r15
leaq 0x70(%rsp), %r12
movl (%r13), %r14d
movl %r14d, 0x4(%rsp)
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x29ba
movl %r14d, (%rax)
movl 0x4(%rsp), %r14d
movq %r12, %rdi
movq %r15, %rsi
callq 0x2780
movl %r14d, (%rax)
addq $0x4, %r13
cmpq %rbp, %r13
jne 0x24b9
xorl %r15d, %r15d
leaq 0x38(%rsp), %r14
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x28c4
testq %rax, %rax
je 0x250a
incl 0xc(%rax)
addq $0x4, %r15
cmpq $0x2625a00, %r15        # imm = 0x2625A00
jne 0x24f6
xorl %r15d, %r15d
leaq 0x38(%rsp), %r14
leaq (%rbx,%r15), %rsi
movq %r14, %rdi
callq 0x28c4
testq %rax, %rax
je 0x2533
incl 0xc(%rax)
addq $0x4, %r15
cmpq $0x2625a00, %r15        # imm = 0x2625A00
jne 0x251f
xorl %r12d, %r12d
callq 0x2040
movq %rax, %r14
leaq 0x38(%rsp), %r15
leaq (%rbx,%r12), %rsi
movq %r15, %rdi
callq 0x28c4
testq %rax, %rax
je 0x2564
incl 0xc(%rax)
addq $0x4, %r12
cmpq $0x2625a00, %r12        # imm = 0x2625A00
jne 0x2550
callq 0x2040
movq %rax, %r15
movq 0x2a58(%rip), %rdi      # 0x4fd8
leaq 0xabd(%rip), %rsi       # 0x3044
movl $0x18, %edx
callq 0x2160
subq %r14, %r15
movabsq $0x431bde82d7b634db, %r13 # imm = 0x431BDE82D7B634DB
movq %r15, %rax
imulq %r13
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
movq 0x2a1f(%rip), %rdi      # 0x4fd8
callq 0x2110
movq %rax, %r14
leaq 0xa95(%rip), %rsi       # 0x305d
movl $0x3, %edx
movq %rax, %rdi
callq 0x2160
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
leaq 0x70(%rsp), %r15
leaq 0x20(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2363
movq %r15, %rdi
movq %r12, %rsi
callq 0x2363
callq 0x2040
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x2363
callq 0x2040
movq %rax, %r15
movq 0x299a(%rip), %rdi      # 0x4fd8
leaq 0xa1c(%rip), %rsi       # 0x3061
movl $0x17, %edx
callq 0x2160
subq %r14, %r15
movq %r15, %rax
imulq %r13
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
movq 0x296b(%rip), %rdi      # 0x4fd8
callq 0x2110
movq %rax, %r14
leaq 0x9e1(%rip), %rsi       # 0x305d
movl $0x3, %edx
movq %rax, %rdi
callq 0x2160
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20d0
leaq 0x38(%rsp), %rdi
callq 0x2854
movl $0x2625a00, %esi        # imm = 0x2625A00
movq %rbx, %rdi
callq 0x2150
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x26de
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x271b
jmp 0x2701
jmp 0x2701
jmp 0x2701
jmp 0x2701
jmp 0x2701
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x2854
movl $0x2625a00, %esi        # imm = 0x2625A00
movq %rbx, %rdi
callq 0x2150
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2732
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %r14, %rdi
callq 0x21d0