// File: /workspace/github_c_makefile_star2_O0/aligrudi[P]gpss/gpss.c
// Function: gpss_greedymin_next
static int gpss_greedymin_next(int *P, int *ptmk)
{
	int *lncnt;	/* number of selected points on each line */
	int *ptcnt;	/* number of remaining collinear points for each point */
	int *ptout;	/* indicates if point cannot be selected */
	int i, j, k;
	int best = -1;
	lncnt = calloc(ln_n, sizeof(lncnt[0]));
	ptcnt = calloc(pt_n, sizeof(ptcnt[0]));
	ptout = calloc(pt_n, sizeof(ptout[0]));
	for (i = 0; i < pt_n; i++) {
		if (ptmk[i]) {
			for (j = 0; j < pt_cnt[i]; j++)
				lncnt[pt_ln[i][j]]++;
		}
	}
	for (i = 0; i < pt_n; i++) {
		for (j = 0; j < pt_cnt[i]; j++)
			if (lncnt[pt_ln[i][j]] >= 2)
				ptout[i] = 1;
		if (ptout[i])
			continue;
		for (j = 0; j < pt_cnt[i]; j++) {
			int l = pt_ln[i][j];
			for (k = 0; k < ln_cnt[l]; k++)
				ptcnt[ln[l][k]]++;
		}
	}
	for (i = 0; i < pt_n; i++) {
		int p = P[i];
		if (!ptmk[p] && !ptout[p] && (best < 0 || ptcnt[p] < ptcnt[best]))
			best = p;
	}
	for (i = 0; i < pt_n; i++) {	/* points covered by only one line */
		int p = P[i];
		if (!ptmk[p] && !ptout[p] && pt_cnt[p] == 1)
			return p;
	}
	free(lncnt);
	free(ptcnt);
	free(ptout);
	return best;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movslq 0x2e5e(%rip), %rdi      # 0x506c
movl $0x4, %esi
callq 0x1070
movq %rax, -0x20(%rbp)
movslq 0x2e45(%rip), %rdi      # 0x5068
movl $0x4, %esi
callq 0x1070
movq %rax, -0x28(%rbp)
movslq 0x2e30(%rip), %rdi      # 0x5068
movl $0x4, %esi
callq 0x1070
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x2e12(%rip), %eax      # 0x5068
jge 0x22be
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x22b1
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq 0x2e11(%rip), %rcx      # 0x5088
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x22af
movq -0x20(%rbp), %rax
movq 0x2df5(%rip), %rcx      # 0x5080
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x226d
jmp 0x22b1
jmp 0x22b3
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x224d
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x2d9a(%rip), %eax      # 0x5068
jge 0x23da
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq 0x2da3(%rip), %rcx      # 0x5088
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x232b
movq -0x20(%rbp), %rax
movq 0x2d87(%rip), %rcx      # 0x5080
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x2, (%rax,%rcx,4)
jl 0x231e
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x2320
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x22db
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x233e
jmp 0x23cc
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq 0x2d39(%rip), %rcx      # 0x5088
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x23ca
movq 0x2d21(%rip), %rax      # 0x5080
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq 0x2cf6(%rip), %rcx      # 0x5078
movslq -0x44(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x23ba
movq -0x28(%rbp), %rax
movq 0x2cda(%rip), %rcx      # 0x5070
movslq -0x44(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2378
jmp 0x23bc
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2345
jmp 0x23cc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x22c5
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x2c7e(%rip), %eax      # 0x5068
jge 0x2447
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x243a
movq -0x30(%rbp), %rax
movslq -0x48(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x243a
cmpl $0x0, -0x40(%rbp)
jl 0x2434
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x243a
movl -0x48(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x243c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x23e1
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x2c11(%rip), %eax      # 0x5068
jge 0x24a9
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x249c
movq -0x30(%rbp), %rax
movslq -0x4c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x249c
movq 0x2bfe(%rip), %rax      # 0x5088
movslq -0x4c(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x249c
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x24ca
jmp 0x249e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x244e
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)