// File: /workspace/github_cpp_makefile_star2_O1/btbujiangjun[P]abcdl/include/utils/ParallelOperator.h
// Function: abcdl::utils::ParallelOperator<int>::parallel_reduce_mul2one(int*, unsigned long*, int const*, unsigned long, std::function<void (int*, int const&, unsigned long*, unsigned long)> const&) const
void parallel_reduce_mul2one(T* result_value,
                                 size_t* result_idx,
                                 const T* op1,
                         		 const size_t num_op1,
                         		 const std::function<void(T*, const T&, size_t*, const size_t)> &f) const{
        size_t block_size = get_block_size(num_op1);
        size_t num_thread = get_num_thread(num_op1, block_size);
        std::vector<std::thread> threads(num_thread);
		T* data = new T[num_thread];
		size_t* indices = new size_t[num_thread];

        for(size_t i = 0; i != num_thread; i++){
            threads[i] = std::thread(
                [&op1, &result_value, &result_idx, &data, &indices, i, &f](size_t start_idx, size_t end_idx){
					for(size_t ti = start_idx; ti != end_idx; ti++){
            			if(ti == start_idx){
							data[i] = op1[ti];
                            indices[i] = ti;
						}else{
    						f(&data[i], op1[ti], &indices[i], ti);
                        }
                    }
					f(result_value, data[i], result_idx, indices[i]);
                }, i * block_size, std::min(num_op1, (i + 1) * block_size)
            );
        }

        for(auto& thread : threads){
            thread.join();
        }
		delete[] data;
        delete[] indices;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, 0x20(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x18(%rsp)
movq (%rdi), %r14
movq 0x8(%rdi), %rcx
movq %r8, %rax
xorl %edx, %edx
divq %r14
cmpq $0x1, %rdx
sbbq $-0x1, %rax
cmpq %r8, %rcx
movq %r8, %rbp
cmovbq %rcx, %rbp
cmpq %rcx, %rax
cmovaeq %rax, %rbp
cmpq %rbp, %rcx
jb 0xb55e
movq %r8, %rax
xorl %edx, %edx
divq %rbp
movq %rax, %r14
cmpq $0x1, %rdx
sbbq $-0x1, %r14
leaq 0x40(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movq %r14, %rsi
callq 0xa482
movq %r14, %rax
shrq $0x3e, %rax
leaq (,%r14,4), %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x9030
movq %rax, 0x10(%rsp)
movq %r14, %rax
shrq $0x3d, %rax
leaq (,%r14,8), %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x9030
movq %rax, 0x8(%rsp)
testq %r14, %r14
je 0xb66f
xorl %ebx, %ebx
leaq 0x70(%rsp), %r12
leaq 0x30(%rsp), %r13
xorl %r15d, %r15d
leaq 0x58(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %r15, 0x98(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rbx, 0x30(%rsp)
addq %rbp, %rbx
movq %rbx, 0x28(%rsp)
leaq 0x28(%rsp), %rcx
cmpq 0x18(%rsp), %rbx
jb 0xb63e
leaq 0x18(%rsp), %rcx
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xb6e6
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax,%r15,8)
jne 0xb6c6
movq 0x38(%rsp), %rcx
movq %rcx, (%rax,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0xb5d0
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r14
cmpq %r14, %rbx
je 0xb68c
movq %rbx, %rdi
callq 0x95a0
addq $0x8, %rbx
jmp 0xb679
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xb69b
callq 0x9420
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xb6aa
callq 0x9420
leaq 0x40(%rsp), %rdi
callq 0xa594
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x90c0
jmp 0xb6d1
jmp 0xb6d1
jmp 0xb6d1
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xa594
movq %rbx, %rdi
callq 0x95d0