// File: /workspace/github_c_makefile_star2_O0/aligrudi[P]gpss/gpss.c
// Function: gpss_greedymax_next
static int gpss_greedymax_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 need not be removed */
	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++) {
		ptout[i] = 1;
		if (!ptmk[i])
			continue;
		for (j = 0; j < pt_cnt[i]; j++)
			if (lncnt[pt_ln[i][j]] > 2)
				ptout[i] = 0;
		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;
	}
	free(lncnt);
	free(ptcnt);
	free(ptout);
	return best;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movslq 0x2b6e(%rip), %rdi      # 0x506c
movl $0x4, %esi
callq 0x1070
movq %rax, -0x18(%rbp)
movslq 0x2b55(%rip), %rdi      # 0x5068
movl $0x4, %esi
callq 0x1070
movq %rax, -0x20(%rbp)
movslq 0x2b40(%rip), %rdi      # 0x5068
movl $0x4, %esi
callq 0x1070
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2b22(%rip), %eax      # 0x5068
jge 0x25ae
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x25a1
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq 0x2b21(%rip), %rcx      # 0x5088
movslq -0x2c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x259f
movq -0x18(%rbp), %rax
movq 0x2b05(%rip), %rcx      # 0x5080
movslq -0x2c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x30(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x255d
jmp 0x25a1
jmp 0x25a3
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x253d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2aaa(%rip), %eax      # 0x5068
jge 0x26d9
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x25e6
jmp 0x26cb
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq 0x2a91(%rip), %rcx      # 0x5088
movslq -0x2c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x263d
movq -0x18(%rbp), %rax
movq 0x2a75(%rip), %rcx      # 0x5080
movslq -0x2c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x30(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x2, (%rax,%rcx,4)
jle 0x2630
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x2632
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x25ed
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq 0x2a3a(%rip), %rcx      # 0x5088
movslq -0x2c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x26c9
movq 0x2a22(%rip), %rax      # 0x5080
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq 0x29f7(%rip), %rcx      # 0x5078
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x26b9
movq -0x20(%rbp), %rax
movq 0x29db(%rip), %rcx      # 0x5070
movslq -0x3c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x34(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2677
jmp 0x26bb
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2644
jmp 0x26cb
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x25b5
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x297f(%rip), %eax      # 0x5068
jge 0x2746
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x2739
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x2739
cmpl $0x0, -0x38(%rbp)
jl 0x2733
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movslq -0x38(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x2739
movl -0x40(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x273b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x26e0
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x20(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movl -0x38(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)