// File: /workspace/github_c_makefile_star2_O2/KhuramAli[P]JAM-Benchmark/Summation_lock_free_cppThread/code12.cpp
// Function: main
int main() {

	std::cout << std::endl;

	std::vector<int> randValues;
	randValues.reserve(size);

	std::mt19937 engine;
	std::uniform_int_distribution<> uniformDist(1, 10);
	for (long long i = 0; i < size; ++i) randValues.push_back(uniformDist(engine));

	std::atomic<unsigned long long> sum(0);
	auto start = std::chrono::system_clock::now();

	std::thread t1(sumUp, std::ref(sum), std::ref(randValues), 0, firBound);
	std::thread t2(sumUp, std::ref(sum), std::ref(randValues), firBound, secBound);
	std::thread t3(sumUp, std::ref(sum), std::ref(randValues), secBound, thiBound);
	std::thread t4(sumUp, std::ref(sum), std::ref(randValues), thiBound, fouBound);


	t1.join();
	t2.join();
	t3.join();
	t4.join();
	std::chrono::duration<double> dur = std::chrono::system_clock::now() - start;
	std::cout << "Time for addition " << dur.count() << " seconds" << std::endl;
	std::cout << "Result: " << sum << std::endl;

	std::cout << std::endl;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x13e0, %rsp           # imm = 0x13E0
movq 0x2d2f(%rip), %rdi      # 0x3fd8
callq 0x1070
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movl $0x5f5e100, %esi        # imm = 0x5F5E100
callq 0x1520
leaq 0x58(%rsp), %rdi
callq 0x15b0
movabsq $0xa00000001, %rax      # imm = 0xA00000001
leaq 0x50(%rsp), %rbx
movq %rax, (%rbx)
movl $0x5f5e100, %r13d       # imm = 0x5F5E100
leaq 0x58(%rsp), %r12
leaq 0x30(%rsp), %r14
leaq 0x20(%rsp), %r15
subq $0x1, %r13
jb 0x131d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x15ba
movl %eax, 0x20(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x19ca
jmp 0x12fb
andq $0x0, 0x20(%rsp)
callq 0x1030
movq %rax, %rbx
leaq 0x10(%rsp), %rdx
movq %r15, (%rdx)
leaq 0x8(%rsp), %rcx
movq %r14, (%rcx)
movq %rsp, %r8
andl $0x0, (%r8)
leaq -0xcd(%rip), %rsi       # 0x127c
leaq 0xcc0(%rip), %r9        # 0x2010
leaq 0x18(%rsp), %rdi
callq 0x15c2
leaq 0x8(%rsp), %rdx
movq %r15, (%rdx)
movq %rsp, %rcx
movq %r14, (%rcx)
leaq -0xf3(%rip), %rsi       # 0x127c
leaq 0xc9a(%rip), %r8        # 0x2010
leaq 0xc9b(%rip), %r9        # 0x2018
leaq 0x10(%rsp), %rdi
callq 0x165e
movq %rsp, %rdx
movq %r15, (%rdx)
leaq 0x28(%rsp), %rcx
movq %r14, (%rcx)
leaq -0x120(%rip), %rsi      # 0x127c
leaq 0xc75(%rip), %r8        # 0x2018
leaq 0xc76(%rip), %r9        # 0x2020
leaq 0x8(%rsp), %rdi
callq 0x165e
leaq 0x28(%rsp), %rdx
movq %r15, (%rdx)
leaq 0x48(%rsp), %rcx
movq %r14, (%rcx)
leaq -0x14f(%rip), %rsi      # 0x127c
leaq 0xc4e(%rip), %r8        # 0x2020
leaq 0xc4f(%rip), %r9        # 0x2028
movq %rsp, %rdi
callq 0x165e
leaq 0x18(%rsp), %rdi
callq 0x1130
leaq 0x10(%rsp), %rdi
callq 0x1130
leaq 0x8(%rsp), %rdi
callq 0x1130
movq %rsp, %rdi
callq 0x1130
callq 0x1030
movq %rax, %r14
movq 0x2bc2(%rip), %rdi      # 0x3fd8
leaq 0xc13(%rip), %rsi       # 0x2030
callq 0x10e0
subq %rbx, %r14
cvtsi2sd %r14, %xmm0
divsd 0xbd6(%rip), %xmm0      # 0x2008
movq %rax, %rdi
callq 0x1110
leaq 0xc02(%rip), %rsi       # 0x2043
movq %rax, %rdi
callq 0x10e0
movq %rax, %rdi
callq 0x1070
movq 0x2b80(%rip), %rdi      # 0x3fd8
leaq 0xbed(%rip), %rsi       # 0x204c
callq 0x10e0
movq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x1090
movq %rax, %rdi
callq 0x1070
movq 0x2b58(%rip), %rdi      # 0x3fd8
callq 0x1070
movq %rsp, %rdi
callq 0x16fa
leaq 0x8(%rsp), %rdi
callq 0x16fa
leaq 0x10(%rsp), %rdi
callq 0x16fa
leaq 0x18(%rsp), %rdi
callq 0x16fa
leaq 0x30(%rsp), %rdi
callq 0x1708
xorl %eax, %eax
addq $0x13e0, %rsp           # imm = 0x13E0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x14ea
movq %rax, %rbx
jmp 0x14f4
movq %rax, %rbx
jmp 0x14fe
jmp 0x150a
jmp 0x150a
jmp 0x150a
jmp 0x14df
movq %rax, %rbx
movq %rsp, %rdi
callq 0x16fa
leaq 0x8(%rsp), %rdi
callq 0x16fa
leaq 0x10(%rsp), %rdi
callq 0x16fa
leaq 0x18(%rsp), %rdi
callq 0x16fa
jmp 0x150d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1708
movq %rbx, %rdi
callq 0x1140
nop