// File: Laakeri[P]Triangulator/src/setcover.cpp
// Function: SetCover::LPSolver::Simplex(int)
bool Simplex(int phase) {
		int x = phase == 1 ? m + 1 : m;
		while (true) {
			int s = -1;
			for (int j = 0; j <= n; j++) {
				if (phase == 2 && N[j] == -1) continue;
				if (s==-1||D[x][j]<D[x][s]||(D[x][j]==D[x][s]&&N[j]<N[s])) s=j;
			}
			if (D[x][s] > -eps) return true;
			int r = -1;
			for (int i = 0; i < m; i++) {
				if (D[i][s] < eps) continue;
				if (r == -1 || D[i][n + 1] / D[i][s] < D[r][n + 1] / D[r][s] ||
					((D[i][n + 1]/D[i][s])==(D[r][n+1]/D[r][s])&&B[i]<B[r]))r=i;
			}
			if (r == -1) return false;
			Pivot(r, s);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x50c9f
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x50ca9
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x20(%rbp)
movq -0x30(%rbp), %rcx
movl -0x20(%rbp), %eax
cmpl 0x24(%rcx), %eax
jg 0x50ddf
cmpl $0x2, -0x14(%rbp)
jne 0x50cee
movq -0x30(%rbp), %rdi
addq $0x28, %rdi
movslq -0x20(%rbp), %rsi
callq 0x178f0
cmpl $-0x1, (%rax)
jne 0x50cee
jmp 0x50dd1
cmpl $-0x1, -0x1c(%rbp)
je 0x50dc9
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x48(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0x4e870
movq -0x48(%rbp), %rdi
fldt (%rax)
fstpt -0x40(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0x40(%rbp)
fldt (%rax)
fucompi %st(1), %st
fstp %st(0)
ja 0x50dc9
jmp 0x50d48
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x60(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x20(%rbp), %rsi
callq 0x4e870
movq -0x60(%rbp), %rdi
fldt (%rax)
fstpt -0x54(%rbp)
movslq -0x18(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0x54(%rbp)
fldt (%rax)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jne 0x50dcf
jp 0x50dcf
jmp 0x50d98
movq -0x30(%rbp), %rdi
addq $0x28, %rdi
movslq -0x20(%rbp), %rsi
callq 0x178f0
movq -0x30(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x64(%rbp)
addq $0x28, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x178f0
movq %rax, %rcx
movl -0x64(%rbp), %eax
cmpl (%rcx), %eax
jge 0x50dcf
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x50dd1
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x50cbd
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movslq -0x18(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
movq %rax, %rcx
movq -0x30(%rbp), %rax
fldt (%rcx)
fldt (%rax)
fchs
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x50e1c
jmp 0x50e13
movb $0x1, -0x1(%rbp)
jmp 0x51062
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rcx
movl -0x28(%rbp), %eax
cmpl 0x20(%rcx), %eax
jge 0x51042
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movslq -0x28(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
movq %rax, %rcx
movq -0x30(%rbp), %rax
fldt (%rcx)
fldt (%rax)
fucompi %st(1), %st
fstp %st(0)
jbe 0x50e6f
jmp 0x50e6a
jmp 0x51034
cmpl $-0x1, -0x24(%rbp)
je 0x5102c
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x88(%rbp)
movslq -0x28(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
incl %eax
movslq %eax, %rsi
callq 0x4e870
movq -0x88(%rbp), %rdi
fldt (%rax)
fstpt -0x94(%rbp)
movslq -0x28(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0x94(%rbp)
movq -0x88(%rbp), %rdi
fldt (%rax)
fdivrp %st, %st(1)
fstpt -0x70(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
incl %eax
movslq %eax, %rsi
callq 0x4e870
movq -0x88(%rbp), %rdi
fldt (%rax)
fstpt -0x7c(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0x7c(%rbp)
fldt -0x70(%rbp)
fldt (%rax)
fdivrp %st, %st(2)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0x5102c
jmp 0x50f33
movq -0x30(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0xb8(%rbp)
movslq -0x28(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
incl %eax
movslq %eax, %rsi
callq 0x4e870
movq -0xb8(%rbp), %rdi
fldt (%rax)
fstpt -0xc4(%rbp)
movslq -0x28(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0xc4(%rbp)
movq -0xb8(%rbp), %rdi
fldt (%rax)
fdivrp %st, %st(1)
fstpt -0xa0(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
incl %eax
movslq %eax, %rsi
callq 0x4e870
movq -0xb8(%rbp), %rdi
fldt (%rax)
fstpt -0xac(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x4e7c0
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x4e870
fldt -0xac(%rbp)
fldt -0xa0(%rbp)
fldt (%rax)
fdivrp %st, %st(2)
fucompi %st(1), %st
fstp %st(0)
jne 0x51032
jp 0x51032
jmp 0x50ff5
movq -0x30(%rbp), %rdi
addq $0x40, %rdi
movslq -0x28(%rbp), %rsi
callq 0x178f0
movq -0x30(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
addq $0x40, %rdi
movslq -0x24(%rbp), %rsi
callq 0x178f0
movq %rax, %rcx
movl -0xc8(%rbp), %eax
cmpl (%rcx), %eax
jge 0x51032
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x51034
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x50e2a
cmpl $-0x1, -0x24(%rbp)
jne 0x5104e
movb $0x0, -0x1(%rbp)
jmp 0x51062
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x50a20
jmp 0x50caf
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq