// File: Ripser[P]ripser/ripser.cpp
// Function: ripser<sparse_distance_matrix>::assemble_columns_to_reduce(std::vector<std::pair<float, long>, std::allocator<std::pair<float, long>>>&, std::vector<std::pair<float, long>, std::allocator<std::pair<float, long>>>&, std::unordered_map<long, unsigned long, ripser<sparse_distance_matrix>::entry_hash, ripser<sparse_distance_matrix>::equal_index, std::allocator<std::pair<long const, unsigned long>>>&, long)
void assemble_columns_to_reduce(std::vector<diameter_index_t>& simplices,
	                                std::vector<diameter_index_t>& columns_to_reduce,
	                                entry_hash_map& pivot_column_index, index_t dim) {

#ifdef INDICATE_PROGRESS
		std::cerr << clear_line << "assembling columns" << std::flush;
		std::chrono::steady_clock::time_point next = std::chrono::steady_clock::now() + time_step;
#endif

		columns_to_reduce.clear();
		std::vector<diameter_index_t> next_simplices;

		simplex_coboundary_enumerator cofacets(*this);

		for (diameter_index_t& simplex : simplices) {
			cofacets.set_simplex(diameter_entry_t(simplex, 1), dim - 1);

			while (cofacets.has_next(false)) {
#ifdef INDICATE_PROGRESS
				if (std::chrono::steady_clock::now() > next) {
					std::cerr << clear_line << "assembling " << next_simplices.size()
					          << " columns (processing " << std::distance(&simplices[0], &simplex)
					          << "/" << simplices.size() << " simplices)" << std::flush;
					next = std::chrono::steady_clock::now() + time_step;
				}
#endif
				auto cofacet = cofacets.next();
				if (get_diameter(cofacet) <= threshold) {
					if (dim < dim_max) next_simplices.push_back({get_diameter(cofacet), get_index(cofacet)});
					if (!is_in_zero_apparent_pair(cofacet, dim) &&
					    (pivot_column_index.find(get_entry(cofacet)) == pivot_column_index.end()))
						columns_to_reduce.push_back({get_diameter(cofacet), get_index(cofacet)});
				}
			}
		}

		if (dim < dim_max) simplices.swap(next_simplices);

#ifdef INDICATE_PROGRESS
		std::cerr << clear_line << "sorting " << columns_to_reduce.size() << " columns"
		          << std::flush;
#endif

		std::sort(columns_to_reduce.begin(), columns_to_reduce.end(),
		          greater_diameter_or_smaller_index<diameter_index_t>);
#ifdef INDICATE_PROGRESS
		std::cerr << clear_line << std::flush;
#endif
	}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x1e0(%rsp)
movq %rsi, 0x1d8(%rsp)
movq %rdx, 0x1d0(%rsp)
movq %rcx, 0x1c8(%rsp)
movq %r8, 0x1c0(%rsp)
movq 0x1e0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0x1c9c0
leaq 0x1a8(%rsp), %rdi
callq 0x5c70
movq 0x50(%rsp), %rsi
leaq 0x108(%rsp), %rdi
callq 0x15a40
jmp 0x11f1a
movq 0x1d8(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0xb280
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
callq 0xb0f0
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x12620
testb $0x1, %al
jne 0x11f72
jmp 0x12235
leaq 0xe8(%rsp), %rdi
callq 0x12660
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
movl $0x1, %edx
callq 0x18f50
jmp 0x11fa3
movq 0x1c0(%rsp), %rdx
decq %rdx
movss 0xc8(%rsp), %xmm0
movq 0xd0(%rsp), %rsi
leaq 0x108(%rsp), %rdi
callq 0x15b70
jmp 0x11fce
jmp 0x11fd0
leaq 0x108(%rsp), %rdi
xorl %esi, %esi
callq 0x15d40
movb %al, 0x4f(%rsp)
jmp 0x11fe5
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x11ff2
jmp 0x12221
leaq 0x108(%rsp), %rdi
callq 0x16070
movq %rax, 0x40(%rsp)
movss %xmm0, 0x48(%rsp)
jmp 0x1200c
movq 0x40(%rsp), %rax
movss 0x48(%rsp), %xmm0
movss %xmm0, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x2ab0
movq %rax, %rcx
movq 0x50(%rsp), %rax
movss (%rcx), %xmm1
movss 0x30(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x1221c
movq 0x50(%rsp), %rcx
movq 0x1c0(%rsp), %rax
cmpq 0x28(%rcx), %rax
jge 0x12103
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x2ab0
movq 0x30(%rsp), %rdi
movq %rax, 0x38(%rsp)
callq 0x2a70
movq 0x38(%rsp), %rsi
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
callq 0x1c9e0
jmp 0x120ab
leaq 0x1a8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x5f00
jmp 0x120c2
jmp 0x12103
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x122bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x15b30
jmp 0x122bb
movq 0x50(%rsp), %rdi
movups 0xb8(%rsp), %xmm0
movaps %xmm0, 0x90(%rsp)
movq 0x1c0(%rsp), %rdx
movss 0x90(%rsp), %xmm0
movq 0x98(%rsp), %rsi
callq 0x1ca10
movb %al, 0x2f(%rsp)
jmp 0x1213c
movb 0x2f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x2e(%rsp)
jne 0x121b6
jmp 0x1214d
movq 0x1c8(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x2a60
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x193a0
movq %rax, 0x20(%rsp)
jmp 0x1217b
movq 0x20(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x1c8(%rsp), %rdi
callq 0x193f0
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1a4c0
movb %al, 0x2e(%rsp)
movb 0x2e(%rsp), %al
testb $0x1, %al
jne 0x121c0
jmp 0x1221a
movq 0x1d0(%rsp), %rax
movq %rax, (%rsp)
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x2ab0
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%rsp)
callq 0x2a70
movq 0x10(%rsp), %rsi
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1c9e0
jmp 0x12208
movq (%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5f00
jmp 0x12218
jmp 0x1221a
jmp 0x1221c
jmp 0x11fd0
jmp 0x12223
leaq 0xe8(%rsp), %rdi
callq 0x12b70
jmp 0x11f54
movq 0x50(%rsp), %rcx
movq 0x1c0(%rsp), %rax
cmpq 0x28(%rcx), %rax
jge 0x1225d
movq 0x1d8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x1cae0
movq 0x1d0(%rsp), %rdi
callq 0xb280
movq %rax, 0x60(%rsp)
movq 0x1d0(%rsp), %rdi
callq 0xb0f0
movq %rax, 0x58(%rsp)
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x2de(%rip), %rdx       # 0x12570
callq 0x1cb40
jmp 0x12299
leaq 0x108(%rsp), %rdi
callq 0x15b30
leaq 0x1a8(%rsp), %rdi
callq 0x5fc0
addq $0x1e8, %rsp            # imm = 0x1E8
retq
leaq 0x1a8(%rsp), %rdi
callq 0x5fc0
movq 0x100(%rsp), %rdi
callq 0x2380
nopw %cs:(%rax,%rax)
nop