// File: /workspace/github_c_makefile_star2_O0/aligrudi[P]gpss/gpss.c
// Function: gpss_linecover
static int gpss_linecover(int *S, int *P)
{
	int i, j;
	int S_n = 0;
	int S_n2 = 0;
	int *lnmk;	/* indicates if each line is selected */
	int *ptmk;	/* number of times a point is covered */
	int rem = 0;
	lnmk = calloc(ln_n, sizeof(lnmk[0]));
	ptmk = calloc(pt_n, sizeof(ptmk[0]));
	while (1) {
		int lnbest = gpss_linecover_next(P, lnmk);
		if (lnbest < 0)
			break;
		lnmk[lnbest] = 1;
		S[S_n++] = lnbest;
		/* marking covered points */
		for (i = 0; i < ln_cnt[lnbest]; i++)
			ptmk[ln[lnbest][i]] = 1;
	}
	/* removing lines covered twice */
	for (i = 0; i < S_n; i++) {
		int covered = 1;
		for (j = 0; j < ln_cnt[S[i]]; j++)
			if (ptmk[ln[S[i]][j]] == 1)
				covered = 0;
		if (covered) {
			for (j = 0; j < ln_cnt[S[i]]; j++)
				ptmk[ln[S[i]][j]]--;
		} else {
			S[S_n2++] = S[i];
		}
	}
	S_n = S_n2;
	/* uncovered vertices */
	for (i = 0; i < pt_n; i++)
		if (!ptmk[i])
			rem++;
	free(lnmk);
	free(ptmk);
	return S_n * 2 + rem;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movslq 0x38d0(%rip), %rdi      # 0x506c
movl $0x4, %esi
callq 0x1070
movq %rax, -0x28(%rbp)
movslq 0x38b7(%rip), %rdi      # 0x5068
movl $0x4, %esi
callq 0x1070
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1e50
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x17d7
jmp 0x184a
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x38(%rbp), %edx
movq -0x8(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq 0x3869(%rip), %rcx      # 0x5078
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x1845
movq -0x30(%rbp), %rax
movq 0x384d(%rip), %rcx      # 0x5070
movslq -0x38(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x14(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1805
jmp 0x17bf
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1954
movl $0x1, -0x3c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq 0x3803(%rip), %rcx      # 0x5078
movq -0x8(%rbp), %rdx
movslq -0x14(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x18c3
movq -0x30(%rbp), %rax
movq 0x37df(%rip), %rcx      # 0x5070
movq -0x8(%rbp), %rdx
movslq -0x14(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x18b6
movl $0x0, -0x3c(%rbp)
jmp 0x18b8
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x186b
cmpl $0x0, -0x3c(%rbp)
je 0x1924
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq 0x379e(%rip), %rcx      # 0x5078
movq -0x8(%rbp), %rdx
movslq -0x14(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x1922
movq -0x30(%rbp), %rax
movq 0x377a(%rip), %rcx      # 0x5070
movq -0x8(%rbp), %rdx
movslq -0x14(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x18d0
jmp 0x1944
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1946
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1851
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x36fe(%rip), %eax      # 0x5068
jge 0x1990
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x1983
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1985
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1961
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
movl -0x1c(%rbp), %eax
shll %eax
addl -0x34(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq