// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_main.c
// Function: getRandomMapByPlayerCount
MapInfo *getRandomMapByPlayerCount(int count) {
	MapInfo *criteriaList = NULL;
	MapInfo *clPtr = NULL;
	int mapCounter = 0;
	int randNum;

	for(int i = 0; maplist[i].mapname; i++) {
		if (maplist[i].minplayers > count || maplist[i].maxplayers < count) {
			gi.dprintf("Excluding %s due to min/max playercount\n", maplist[i].mapname);
			continue;
		}
		if (!criteriaList) {
			criteriaList = clPtr = &maplist[i];			
		} else {
			clPtr->next = &maplist[i];
			clPtr = clPtr->next;
			clPtr->next = NULL;
		}
		mapCounter++;
	}

	//QW// Added. This should never happen.
	if (!clPtr || !criteriaList) {
		gi.error("%s line %i: NULL pointer error.", __func__, __LINE__);
		abort(); // Shut up compiler.
	}

	clPtr->next = criteriaList;
	srand(time(0));
	randNum = rand() % (mapCounter - 2);
	for(int i = 0; i < randNum; i++) 
		clPtr = clPtr->next;	
	return clPtr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rcx
movq 0x44784(%rip), %rax     # 0x827c8
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x3e122
movslq -0x24(%rbp), %rcx
movq 0x44768(%rip), %rax     # 0x827c8
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x4(%rbp), %eax
jg 0x3e089
movslq -0x24(%rbp), %rcx
movq 0x4474e(%rip), %rax     # 0x827c8
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpl -0x4(%rbp), %eax
jge 0x3e0b6
movq 0x44570(%rip), %rax     # 0x82600
movq 0x8(%rax), %rcx
movslq -0x24(%rbp), %rdx
movq 0x44729(%rip), %rax     # 0x827c8
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq (%rax), %rsi
leaq 0x3602f(%rip), %rdi     # 0x740df
movb $0x0, %al
callq *%rcx
jmp 0x3e114
cmpq $0x0, -0x10(%rbp)
jne 0x3e0d9
movslq -0x24(%rbp), %rcx
movq 0x44700(%rip), %rax     # 0x827c8
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq %rax, -0x10(%rbp)
jmp 0x3e10b
movslq -0x24(%rbp), %rax
movq 0x446e4(%rip), %rcx     # 0x827c8
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x10(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3e039
cmpq $0x0, -0x18(%rbp)
je 0x3e130
cmpq $0x0, -0x10(%rbp)
jne 0x3e154
leaq 0x35fd1(%rip), %rdi     # 0x74108
leaq 0x35fea(%rip), %rsi     # 0x74128
movl $0x138, %edx            # imm = 0x138
movq 0x444b6(%rip), %rcx     # 0x82600
movb $0x0, %al
callq *0x38(%rcx)
callq 0x181b0
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x18f70
movl %eax, %edi
callq 0x18aa0
callq 0x19c80
movl -0x1c(%rbp), %ecx
subl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3e1a7
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3e188
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)