// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/rules/parsing.c
// Function: parse_and_check
unsigned int parse_and_check(scope_t *root_scope, arraylist_t *file, arraylist_t *functions, arraylist_t *variables, arraylist_t *conf, arraylist_t *real_file) {

	type_t type;
	unsigned int result        = 0;
	unsigned int breaks        = 0;
	scope_t *scope             = NULL;
	char *line                 = NULL;
	char *message              = NULL;
	char *display              = NULL;
	function_t     *function   = NULL;
	field_t        *field      = NULL;
	invalid_call_t *call       = NULL;
	wrong_type_t   *wrong_type = NULL;
	line_t         *line_info  = NULL;
	messages_t     *messages   = malloc(sizeof(messages_t));

	if(messages == NULL) exit(1);

	if(root_scope->parent == NULL) {
		messages->functions_list = arraylist_init(root_scope->functions->size);
		messages->variables_list = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
		fill_functions_list(root_scope, messages->functions_list);
		fill_variables_list(root_scope, messages->variables_list);
	} else {
		messages->functions_list = functions;
		messages->variables_list = variables;
	}

	for(int i = root_scope->from_line ; i <= root_scope->to_line ; i++) {
		scope = get_child_scope(root_scope, i);
		if(scope != root_scope) {
			if(i == scope->from_line) {
				result += parse_and_check(scope, file, messages->functions_list, messages->variables_list, conf, real_file);
			}
		} else {
			messages->undeclared_functions = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->undeclared_variables = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->invalid_params       = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->invalid_calls        = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->wrong_assignment     = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->wrong_return         = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->ternary_types        = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
			messages->operator_spacing     = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);

			line_info = get_line(file, i);
			line = line_info->line;
			breaks = strcount_heading_line_breaks(line) + (line_info->start_real_line == 0 ? 1 : 0);
			type = parse_expression(line, i, scope, messages);
			if(!strcmp(type.name, "NULL")) {
				type = parse_operation(line, i, scope, messages);
			}

			if(conf == NULL || check_rule(conf, "undeclared-function")) {
				for(size_t j = 0 ; j < messages->undeclared_functions->size ; j++) {
					function = arraylist_get(messages->undeclared_functions, j);
					message = strconcat("Undeclared function: ", function->name);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "undeclared-variable")) {
				for(size_t j = 0 ; j < messages->undeclared_variables->size ; j++) {
					message = strconcat("Undeclared variable: ", arraylist_get(messages->undeclared_variables, j));
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "arguments-count")) {
				for(size_t j = 0 ; j < messages->invalid_calls->size ; j++) {
					call = arraylist_get(messages->invalid_calls, j);
					message = strconcat(call->more > 0 ? "Too many arguments for function: " : "Too few arguments for function: ", call->name);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					free(call->name);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "function-parameters-type")) {
				for(size_t j = 0 ; j < messages->invalid_params->size ; j++) {
					field = arraylist_get(messages->invalid_params, j);
					message = strconcat("Invalid parameter type: ", field->name);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "variable-assignment-type")) {
				for(size_t j = 0 ; j < messages->wrong_assignment->size ; j++) {
					wrong_type = arraylist_get(messages->wrong_assignment, j);
					message = build_wrong_type_message(wrong_type, WRONG_TYPE_ASSIGNMENT);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "return-type")) {
				for(size_t j = 0 ; j < messages->wrong_return->size ; j++) {
					wrong_type = arraylist_get(messages->wrong_return, j);
					message = build_wrong_type_message(wrong_type, WRONG_TYPE_RETURN);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "ternary-types")) {
				for(size_t j = 0 ; j < messages->ternary_types->size ; j++) {
					wrong_type = arraylist_get(messages->ternary_types, j);
					message = build_wrong_type_message(wrong_type, WRONG_TYPE_TERNARY);
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_error(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			if(conf == NULL || check_rule(conf, "operators-spacing")) {
				for(size_t j = 0 ; j < messages->operator_spacing->size ; j++) {
					message = strconcat("Missing operator spacing: ", arraylist_get(messages->operator_spacing, j));
					display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
					print_warning(line_info->source, line_info->start_real_line + breaks, display, message);
					free(display);
					free(message);
					result++;
				}
			}

			function_list_free(messages->undeclared_functions);
			field_list_free(messages->invalid_params);
			arraylist_free(messages->undeclared_variables, 1);
			arraylist_free(messages->invalid_calls, 1);
			arraylist_free(messages->operator_spacing, 1);
			free_wrong_type_list(messages->wrong_assignment);
			free_wrong_type_list(messages->wrong_return);
			free_wrong_type_list(messages->ternary_types);
			free(type.name);

		}
		
	}

	if(root_scope->parent == NULL) {

		if(conf == NULL || check_rule(conf, "unused-variable")) {
			for(size_t j = 0 ; j < messages->variables_list->size ; j++) {
				field = arraylist_get(messages->variables_list, j);
				line_info = get_line(file, field->line);
				message = field->is_param ? strconcat("Unused parameter: ", field->name) : strconcat("Unused variable: ", field->name);
				breaks = strcount_heading_line_breaks(line_info->line) + (line_info->start_real_line == 0 ? 1 : 0);
				display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
				print_warning(line_info->source, line_info->start_real_line + breaks, display, message);
				free(display);
				free(message);
				result++;
			}
		}

		if(conf == NULL || check_rule(conf, "unused-function")) {
			for(size_t j = 0 ; j < messages->functions_list->size ; j++) {
				function = arraylist_get(messages->functions_list, j);
				line_info = get_line(file, function->line);
				message = strconcat("Unused function: ", function->name);
				breaks = strcount_heading_line_breaks(line_info->line) + (line_info->start_real_line == 0 ? 1 : 0);
				display = trim(arraylist_get(real_file, line_info->start_real_line + breaks - 1));
				print_warning(line_info->source, line_info->start_real_line + breaks, display, message);
				free(display);
				free(message);
				result++;
			}
		}

		arraylist_free(messages->functions_list, 0);
		arraylist_free(messages->variables_list, 0);

		free(messages);
	}

	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbx
movq %r8, 0x28(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movl $0x50, %edi
callq 0x2140
testq %rax, %rax
je 0xa87f
movq %rax, %rbp
cmpq $0x0, (%r13)
movq %rax, 0x18(%rsp)
movq %r12, 0x40(%rsp)
movq %r13, 0x38(%rsp)
je 0x9d76
movq %r15, 0x48(%rbp)
movq %r14, 0x40(%rbp)
movq %r13, %r14
jmp 0x9e08
movq 0x10(%r13), %rax
movl 0x8(%rax), %edi
callq 0x6ac8
movq %rax, 0x48(%rbp)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x40(%rbp)
movq 0x10(%r13), %rdi
cmpq $0x0, 0x8(%rdi)
movq %r13, %r14
je 0x9df2
movq 0x18(%rsp), %rax
movq 0x48(%rax), %r15
xorl %r12d, %r12d
leaq 0x4a84(%rip), %r13      # 0xe839
movq %r12, %rsi
callq 0x6c76
cmpb $0x0, 0x18(%rax)
jne 0x9de0
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2120
testl %eax, %eax
je 0x9de0
movq %r15, %rdi
movq %r14, %rsi
callq 0x6b96
incq %r12
movq 0x38(%rsp), %r14
movq 0x10(%r14), %rdi
cmpq 0x8(%rdi), %r12
jb 0x9db5
movq 0x18(%rsp), %rbp
movq 0x40(%rbp), %rsi
movq %r14, %rdi
callq 0xa889
movq 0x40(%rsp), %r12
movl 0x20(%r14), %r15d
movq $0x0, 0x10(%rsp)
cmpl 0x28(%r14), %r15d
jg 0xa678
movq $0x0, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
movq %r14, %rdi
movl %r15d, %esi
callq 0x6130
movq %rax, %rbp
testq %rax, %rax
cmoveq %r14, %rbp
cmpq %r14, %rbp
je 0x9e8e
cmpl 0x20(%rbp), %r15d
movq %r15, %rsi
jne 0xa04e
movq 0x18(%rsp), %r15
movq 0x40(%r15), %rcx
movq 0x48(%r15), %rdx
movq %rbp, %rdi
movq %r15, %rbp
movq %rsi, %r15
movq %r12, %rsi
movq 0x28(%rsp), %r8
movq %rbx, %r9
callq 0x9d18
movq %r15, %rsi
movq 0x10(%rsp), %rcx
addl %eax, %ecx
movq %rcx, 0x10(%rsp)
jmp 0xa668
movl $0xa, %edi
callq 0x6ac8
movq 0x18(%rsp), %r13
movq %rax, 0x8(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, (%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x10(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x18(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x20(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x28(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x30(%r13)
movl $0xa, %edi
callq 0x6ac8
movq %rax, 0x38(%r13)
movq %r12, %rdi
movl %r15d, %esi
callq 0x2a74
movq %rax, %r12
movq (%rax), %r14
movq %r14, %rdi
callq 0x7ef3
cmpl $0x1, 0x10(%r12)
adcl $0x0, %eax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %r15, 0x48(%rsp)
movl %r15d, %esi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xb680
movq %rax, %r15
movq %rax, %rdi
leaq 0x4973(%rip), %rsi      # 0xe8c0
callq 0x2120
testl %eax, %eax
jne 0x9f6e
movq %r14, %rdi
movq 0x48(%rsp), %rsi
movq %rbp, %rdx
movq 0x18(%rsp), %rcx
callq 0x7020
movq %rax, %r15
movq %r15, 0x50(%rsp)
movq 0x28(%rsp), %r14
testq %r14, %r14
movq 0x10(%rsp), %r15
movq 0x30(%rsp), %r13
je 0x9f9e
movq %r14, %rdi
leaq 0x4ac8(%rip), %rsi      # 0xea59
callq 0x6076
testb %al, %al
je 0xa05f
movq 0x18(%rsp), %rbp
movq 0x8(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa058
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %rbp, %r13
xorl %ebp, %ebp
leaq 0x4aa7(%rip), %rbx      # 0xea6d
movq %rbp, %rsi
callq 0x6c76
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x7fbd
movq %rax, %r15
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %r14
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl 0x30(%rsp), %esi
movq %rax, %rdx
movq %r15, %rcx
callq 0x5829
movq %r14, %rdi
callq 0x2030
movq %r15, %rdi
callq 0x2030
incq %rbp
movq 0x8(%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0x9fc6
movq 0x10(%rsp), %rax
addl %ebp, %eax
movq 0x20(%rsp), %rbx
movq %rax, %r15
movq 0x28(%rsp), %r14
movq %r13, %rbp
movq 0x30(%rsp), %r13
jmp 0xa064
movq 0x18(%rsp), %rbp
jmp 0xa668
movq 0x28(%rsp), %r14
jmp 0xa064
movq 0x18(%rsp), %rbp
testq %r14, %r14
movq %r15, 0x10(%rsp)
je 0xa085
movq %r14, %rdi
leaq 0x4a0b(%rip), %rsi      # 0xea83
callq 0x6076
testb %al, %al
je 0xa132
movq (%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa132
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %rbp, %r13
xorl %ebp, %ebp
leaq 0x49ef(%rip), %rbx      # 0xea97
movq %rbp, %rsi
callq 0x6c76
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7fbd
movq %rax, %r15
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %r14
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl 0x30(%rsp), %esi
movq %rax, %rdx
movq %r15, %rcx
callq 0x5829
movq %r14, %rdi
callq 0x2030
movq %r15, %rdi
callq 0x2030
incq %rbp
movq (%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa0a8
movq 0x10(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r15
movq %r13, %rbp
movq 0x30(%rsp), %r13
jmp 0xa135
movq %r14, %r15
testq %r15, %r15
je 0xa151
movq %r15, %rdi
leaq 0x4969(%rip), %rsi      # 0xeaad
callq 0x6076
testb %al, %al
je 0xa21a
movq 0x18(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa21a
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
leaq 0x496e(%rip), %r13      # 0xeadf
movq %rbp, %rsi
callq 0x6c76
movq %rax, %r15
cmpl $0x0, 0x8(%rax)
movq %r13, %rdi
leaq 0x4933(%rip), %rax      # 0xeabd
cmovgq %rax, %rdi
movq (%r15), %rsi
callq 0x7fbd
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl 0x30(%rsp), %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5829
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
movq (%r15), %rdi
callq 0x2030
incq %rbp
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa171
movq 0x10(%rsp), %r14
addl %ebp, %r14d
movq 0x18(%rsp), %rbp
movq 0x28(%rsp), %r15
movq 0x30(%rsp), %r13
jmp 0xa21f
movq 0x10(%rsp), %r14
testq %r15, %r15
je 0xa23b
movq %r15, %rdi
leaq 0x48d2(%rip), %rsi      # 0xeb00
callq 0x6076
testb %al, %al
je 0xa2e5
movq 0x10(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa2e5
movq %r14, 0x10(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %rbp, %r13
xorl %ebp, %ebp
leaq 0x48b6(%rip), %r15      # 0xeb19
movq %rbp, %rsi
callq 0x6c76
movq (%rax), %rsi
movq %r15, %rdi
callq 0x7fbd
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl 0x30(%rsp), %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5829
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
incq %rbp
movq 0x10(%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa263
movq 0x10(%rsp), %r14
addl %ebp, %r14d
movq 0x28(%rsp), %r15
movq %r13, %rbp
movq 0x30(%rsp), %r13
testq %r15, %r15
je 0xa301
movq %r15, %rdi
leaq 0x483e(%rip), %rsi      # 0xeb32
callq 0x6076
testb %al, %al
je 0xa3a6
movq 0x20(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa3a6
movq %r14, 0x10(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %r13, %r15
movq %rbp, %r13
xorl %ebp, %ebp
movq %rbp, %rsi
callq 0x6c76
movq %rax, %rdi
xorl %esi, %esi
callq 0xa8f1
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl %r15d, %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5829
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
incq %rbp
movq 0x20(%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa325
movq 0x10(%rsp), %r14
addl %ebp, %r14d
movq 0x28(%rsp), %rax
movq %r13, %rbp
movq %r15, %r13
movq %rax, %r15
testq %r15, %r15
je 0xa3c2
movq %r15, %rdi
leaq 0x4796(%rip), %rsi      # 0xeb4b
callq 0x6076
testb %al, %al
je 0xa46a
movq 0x28(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa46a
movq %r14, 0x10(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %r13, %r15
movq %rbp, %r13
xorl %ebp, %ebp
movq %rbp, %rsi
callq 0x6c76
movq %rax, %rdi
movl $0x1, %esi
callq 0xa8f1
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl %r15d, %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5829
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
incq %rbp
movq 0x28(%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa3e6
movq 0x10(%rsp), %r14
addl %ebp, %r14d
movq 0x28(%rsp), %rax
movq %r13, %rbp
movq %r15, %r13
movq %rax, %r15
testq %r15, %r15
je 0xa486
movq %r15, %rdi
leaq 0x46de(%rip), %rsi      # 0xeb57
callq 0x6076
testb %al, %al
je 0xa52e
movq 0x30(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa52e
movq %r14, 0x10(%rsp)
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
movq %r13, %r15
movq %rbp, %r13
xorl %ebp, %ebp
movq %rbp, %rsi
callq 0x6c76
movq %rax, %rdi
movl $0x2, %esi
callq 0xa8f1
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl %r15d, %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x5829
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
incq %rbp
movq 0x30(%r13), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa4aa
movq 0x10(%rsp), %r14
addl %ebp, %r14d
movq 0x28(%rsp), %rax
movq %r13, %rbp
movq %r15, %r13
movq %rax, %r15
testq %r15, %r15
movq %r14, 0x10(%rsp)
je 0xa54f
movq %r15, %rdi
leaq 0x4623(%rip), %rsi      # 0xeb65
callq 0x6076
testb %al, %al
je 0xa5f8
movq 0x38(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa5f8
leal -0x1(%r13), %eax
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
leaq 0x4608(%rip), %r15      # 0xeb77
movq %rbp, %rsi
callq 0x6c76
movq %r15, %rdi
movq %rax, %rsi
callq 0x7fbd
movq %rax, %r14
movl 0x10(%r12), %esi
addl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
addl %r13d, %esi
movq %rax, %rdx
movq %r14, %rcx
callq 0x57a8
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0x2030
movq %r14, %rdi
callq 0x2030
incq %rbp
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rdi
cmpq 0x8(%rdi), %rbp
jb 0xa56f
movq 0x10(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %r14
movq 0x18(%rsp), %rbp
jmp 0xa5fd
movq 0x38(%rsp), %r14
movq 0x8(%rbp), %rdi
callq 0x68d7
movq 0x10(%rbp), %rdi
callq 0x6899
movq (%rbp), %rdi
movl $0x1, %esi
callq 0x6d0a
movq 0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x6d0a
movq 0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x6d0a
movq 0x20(%rbp), %rdi
callq 0xa9cf
movq 0x28(%rbp), %rdi
callq 0xa9cf
movq 0x30(%rbp), %rdi
callq 0xa9cf
movq 0x50(%rsp), %rdi
callq 0x2030
movq 0x40(%rsp), %r12
movq 0x48(%rsp), %rsi
leal 0x1(%rsi), %eax
cmpl 0x28(%r14), %esi
movl %eax, %r15d
jl 0x9e2d
cmpq $0x0, (%r14)
je 0xa688
movq 0x10(%rsp), %r14
jmp 0xa86d
movq 0x28(%rsp), %r15
testq %r15, %r15
movq 0x10(%rsp), %r14
movq %rbx, 0x20(%rsp)
je 0xa6b3
leaq 0x44ef(%rip), %rsi      # 0xeb92
movq %r15, %rdi
callq 0x6076
testb %al, %al
je 0xa77a
movq 0x40(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa77a
xorl %r15d, %r15d
movq %r15, %rsi
callq 0x6c76
movq %rax, %rbx
movl 0x20(%rax), %esi
movq %r12, %rdi
callq 0x2a74
movq %rax, %r13
cmpb $0x0, 0x24(%rbx)
movq (%rbx), %rsi
leaq 0x44b6(%rip), %rdi      # 0xeba2
leaq 0x44c2(%rip), %rax      # 0xebb5
cmoveq %rax, %rdi
callq 0x7fbd
movq %rax, %r12
movq (%r13), %rdi
callq 0x7ef3
movl %eax, %ebx
movl 0x10(%r13), %ebp
movl %ebp, %esi
subl $0x1, %esi
adcl %eax, %esi
movq 0x20(%rsp), %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %r14
cmpl $0x1, %ebp
movq 0x8(%r13), %rdi
adcl 0x10(%r13), %ebx
movq 0x18(%rsp), %rbp
movl %ebx, %esi
movq %rax, %rdx
movq %r12, %rcx
callq 0x57a8
movq %r14, %rdi
callq 0x2030
movq %r12, %rdi
movq 0x40(%rsp), %r12
callq 0x2030
incq %r15
movq 0x40(%rbp), %rdi
cmpq 0x8(%rdi), %r15
jb 0xa6c5
movq 0x10(%rsp), %r14
addl %r15d, %r14d
movq 0x28(%rsp), %r15
testq %r15, %r15
je 0xa796
leaq 0x4441(%rip), %rsi      # 0xebc7
movq %r15, %rdi
callq 0x6076
testb %al, %al
je 0xa84f
movq 0x48(%rbp), %rdi
cmpq $0x0, 0x8(%rdi)
je 0xa84f
movq %r14, 0x10(%rsp)
xorl %r15d, %r15d
movq %r15, %rsi
callq 0x6c76
movq %rax, %rbx
movl 0x28(%rax), %esi
movq %r12, %rdi
callq 0x2a74
movq %rax, %rbp
movq (%rbx), %rsi
leaq 0x4407(%rip), %rdi      # 0xebd7
callq 0x7fbd
movq %rax, %r13
movq (%rbp), %rdi
callq 0x7ef3
movl %eax, %ebx
movl 0x10(%rbp), %r12d
movl %r12d, %esi
subl $0x1, %esi
adcl %eax, %esi
movq 0x20(%rsp), %rdi
callq 0x6c76
movq %rax, %rdi
callq 0x81dc
movq %rax, %r14
cmpl $0x1, %r12d
movq 0x40(%rsp), %r12
movq 0x8(%rbp), %rdi
adcl 0x10(%rbp), %ebx
movl %ebx, %esi
movq %rax, %rdx
movq %r13, %rcx
callq 0x57a8
movq %r14, %rdi
callq 0x2030
movq %r13, %rdi
movq 0x18(%rsp), %rbp
callq 0x2030
incq %r15
movq 0x48(%rbp), %rdi
cmpq 0x8(%rdi), %r15
jb 0xa7ad
movq 0x10(%rsp), %r14
addl %r15d, %r14d
movq 0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x6d0a
movq 0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x6d0a
movq %rbp, %rdi
callq 0x2030
movl %r14d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x21a0