// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/lang.c
// Function: compile_file
int compile_file(char *filename)
{
 /*!Last Changed 26.01.2009 added matrix type*/
	/*!Last Changed 12.10.2004*/
 FILE *myfile;
 char myline[READLINELENGTH], *params[MAXPARAMS]={NULL}, *grammarparams[MAXPARAMS]={NULL}, *tempparams[MAXPARAMS], *temporder, *order = NULL;
 int i, paramcount = 0, linecount = 0, res, charcount, grammarcount = 0, result = SUCCESS;
	CONSTRUCT_TYPE counts[10] = {0};
 int variablecount = 0;
 variableptr variables = NULL;
 if ((myfile = fopen(filename, "r")) == NULL)
  {
   printf(m1274, filename);
   return FAILURE;
  }
	add_default_variables(&variables, &variablecount);
 while (fgets(myline, READLINELENGTH, myfile))
  {
		 linecount++;
		 if (order)
			 {
				 safe_free(order);
					order = NULL;
			 }
   for (i = 0; i < paramcount; i++)
    {
     safe_free(params[i]);
     params[i] = NULL;
    }
   for (i = 0; i < grammarcount; i++)
    {
     safe_free(grammarparams[i]);
     grammarparams[i] = NULL;
    }
   temporder = strtok(myline," \t\n");
   if (temporder)
    {
     paramcount = -1;
     do{
       paramcount++;
       tempparams[paramcount] = strtok(NULL, " \t\n");
     }while((tempparams[paramcount]) && (paramcount < MAXPARAMS - 1));
    }
   else
     continue;
   order = strcopy(order, temporder);
			if (!check_of_variables(order, variables, variablecount))
			 {
				 printf(e1014, linecount, order);
					result = FAILURE;
			 }
   for (i = 0; i < paramcount; i++)
     params[i] = strcopy(params[i], tempparams[i]);
   if (order[0] != '\'' && char_count(order, '%') == 0)
    {
     res = get_order_index(order);
     if (res == -1)
					 {
						 printf(e1001, linecount, order);
							result = FAILURE;
						 continue;
					 }
					charcount = char_count(grammar_of_order(res), '<');
					if (charcount > paramcount)
					 {
						 printf(e1002, linecount, order);
							result = FAILURE;
							continue;
					 }
					else
						 if (res != 70 && res != 71 && res != 72 && res != 152 && res != 309)
  						 if (charcount < paramcount)
	  					   printf(w1001, linecount, order);
					switch (res)
					 {
					  case 97 :counts[IF]++;
								        break;
							case 98 :counts[ELSE]++;
								        if (counts[ELSE] > counts[IF])
																 {
																	 printf(e1003, linecount);
																		result = FAILURE;
																	 continue;
																 }
								        break;
							case 99 :counts[ENDIF]++;
								        if (counts[ENDIF] > counts[IF])
																 {
																	 printf(e1004, linecount);
																		result = FAILURE;
																	 continue;
																 }
								        break;
							case 76 :counts[SWITCH]++;
								        if (counts[SWITCH] - counts[ENDSWITCH] > 1)
																 {
																	 printf(e1005, linecount);
																		result = FAILURE;
																		continue;
																 }
								        break;
							case 77 :counts[ENDSWITCH]++;
								        if (counts[ENDSWITCH] > counts[SWITCH])
																 {
																	 printf(e1006, linecount);
																		result = FAILURE;
																		continue;
																 }
								        break;
							case 78 :counts[CASE]++;
								        if (counts[SWITCH] == counts[ENDSWITCH])
																 {
																	 printf(e1007, linecount);
																		result = FAILURE;
																		continue;
																 }
								        break;
							case 74 :counts[FOR]++;
								        break;
							case 75 :counts[ENDFOR]++;
								        if (counts[ENDFOR] > counts[FOR])
																 {
																	 printf(e1008, linecount);
																		result = FAILURE;
																		continue;
																 }
								        break;
							case 100:counts[WHILE]++;
								        break;
							case 101:counts[ENDWHILE]++;
								        if (counts[ENDWHILE] > counts[WHILE])
																 {
																	 printf(e1009, linecount);
																		result = FAILURE;
																		continue;
																 }
								        break;
						 case  70:for (i = 0; i < paramcount; i++)
																	 if (!add_variable(INTEGER_TYPE, &(params[i]), 1, &variables, &variablecount))
																			 printf(w1002, linecount, params[i]);
								        break;
							case  71:for (i = 0; i < paramcount; i++)
																	 if (!add_variable(REAL_TYPE, &(params[i]), 1, &variables, &variablecount))
																			 printf(w1002, linecount, params[i]);
																break;
							case  72:for (i = 0; i < paramcount; i++)
																	 if (!add_variable(STRING_TYPE, &(params[i]), 1, &variables, &variablecount))
																			 printf(w1002, linecount, params[i]);
								        break;
							case 152:for (i = 0; i < paramcount; i++)
																	 if (!add_variable(FILE_TYPE, &(params[i]), 1, &variables, &variablecount))
																			 printf(w1002, linecount, params[i]);
                break;
       case 309:for (i = 0; i < paramcount; i++)
                  if (!add_variable(MATRIX_TYPE, &(params[i]), 1, &variables, &variablecount))
                    printf(w1002, linecount, params[i]);
								        break;
					 }
					strcpy(myline, grammar_of_order(res));
     temporder = strtok(myline," <>\t\n");
     if (temporder)
					 {
       grammarcount = -1;
       do{
         grammarcount++;
         tempparams[grammarcount] = strtok(NULL, " <>\t\n");
							}while((tempparams[grammarcount]) && (grammarcount < MAXPARAMS - 1));
					 }
     for (i = 0; i < grammarcount; i++)
       grammarparams[i] = strcopy(grammarparams[i], tempparams[i]);
     res = check_parameters(params, paramcount, grammarparams, grammarcount, variables, variablecount);
					if (res != -1)
					 {
						 printf(e1016, linecount, params[res]);
							result = FAILURE;
					 }
    }
  }
 if (counts[IF] > counts[ENDIF])
	 {
		 printf(e1010, linecount);
			result = FAILURE;
	 }
 if (counts[SWITCH] > counts[ENDSWITCH])
	 {
		 printf(e1011, linecount);
			result = FAILURE;
	 }
 if (counts[FOR] > counts[ENDFOR])
	 {
		 printf(e1012, linecount);
			result = FAILURE;
	 }
 if (counts[WHILE] > counts[ENDWHILE])
	 {
		 printf(e1013, linecount);
			result = FAILURE;
	 }
	if (order)
		 safe_free(order);
 for (i = 0; i < paramcount; i++)
  {
   safe_free(params[i]);
   params[i] = NULL;
  }
 for (i = 0; i < grammarcount; i++)
  {
   safe_free(grammarparams[i]);
   grammarparams[i] = NULL;
  }
	free_variables(variables, variablecount);
	safe_free(variables);
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7aaf8, %rsp          # imm = 0x7AAF8
movq %rdi, %rbx
leaq 0x70(%rsp), %rdi
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x4050
leaq 0x390(%rsp), %rdi
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x4050
andl $0x0, 0x18(%rsp)
andq $0x0, 0x48(%rsp)
leaq 0x6bcfb(%rip), %rsi     # 0x9b87f
movq %rbx, %rdi
callq 0x40f0
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x3030a
leaq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2f963
pushq $0x1
popq %rax
xorl %ebx, %ebx
movl $0x0, %r15d
movl $0x0, %ebp
xorl %r12d, %r12d
movl %eax, 0xc(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
leaq 0x9d0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x68(%rsp), %rdx
callq 0x4120
testq %rax, %rax
je 0x3021d
testq %rbx, %rbx
je 0x2fc35
movq %rbx, %rdi
callq 0x34ff7
incl %ebp
testl %r15d, %r15d
movl $0x0, %ebx
cmovgl %r15d, %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x2fc60
movq 0x70(%rsp,%r14,8), %rdi
callq 0x34ff7
andq $0x0, 0x70(%rsp,%r14,8)
incq %r14
jmp 0x2fc46
testl %r12d, %r12d
movl $0x0, %r14d
cmovgl %r12d, %r14d
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x2fc8f
movq 0x390(%rsp,%rbx,8), %rdi
callq 0x34ff7
andq $0x0, 0x390(%rsp,%rbx,8)
incq %rbx
jmp 0x2fc6f
leaq 0x9d0(%rsp), %rdi
leaq 0x6946b(%rip), %rsi     # 0x99109
callq 0x4280
movl $0x0, %ebx
testq %rax, %rax
je 0x2fc08
movq %rax, %r13
movq %r12, 0x10(%rsp)
xorl %ecx, %ecx
pushq $-0x1
popq %r15
movq %r15, %rbx
movq %rcx, %r12
incq %r15
xorl %edi, %edi
leaq 0x69438(%rip), %rsi     # 0x99109
callq 0x4280
movq %rax, 0x6b8(%rsp,%rbx,8)
cmpq $0x61, %rbx
jg 0x2fcee
leaq 0x1(%r12), %rcx
testq %rax, %rax
jne 0x2fcbf
xorl %edi, %edi
movq %r13, %rsi
callq 0x3604c
movq %rax, %rbx
movq 0x48(%rsp), %rsi
movl 0x18(%rsp), %edx
movq %rax, %rdi
callq 0x30331
testl %eax, %eax
jne 0x2fd2b
movl $0x0, 0xc(%rsp)
leaq 0x69418(%rip), %rdi     # 0x99137
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq %rbx, 0x20(%rsp)
movl %ebp, %r13d
leaq -0x1(%r15), %rax
movq %rax, 0x60(%rsp)
xorl %ebx, %ebx
movq %r12, %rbp
subq $0x1, %rbp
jb 0x2fd64
movq 0x70(%rsp,%rbx), %rdi
movq 0x6b0(%rsp,%rbx), %rsi
callq 0x3604c
movq %rax, 0x70(%rsp,%rbx)
addq $0x8, %rbx
jmp 0x2fd41
movq 0x20(%rsp), %rbx
cmpb $0x27, (%rbx)
jne 0x2fd7b
movq 0x10(%rsp), %r12
movl %r13d, %ebp
jmp 0x2fc08
movq %rbx, %rdi
pushq $0x25
popq %rsi
callq 0x35e64
testl %eax, %eax
movl %r13d, %ebp
jne 0x2fde0
movq %rbx, %rdi
callq 0xd7e8
cmpl $-0x1, %eax
je 0x2fdc5
movl %eax, %r13d
movl %eax, %edi
callq 0xd7d4
movq %rax, %rdi
pushq $0x3c
popq %rsi
callq 0x35e64
cmpl %r15d, %eax
jle 0x2fdea
movl $0x0, 0xc(%rsp)
leaq 0x693f1(%rip), %rdi     # 0x991b4
jmp 0x2fdd4
movl $0x0, 0xc(%rsp)
leaq 0x693ac(%rip), %rdi     # 0x99180
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq 0x10(%rsp), %r12
jmp 0x2fc08
cmpl $0x46, %r13d
movq %r13, 0x58(%rsp)
je 0x2fefc
cmpl $0x47, %r13d
leaq 0x48(%rsp), %rbx
je 0x2fe6b
cmpl $0x135, %r13d           # imm = 0x135
je 0x2ff70
cmpl $0x98, %r13d
je 0x2ffaf
cmpl $0x48, %r13d
jne 0x2fead
leaq 0x70(%rsp), %r13
subq $0x1, %r12
jb 0x2ffee
pushq $0x2
popq %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
leaq 0x18(%rsp), %r8
callq 0x2f9df
testl %eax, %eax
jne 0x2fe65
movq (%r13), %rdx
leaq 0x69593(%rip), %rdi     # 0x993ef
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
jmp 0x2fe2d
leaq 0x70(%rsp), %r13
subq $0x1, %r12
jb 0x2ffee
pushq $0x1
popq %rdi
movq %r13, %rsi
movl %edi, %edx
movq %rbx, %rcx
leaq 0x18(%rsp), %r8
callq 0x2f9df
testl %eax, %eax
jne 0x2fea7
movq (%r13), %rdx
leaq 0x69551(%rip), %rdi     # 0x993ef
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
jmp 0x2fe70
cmpl 0x60(%rsp), %eax
jg 0x2fec8
leaq 0x69356(%rip), %rdi     # 0x99210
movl %ebp, %esi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x4030
leal -0x4a(%r13), %eax
cmpl $0x4, %eax
movq %r13, %rcx
leaq 0x69559(%rip), %r13     # 0x99432
jbe 0x2ff43
leal -0x61(%rcx), %eax
cmpl $0x4, %eax
ja 0x2ff5c
leaq 0x68e1e(%rip), %rcx     # 0x98d08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl 0x30(%rsp)
jmp 0x301b3
leaq 0x70(%rsp), %r13
leaq 0x48(%rsp), %rbx
subq $0x1, %r12
jb 0x2ffee
xorl %edi, %edi
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
leaq 0x18(%rsp), %r8
callq 0x2f9df
testl %eax, %eax
jne 0x2ff3d
movq (%r13), %rdx
leaq 0x694bb(%rip), %rdi     # 0x993ef
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
jmp 0x2ff06
leaq 0x68daa(%rip), %rcx     # 0x98cf4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl 0x3c(%rsp)
jmp 0x301b3
cmpl $0x98, %ecx
je 0x2ffaf
movq %rcx, %r13
cmpl $0x135, %r13d           # imm = 0x135
jne 0x2ffee
leaq 0x70(%rsp), %r13
subq $0x1, %r12
jb 0x2ffee
pushq $0x5
popq %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
leaq 0x18(%rsp), %r8
callq 0x2f9df
testl %eax, %eax
jne 0x2ffa9
movq (%r13), %rdx
leaq 0x6944f(%rip), %rdi     # 0x993ef
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
jmp 0x2ff75
leaq 0x70(%rsp), %r13
subq $0x1, %r12
jb 0x2ffee
pushq $0x4
popq %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
leaq 0x18(%rsp), %r8
callq 0x2f9df
testl %eax, %eax
jne 0x2ffe8
movq (%r13), %rdx
leaq 0x69410(%rip), %rdi     # 0x993ef
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
jmp 0x2ffb4
movq 0x10(%rsp), %r12
leaq 0x69438(%rip), %r13     # 0x99432
movq 0x58(%rsp), %rdi
callq 0xd7d4
leaq 0x9d0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4280
testq %rax, %rax
je 0x30051
pushq $-0x1
popq %r14
movq %r14, %rbx
incq %r14
xorl %edi, %edi
movq %r13, %rsi
callq 0x4280
movq %rax, 0x6b8(%rsp,%rbx,8)
cmpq $0x61, %rbx
jg 0x3004e
testq %rax, %rax
jne 0x3002b
movl %r14d, %r12d
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x3007a
movq 0x390(%rsp,%rbx,8), %rdi
movq 0x6b0(%rsp,%rbx,8), %rsi
callq 0x3604c
movq %rax, 0x390(%rsp,%rbx,8)
incq %rbx
jmp 0x30053
movq 0x48(%rsp), %r8
movl 0x18(%rsp), %r9d
leaq 0x70(%rsp), %rdi
movl %r15d, %esi
leaq 0x390(%rsp), %rdx
movl %r12d, %ecx
callq 0x2f6a3
cmpl $-0x1, %eax
je 0x300c0
cltq
movq 0x70(%rsp,%rax,8), %rdx
movl $0x0, 0xc(%rsp)
leaq 0x69381(%rip), %rdi     # 0x99438
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
movq 0x20(%rsp), %rbx
jmp 0x2fc08
movl 0x2c(%rsp), %ebx
cmpl 0x1c(%rsp), %ebx
movq 0x10(%rsp), %r12
jne 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69252(%rip), %rdi     # 0x9933e
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
movl %ebx, 0x1c(%rsp)
jmp 0x300c0
movl 0x40(%rsp), %eax
incl %eax
movl %eax, 0x40(%rsp)
cmpl 0x44(%rsp), %eax
movq 0x10(%rsp), %r12
jbe 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69292(%rip), %rdi     # 0x993b5
jmp 0x3020f
movl 0x2c(%rsp), %eax
incl %eax
movl %eax, 0x2c(%rsp)
subl 0x1c(%rsp), %eax
cmpl $0x2, %eax
movq 0x10(%rsp), %r12
jb 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69177(%rip), %rdi     # 0x992ca
jmp 0x3020f
movl 0x34(%rsp), %eax
incl %eax
movl %eax, 0x34(%rsp)
cmpl 0x30(%rsp), %eax
movq 0x10(%rsp), %r12
jbe 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69116(%rip), %rdi     # 0x99296
jmp 0x3020f
movl 0x1c(%rsp), %eax
incl %eax
movl %eax, 0x1c(%rsp)
cmpl 0x2c(%rsp), %eax
movq 0x10(%rsp), %r12
jbe 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69155(%rip), %rdi     # 0x99302
jmp 0x3020f
incl 0x44(%rsp)
movq 0x10(%rsp), %r12
jmp 0x2fffa
movl 0x38(%rsp), %eax
incl %eax
movl %eax, 0x38(%rsp)
cmpl 0x3c(%rsp), %eax
movq 0x10(%rsp), %r12
jbe 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x6919a(%rip), %rdi     # 0x9937f
jmp 0x3020f
movl 0x54(%rsp), %eax
incl %eax
movl %eax, 0x54(%rsp)
cmpl 0x30(%rsp), %eax
movq 0x10(%rsp), %r12
jbe 0x2fffa
movl $0x0, 0xc(%rsp)
leaq 0x69060(%rip), %rdi     # 0x9926f
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x300c0
movq %rbx, %r14
movl %ebp, %ebx
movl 0x34(%rsp), %eax
cmpl %eax, 0x30(%rsp)
movl 0xc(%rsp), %ebp
jbe 0x30242
leaq 0x6923f(%rip), %rdi     # 0x99476
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x1c(%rsp), %eax
cmpl %eax, 0x2c(%rsp)
jbe 0x3025e
leaq 0x6924a(%rip), %rdi     # 0x9949d
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x38(%rsp), %eax
cmpl %eax, 0x3c(%rsp)
jbe 0x3027a
leaq 0x69259(%rip), %rdi     # 0x994c8
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x40(%rsp), %eax
cmpl %eax, 0x44(%rsp)
jbe 0x30296
leaq 0x69265(%rip), %rdi     # 0x994f0
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
testq %r14, %r14
je 0x302a3
movq %r14, %rdi
callq 0x34ff7
xorl %ebx, %ebx
testl %r15d, %r15d
cmovlel %ebx, %r15d
cmpq %rbx, %r15
je 0x302c6
movq 0x70(%rsp,%rbx,8), %rdi
callq 0x34ff7
andq $0x0, 0x70(%rsp,%rbx,8)
incq %rbx
jmp 0x302ac
xorl %ebx, %ebx
testl %r12d, %r12d
cmovlel %ebx, %r12d
cmpq %rbx, %r12
je 0x302ef
movq 0x390(%rsp,%rbx,8), %rdi
callq 0x34ff7
andq $0x0, 0x390(%rsp,%rbx,8)
incq %rbx
jmp 0x302cf
movq 0x48(%rsp), %rbx
movl 0x18(%rsp), %esi
movq %rbx, %rdi
callq 0x303e1
movq %rbx, %rdi
callq 0x34ff7
jmp 0x3031d
leaq 0x65ef9(%rip), %rdi     # 0x9620a
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
movl %ebp, %eax
addq $0x7aaf8, %rsp          # imm = 0x7AAF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq