// File: /workspace/github_cpp_makefile_star2_O1/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 $0x118, %rsp            # imm = 0x118
movups 0xc47(%rip), %xmm0      # 0x3034
leaq 0x80(%rsp), %rsi
movaps %xmm0, 0x30(%rsi)
movups 0xc24(%rip), %xmm0      # 0x3024
movaps %xmm0, 0x20(%rsi)
movups 0xc09(%rip), %xmm0      # 0x3014
movaps %xmm0, 0x10(%rsi)
movups 0xbee(%rip), %xmm0      # 0x3004
movaps %xmm0, (%rsi)
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rcx
movl $0x10, %edx
callq 0x273e
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x2625a00, %edi        # imm = 0x2625A00
callq 0x2140
movq %rax, %r15
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, %rbx
addq $0x2625a00, %rbx        # imm = 0x2625A00
movq %rbx, 0x20(%rsp)
xorl %r14d, %r14d
movl $0x2625a00, %edx        # imm = 0x2625A00
movq %rax, %rdi
xorl %esi, %esi
callq 0x20c0
movq %rbx, 0x18(%rsp)
movl $0x8c708e, %edi         # imm = 0x8C708E
callq 0x2120
callq 0x2060
movl %eax, (%r15,%r14)
addq $0x4, %r14
cmpq $0x2625a00, %r14        # imm = 0x2625A00
jne 0x2485
movq %r15, 0x40(%rsp)
leaq 0x78(%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 0x98(%rsp), %rax
leaq 0xd8(%rsp), %rcx
movl $0x10, -0x58(%rcx)
movq %rax, -0x50(%rcx)
movq %rcx, -0x48(%rcx)
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rbp
cmpq %rbp, %r13
je 0x2532
leaq 0x48(%rsp), %r14
leaq 0xc(%rsp), %r15
leaq 0x80(%rsp), %r12
movl (%r13), %ebx
movl %ebx, 0xc(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x29aa
movl %ebx, (%rax)
movl 0xc(%rsp), %ebx
movq %r12, %rdi
movq %r15, %rsi
callq 0x2784
movl %ebx, (%rax)
addq $0x4, %r13
cmpq %rbp, %r13
jne 0x2503
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x232c
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x232c
callq 0x2040
movq %rax, %r14
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x232c
callq 0x2040
movq %rax, %r15
movq 0x2a62(%rip), %rdi      # 0x4fd8
leaq 0xac7(%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 0x2a29(%rip), %rdi      # 0x4fd8
callq 0x2110
movq %rax, %r14
leaq 0xa9f(%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 0x80(%rsp), %r15
leaq 0x10(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x237f
movq %r15, %rdi
movq %r12, %rsi
callq 0x237f
callq 0x2040
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x237f
callq 0x2040
movq %rax, %r15
movq 0x29a1(%rip), %rdi      # 0x4fd8
leaq 0xa23(%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 0x2972(%rip), %rdi      # 0x4fd8
callq 0x2110
movq %rax, %r14
leaq 0x9e8(%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 0x48(%rsp), %rdi
callq 0x284e
movl $0x2625a00, %esi        # imm = 0x2625A00
movq 0x40(%rsp), %rdi
callq 0x2150
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x26d9
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x26fa
movq %rax, %rbx
jmp 0x271e
jmp 0x26fa
jmp 0x26fa
jmp 0x26fa
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x284e
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x271e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2735
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x21d0
nop