// File: Ripser[P]ripser/ripser.cpp
// Function: ripser<sparse_distance_matrix>::compute_dim_0_pairs(std::vector<std::pair<float, long>, std::allocator<std::pair<float, long>>>&, std::vector<std::pair<float, long>, std::allocator<std::pair<float, long>>>&)
void compute_dim_0_pairs(std::vector<diameter_index_t>& edges,
	                         std::vector<diameter_index_t>& columns_to_reduce) {
#ifdef PRINT_PERSISTENCE_PAIRS
		std::cout << "persistence intervals in dim 0:" << std::endl;
#endif

		union_find dset(n);

		edges = get_edges();
		std::sort(edges.rbegin(), edges.rend(),
		          greater_diameter_or_smaller_index<diameter_index_t>);
		std::vector<index_t> vertices_of_edge(2);
		for (auto e : edges) {
			get_simplex_vertices(get_index(e), 1, n, vertices_of_edge.rbegin());
			index_t u = dset.find(vertices_of_edge[0]), v = dset.find(vertices_of_edge[1]);

			if (u != v) {
#ifdef PRINT_PERSISTENCE_PAIRS
				if (get_diameter(e) != 0)
					std::cout << " [0," << get_diameter(e) << ")" << std::endl;
#endif
				dset.link(u, v);
			} else if ((dim_max > 0) && (get_index(get_zero_apparent_cofacet(e, 1)) == -1))
				columns_to_reduce.push_back(e);
		}
		if (dim_max > 0) std::reverse(columns_to_reduce.begin(), columns_to_reduce.end());

#ifdef PRINT_PERSISTENCE_PAIRS
		for (index_t i = 0; i < n; ++i)
			if (dset.find(i) == i) std::cout << " [0, )" << std::endl;
#endif
	}

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movq %rdx, 0x190(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x1def2(%rip), %rdi     # 0x2efb8
leaq 0x1154b(%rip), %rsi     # 0x22618
callq 0x2230
movq %rax, %rdi
movq 0x1deb4(%rip), %rsi     # 0x2ef90
callq 0x2250
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rsi
leaq 0x160(%rsp), %rdi
callq 0x122f0
movq 0x80(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x2fd0
jmp 0x11111
movq 0x198(%rsp), %rdi
leaq 0x148(%rsp), %rsi
movq %rsi, 0x68(%rsp)
callq 0x12430
movq 0x68(%rsp), %rdi
callq 0x5fc0
movq 0x198(%rsp), %rsi
leaq 0x130(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x124d0
movq 0x198(%rsp), %rsi
leaq 0x128(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x12520
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0x13f6(%rip), %rdx      # 0x12570
callq 0x12470
jmp 0x11181
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x5c80
movq 0x60(%rsp), %rdx
leaq 0x110(%rsp), %rdi
movl $0x2, %esi
callq 0x5c90
jmp 0x111ac
leaq 0x10f(%rsp), %rdi
callq 0x5d10
movq 0x198(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0xb280
movq %rax, 0xf8(%rsp)
movq 0x100(%rsp), %rdi
callq 0xb0f0
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x12620
testb $0x1, %al
jne 0x11211
jmp 0x114e8
leaq 0xf8(%rsp), %rdi
callq 0x12660
movups (%rax), %xmm0
movaps %xmm0, 0xe0(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2a20
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x48(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x50(%rsp)
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x58(%rsp)
leaq 0x110(%rsp), %rsi
callq 0x5e90
movq 0x80(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %r8
movq 0x58(%rsp), %r9
leaq 0xd0(%rsp), %rdi
movl $0x1, %ecx
callq 0x12670
jmp 0x11294
xorl %eax, %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0x5ee0
movq (%rax), %rsi
leaq 0x160(%rsp), %rdi
callq 0x127a0
movq %rax, 0x40(%rsp)
jmp 0x112bc
movq 0x40(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0x110(%rsp), %rdi
movl $0x1, %esi
callq 0x5ee0
movq (%rax), %rsi
leaq 0x160(%rsp), %rdi
callq 0x127a0
movq %rax, 0x38(%rsp)
jmp 0x112f2
movq 0x38(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
cmpq 0xc0(%rsp), %rax
je 0x1141f
leaq 0xe0(%rsp), %rdi
callq 0x2a10
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x11331
jp 0x11331
jmp 0x113fb
movq 0x1dc80(%rip), %rdi     # 0x2efb8
leaq 0x112f9(%rip), %rsi     # 0x22638
callq 0x2230
movq %rax, 0x30(%rsp)
jmp 0x1134b
leaq 0xe0(%rsp), %rdi
callq 0x2a10
movq 0x30(%rsp), %rdi
callq 0x21e0
movq %rax, 0x28(%rsp)
jmp 0x11369
movq 0x28(%rsp), %rdi
leaq 0x112cd(%rip), %rsi     # 0x22642
callq 0x2230
movq %rax, 0x20(%rsp)
jmp 0x11381
movq 0x20(%rsp), %rdi
movq 0x1dc03(%rip), %rsi     # 0x2ef90
callq 0x2250
jmp 0x11394
jmp 0x113fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x115f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x10f(%rsp), %rdi
callq 0x5d10
jmp 0x115f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x5f60
jmp 0x115f1
movq 0xc8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
leaq 0x160(%rsp), %rdi
callq 0x12850
jmp 0x1141a
jmp 0x114d4
movq 0x80(%rsp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x28(%rcx)
movb %al, 0x1f(%rsp)
jle 0x114af
leaq 0xa0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x12aa0
jmp 0x1144b
movq 0x80(%rsp), %rdi
movss 0xa0(%rsp), %xmm0
movq 0xa8(%rsp), %rsi
movl $0x1, %edx
callq 0x12980
movq %rax, 0x10(%rsp)
movss %xmm0, 0x18(%rsp)
jmp 0x1147b
movq 0x10(%rsp), %rax
movss 0x18(%rsp), %xmm0
movss %xmm0, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x2a70
cmpq $-0x1, %rax
sete %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x114b9
jmp 0x114d2
movq 0x190(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x12b00
jmp 0x114d0
jmp 0x114d2
jmp 0x114d4
jmp 0x114d6
leaq 0xf8(%rsp), %rdi
callq 0x12b70
jmp 0x111f3
movq 0x80(%rsp), %rax
cmpq $0x0, 0x28(%rax)
jle 0x1153a
movq 0x190(%rsp), %rdi
callq 0xb280
movq %rax, 0x98(%rsp)
movq 0x190(%rsp), %rdi
callq 0xb0f0
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x12b90
jmp 0x11538
jmp 0x1153a
movq $0x0, 0x88(%rsp)
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %rax
cmpq 0x20(%rcx), %rax
jge 0x115cf
movq 0x88(%rsp), %rsi
leaq 0x160(%rsp), %rdi
callq 0x127a0
movq %rax, 0x8(%rsp)
jmp 0x11578
movq 0x8(%rsp), %rax
cmpq 0x88(%rsp), %rax
jne 0x115b4
movq 0x1da2a(%rip), %rdi     # 0x2efb8
leaq 0x110a8(%rip), %rsi     # 0x2263d
callq 0x2230
movq %rax, (%rsp)
jmp 0x115a0
movq (%rsp), %rdi
movq 0x1d9e5(%rip), %rsi     # 0x2ef90
callq 0x2250
jmp 0x115b2
jmp 0x115b4
jmp 0x115b6
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x11546
leaq 0x110(%rsp), %rdi
callq 0x5f60
leaq 0x160(%rsp), %rdi
callq 0x12bd0
addq $0x1a8, %rsp            # imm = 0x1A8
retq
leaq 0x160(%rsp), %rdi
callq 0x12bd0
movq 0x140(%rsp), %rdi
callq 0x2380
nopl (%rax,%rax)