// File: Laakeri[P]Triangulator/src/MCS.cpp
// Function: MCS::MCS_MP(Graph const&)
pair<vector<pair<int, int> >, vector<pair<int, int> > > MCS_MP(const Graph& G) {
	for (int i = 0; i < G.n; i++) {
		label[i] = 0;
		rm[i] = 0;
		reach[i].clear();
		rc[i] = 0;
	}
	vector<pair<int, int> > fill;
	vector<pair<int, int> > order(G.n);
	int s = -1;
	for (int it = G.n-1; it >= 0; it--) {
		int x = -1;
		for (int i = 0; i < G.n; i++) {
			if (rm[i] == 0 && label[i] >= label[x]) {
				x = i;
			}
		}
		assert(x >= 0 && rm[x] == 0 && label[x] < G.n);
		order[it] = {x, (label[x] <= s)};
		s = label[x];
		for (int i = 0; i < G.n; i++) {
			rc[i] = 0;
		}
		rc[x] = 1;
		rm[x] = 1;
		for (int y : G.g[x]) {
			if (rm[y] == 0) {
				rc[y] = 1;
				reach[label[y]].push_back(y);
			}
		}
		for (int j = 0; j < G.n; j++) {
			while (!reach[j].empty()) {
				int y = reach[j].back();
				reach[j].pop_back();
				for (int z : G.g[y]) {
					if (rm[z] == 0 && rc[z] == 0) {
						rc[z] = 1;
						if (label[z] > j) {
							reach[label[z]].push_back(z);
							label[z]++;
							fill.push_back({x, z});
						}
						else {
							reach[j].push_back(z);
						}
					}
				}
			}
		}
		for (int y : G.g[x]) {
			if (rm[y] == 0) {
				label[y]++;
			}
		}
	}
	return {fill, order};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x100(%rbp)
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x28b1f
movslq -0x14(%rbp), %rcx
leaq 0x29b75e(%rip), %rax    # 0x2c4230
movl $0x0, (%rax,%rcx,4)
movslq -0x14(%rbp), %rcx
leaq 0x2cc48c(%rip), %rax    # 0x2f4f70
movl $0x0, (%rax,%rcx,4)
movslq -0x14(%rbp), %rax
leaq 0x5183a(%rip), %rdi     # 0x7a330
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x17980
movslq -0x14(%rbp), %rcx
leaq 0x2fd1a3(%rip), %rax    # 0x325cb0
movl $0x0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x28abb
leaq -0x30(%rbp), %rdi
callq 0xbd50
movq -0x10(%rbp), %rax
movslq 0x50(%rax), %rax
movq %rax, -0x110(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x53b0
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x2dbb0
jmp 0x28b60
leaq -0x49(%rbp), %rdi
callq 0x5450
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jl 0x290e2
movl $0xffffffff, -0x68(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x28bff
movslq -0x6c(%rbp), %rcx
leaq 0x2cc3c4(%rip), %rax    # 0x2f4f70
cmpl $0x0, (%rax,%rcx,4)
jne 0x28bf2
movslq -0x6c(%rbp), %rcx
leaq 0x29b673(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %eax
movslq -0x68(%rbp), %rdx
leaq 0x29b665(%rip), %rcx    # 0x2c4230
cmpl (%rcx,%rdx,4), %eax
jl 0x28bf2
movl -0x6c(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x28bf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x5450
jmp 0x2911a
jmp 0x28bf4
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x28b95
xorl %eax, %eax
cmpl $0x0, -0x68(%rbp)
movb %al, -0x111(%rbp)
jl 0x28c44
movslq -0x68(%rbp), %rdx
xorl %eax, %eax
leaq 0x2cc356(%rip), %rcx    # 0x2f4f70
cmpl $0x0, (%rcx,%rdx,4)
movb %al, -0x111(%rbp)
jne 0x28c44
movslq -0x68(%rbp), %rcx
leaq 0x29b5ff(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
setl %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x28c50
jmp 0x28c52
jmp 0x28c71
leaq 0x3102f(%rip), %rdi     # 0x59c88
leaq 0x3104f(%rip), %rsi     # 0x59caf
movl $0x33, %edx
leaq 0x3104b(%rip), %rcx     # 0x59cb7
callq 0x31a0
movslq -0x68(%rbp), %rcx
leaq 0x29b5b4(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %eax
movl -0x60(%rbp), %ecx
subl %ecx, %eax
setle -0x75(%rbp)
leaq -0x74(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x75(%rbp), %rdx
callq 0x2dc20
jmp 0x28c9b
movslq -0x64(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2dc50
movq %rax, %rdi
leaq -0x74(%rbp), %rsi
callq 0x13e20
movslq -0x68(%rbp), %rcx
leaq 0x29b571(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x28d0f
movslq -0x7c(%rbp), %rcx
leaq 0x2fcfcd(%rip), %rax    # 0x325cb0
movl $0x0, (%rax,%rcx,4)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x28ccc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5470
jmp 0x2911a
movslq -0x68(%rbp), %rcx
leaq 0x2fcf96(%rip), %rax    # 0x325cb0
movl $0x1, (%rax,%rcx,4)
movslq -0x68(%rbp), %rcx
leaq 0x2cc244(%rip), %rax    # 0x2f4f70
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movslq -0x68(%rbp), %rsi
callq 0xbba0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x6680
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
callq 0x66b0
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xbbc0
testb $0x1, %al
jne 0x28d8d
jmp 0x28e0e
leaq -0x90(%rbp), %rdi
callq 0xbc00
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
movslq -0x9c(%rbp), %rcx
leaq 0x2cc1c1(%rip), %rax    # 0x2f4f70
cmpl $0x0, (%rax,%rcx,4)
jne 0x28dfb
movslq -0x9c(%rbp), %rcx
leaq 0x2fceed(%rip), %rax    # 0x325cb0
movl $0x1, (%rax,%rcx,4)
movslq -0x9c(%rbp), %rcx
leaq 0x29b458(%rip), %rax    # 0x2c4230
movslq (%rax,%rcx,4), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x51549(%rip), %rax     # 0x7a330
leaq (%rax,%rcx,8), %rdi
leaq -0x9c(%rbp), %rsi
callq 0xdff0
jmp 0x28df9
jmp 0x28dfb
jmp 0x28dfd
leaq -0x90(%rbp), %rdi
callq 0xbc80
jmp 0x28d71
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x29025
jmp 0x28e2d
movslq -0xa0(%rbp), %rax
leaq 0x514f5(%rip), %rdi     # 0x7a330
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x2dc70
xorb $-0x1, %al
testb $0x1, %al
jne 0x28e52
jmp 0x2900f
movslq -0xa0(%rbp), %rax
leaq 0x514d0(%rip), %rdi     # 0x7a330
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x17940
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
movslq -0xa0(%rbp), %rax
leaq 0x514ae(%rip), %rdi     # 0x7a330
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x178c0
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movslq -0xa4(%rbp), %rsi
callq 0xbba0
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x6680
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x66b0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xbbc0
testb $0x1, %al
jne 0x28eeb
jmp 0x2900a
leaq -0xb8(%rbp), %rdi
callq 0xbc00
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
movslq -0xc4(%rbp), %rcx
leaq 0x2cc063(%rip), %rax    # 0x2f4f70
cmpl $0x0, (%rax,%rcx,4)
jne 0x28ff7
movslq -0xc4(%rbp), %rcx
leaq 0x2fcd8b(%rip), %rax    # 0x325cb0
cmpl $0x0, (%rax,%rcx,4)
jne 0x28ff7
movslq -0xc4(%rbp), %rcx
leaq 0x2fcd73(%rip), %rax    # 0x325cb0
movl $0x1, (%rax,%rcx,4)
movslq -0xc4(%rbp), %rcx
leaq 0x29b2de(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %eax
cmpl -0xa0(%rbp), %eax
jle 0x28fcf
movslq -0xc4(%rbp), %rcx
leaq 0x29b2c5(%rip), %rax    # 0x2c4230
movslq (%rax,%rcx,4), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x513b6(%rip), %rax     # 0x7a330
leaq (%rax,%rcx,8), %rdi
leaq -0xc4(%rbp), %rsi
callq 0xdff0
jmp 0x28f8c
movslq -0xc4(%rbp), %rcx
leaq 0x29b296(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %edx
incl %edx
movl %edx, (%rax,%rcx,4)
leaq -0xcc(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0xc4(%rbp), %rdx
callq 0xdfc0
jmp 0x28fbb
leaq -0x30(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
callq 0x179a0
jmp 0x28fcd
jmp 0x28ff5
movslq -0xa0(%rbp), %rax
leaq (%rax,%rax,2), %rcx
leaq 0x5134f(%rip), %rax     # 0x7a330
leaq (%rax,%rcx,8), %rdi
leaq -0xc4(%rbp), %rsi
callq 0xdff0
jmp 0x28ff3
jmp 0x28ff5
jmp 0x28ff7
jmp 0x28ff9
leaq -0xb8(%rbp), %rdi
callq 0xbc80
jmp 0x28ecf
jmp 0x28e2d
jmp 0x29011
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x28e18
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movslq -0x68(%rbp), %rsi
callq 0xbba0
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x6680
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x66b0
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xbbc0
testb $0x1, %al
jne 0x2907c
jmp 0x290d2
leaq -0xe0(%rbp), %rdi
callq 0xbc00
movl (%rax), %eax
movl %eax, -0xec(%rbp)
movslq -0xec(%rbp), %rcx
leaq 0x2cbed2(%rip), %rax    # 0x2f4f70
cmpl $0x0, (%rax,%rcx,4)
jne 0x290c2
movslq -0xec(%rbp), %rcx
leaq 0x29b17e(%rip), %rax    # 0x2c4230
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
leaq 0x29b171(%rip), %rax    # 0x2c4230
movl %edx, (%rax,%rcx,4)
jmp 0x290c4
leaq -0xe0(%rbp), %rdi
callq 0xbc80
jmp 0x29063
jmp 0x290d4
movl -0x64(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x28b7d
movq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x2dcb0
jmp 0x290f8
leaq -0x48(%rbp), %rdi
callq 0x5470
leaq -0x30(%rbp), %rdi
callq 0x5470
movq -0xf8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x5470
movq -0x58(%rbp), %rdi
callq 0x3480
nopl (%rax)