// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/rules/no_prototype.c
// Function: check_no_prototype
unsigned int check_no_prototype(scope_t *root_scope, arraylist_t *file, arraylist_t *real_file) {

	arraylist_t *functions = root_scope->functions;
	function_t  *function  = NULL;
	function_t  *prototype = NULL;
	line_t      *line      = NULL;
	char        *display   = NULL;
	unsigned int breaks    = 0;
	unsigned int count     = 0; //Counts warnings and errors

	for(size_t i = 0 ; i < functions->size ; i++) {
		breaks = 0;
		function = arraylist_get(functions, i);
		if(!function->is_prototype && strcmp(function->name, "main")) {

			prototype = find_function_prototype(root_scope, function->name);
			if(prototype != NULL) {
				if(strcmp(function->return_type.name, prototype->return_type.name) || !check_params(function, prototype)) {
					line = get_line(file, prototype->line);
					breaks = strcount_heading_line_breaks(line->line) + (line->start_real_line == 0 ? 1 : 0);
					display = trim(arraylist_get(real_file, line->start_real_line + breaks - 1));
					print_error(line->source, line->start_real_line + breaks, display, "Conflicting types");
					free(display);
					count++;
				}
			} else {
				line = get_line(file, function->line);
				breaks = strcount_heading_line_breaks(line->line) + (line->start_real_line == 0 ? 1 : 0); //TODO count until not whitespace instead of all breaks
				display = trim(arraylist_get(real_file, line->start_real_line + breaks - 1));
				print_warning(line->source, line->start_real_line + breaks, display, "Missing prototype");
				free(display);
				count++;
			}
		}
	}

	return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0xd7e8
movl $0x0, -0x44(%rbp)
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x8890
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpb $0x0, 0x18(%rax)
jne 0xd7d5
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x73a8(%rip), %rsi      # 0x149f4
callq 0x20f0
cmpl $0x0, %eax
je 0xd7d5
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
callq 0x8470
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xd740
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x20f0
cmpl $0x0, %eax
jne 0xd6a8
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xd800
cmpb $0x0, %al
jne 0xd73b
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x28(%rax), %esi
callq 0x2cb0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0xa840
movq -0x38(%rbp), %rcx
movl 0x10(%rcx), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x44(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x8890
movq %rax, %rdi
callq 0xad00
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movl 0x10(%rax), %esi
addl -0x44(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq 0x72d5(%rip), %rcx      # 0x149f9
callq 0x6950
movq -0x40(%rbp), %rdi
callq 0x2030
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd7d3
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x28(%rax), %esi
callq 0x2cb0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0xa840
movq -0x38(%rbp), %rcx
movl 0x10(%rcx), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
addl -0x44(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x8890
movq %rax, %rdi
callq 0xad00
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movl 0x10(%rax), %esi
addl -0x44(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq 0x724f(%rip), %rcx      # 0x14a0b
callq 0x6850
movq -0x40(%rbp), %rdi
callq 0x2030
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd7d5
jmp 0xd7d7
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xd606
movl -0x48(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)