// File: /workspace/github_c_makefile_star2_O3/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 $0x7aae8, %rsp          # imm = 0x7AAE8
movq %rdi, %rbx
leaq 0x60(%rsp), %rdi
xorl %ebp, %ebp
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x4050
leaq 0x380(%rsp), %rdi
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x4050
movl $0x0, 0x1c(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x77a37(%rip), %rsi     # 0xab95b
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x3474c
movq %rax, %r14
leaq 0x28(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x33cca
leaq 0x9c0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r14, %rdx
callq 0x4120
testq %rax, %rax
je 0x3475f
movq %r14, %rbp
movl $0x1, 0xc(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x24(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x0, 0x30(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r14, 0x38(%rsp)
testq %rbx, %rbx
je 0x33fd5
movq %rbx, %rdi
callq 0x3a180
testl %r12d, %r12d
jle 0x33ffb
movl %r12d, %ebx
xorl %r14d, %r14d
movq 0x60(%rsp,%r14,8), %rdi
callq 0x3a180
movq $0x0, 0x60(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x33fe0
testl %r13d, %r13d
jle 0x34027
movl %r13d, %ebx
xorl %r14d, %r14d
movq 0x380(%rsp,%r14,8), %rdi
callq 0x3a180
movq $0x0, 0x380(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x34006
incl %r15d
leaq 0x9c0(%rsp), %rdi
leaq 0x75160(%rip), %rsi     # 0xa9199
callq 0x4280
testq %rax, %rax
je 0x34116
movq %rax, %rbx
movl %r15d, 0x34(%rsp)
movq %r13, 0x10(%rsp)
movq $-0x1, %r12
xorl %ecx, %ecx
leaq 0x75135(%rip), %r15     # 0xa9199
movq %r12, %r13
movq %rcx, %r14
incq %r12
xorl %edi, %edi
movq %r15, %rsi
callq 0x4280
movq %rax, 0x6a8(%rsp,%r13,8)
cmpq $0x61, %r13
jg 0x3408e
leaq 0x1(%r14), %rcx
testq %rax, %rax
jne 0x34064
movq %rbp, %r15
xorl %edi, %edi
movq %rbx, %rsi
callq 0x3b494
movq %rax, %rbx
movq 0x28(%rsp), %rsi
movl 0x1c(%rsp), %edx
movq %rax, %rdi
callq 0x34791
testl %eax, %eax
jne 0x340d0
movl $0x0, 0xc(%rsp)
leaq 0x75105(%rip), %rdi     # 0xa91c7
movl 0x34(%rsp), %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq %rbx, 0x58(%rsp)
movq %r12, %r13
decq %r13
js 0x34102
movq %r14, %rbp
xorl %ebx, %ebx
movq 0x60(%rsp,%rbx), %rdi
movq 0x6a0(%rsp,%rbx), %rsi
callq 0x3b494
movq %rax, 0x60(%rsp,%rbx)
addq $0x8, %rbx
decq %rbp
jne 0x340e2
movq 0x58(%rsp), %rbx
cmpb $0x27, (%rbx)
jne 0x3411a
movq 0x10(%rsp), %r13
movq %r15, %rbp
jmp 0x34133
xorl %ebx, %ebx
jmp 0x34138
movq %rbx, %rdi
movl $0x25, %esi
callq 0x3b290
testl %eax, %eax
movq %r15, %rbp
je 0x3415b
movq 0x10(%rsp), %r13
movl 0x34(%rsp), %r15d
leaq 0x9c0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rbp, %rdx
callq 0x4120
testq %rax, %rax
jne 0x33fc8
jmp 0x34673
movq %rbx, %rdi
callq 0xe16c
cmpl $-0x1, %eax
movl 0x34(%rsp), %r15d
je 0x341b1
movq %rax, %rbp
movl %ebp, %edi
callq 0xe158
movq %rax, %rdi
movl $0x3c, %esi
callq 0x3b290
cmpl %r12d, %eax
jle 0x341d7
movl $0x0, 0xc(%rsp)
leaq 0x750ac(%rip), %rdi     # 0xa9244
movl %r15d, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq 0x10(%rsp), %r13
movq 0x38(%rsp), %rbp
jmp 0x34138
movl $0x0, 0xc(%rsp)
leaq 0x75050(%rip), %rdi     # 0xa9210
movl %r15d, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq 0x10(%rsp), %r13
jmp 0x34138
cmpl $0x47, %ebp
movq %rbp, %rdi
jle 0x34259
cmpl $0x135, %edi            # imm = 0x135
je 0x343a0
cmpl $0x98, %edi
movq 0x38(%rsp), %rbp
je 0x343f6
cmpl $0x48, %edi
jne 0x34316
testq %r13, %r13
js 0x34538
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x2, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x33d4b
testl %eax, %eax
jne 0x3424b
movq (%r13), %rdx
leaq 0x7523e(%rip), %rdi     # 0xa947f
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r14
jne 0x34216
jmp 0x34445
cmpl $0x46, %edi
je 0x342c0
cmpl $0x47, %edi
movq 0x38(%rsp), %rbp
jne 0x34316
testq %r13, %r13
js 0x34538
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x1, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x33d4b
testl %eax, %eax
jne 0x342b2
movq (%r13), %rdx
leaq 0x751d7(%rip), %rdi     # 0xa947f
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r14
jne 0x3427d
jmp 0x34445
testq %r13, %r13
movq 0x38(%rsp), %rbp
js 0x34538
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
xorl %edi, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x33d4b
testl %eax, %eax
jne 0x34308
movq (%r13), %rdx
leaq 0x75181(%rip), %rdi     # 0xa947f
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r14
jne 0x342d6
jmp 0x34445
cmpl %r13d, %eax
jg 0x3433a
movq %rdi, %rbp
leaq 0x74f7b(%rip), %rdi     # 0xa92a0
movl %r15d, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq %rbp, %rdi
movq 0x38(%rsp), %rbp
cmpl $0x60, %edi
jle 0x34360
leal -0x61(%rdi), %eax
cmpl $0x4, %eax
ja 0x3438c
leaq 0x74a4a(%rip), %rcx     # 0xa8d98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
incl 0x30(%rsp)
jmp 0x34538
movl %edi, %eax
addl $-0x4a, %eax
cmpl $0x4, %eax
ja 0x34538
leaq 0x74a0f(%rip), %rcx     # 0xa8d84
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq 0x10(%rsp), %r13
jmpq *%rax
incl 0x44(%rsp)
jmp 0x3453d
cmpl $0x98, %edi
je 0x343f6
cmpl $0x135, %edi            # imm = 0x135
jne 0x34452
testq %r13, %r13
js 0x34452
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movq 0x38(%rsp), %rbp
movl $0x5, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x33d4b
testl %eax, %eax
jne 0x343eb
movq (%r13), %rdx
leaq 0x7509e(%rip), %rdi     # 0xa947f
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r14
jne 0x343b6
jmp 0x34445
testq %r13, %r13
js 0x34538
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x4, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x33d4b
testl %eax, %eax
jne 0x3443c
movq (%r13), %rdx
leaq 0x7504d(%rip), %rdi     # 0xa947f
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r14
jne 0x34407
movq 0x10(%rsp), %r13
movq %rbx, %rdi
jmp 0x3453d
movq 0x10(%rsp), %r13
movq 0x38(%rsp), %rbp
jmp 0x3453d
movl 0x24(%rsp), %eax
cmpl %eax, 0x20(%rsp)
jne 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74f50(%rip), %rdi     # 0xa93ce
movl %r15d, %esi
movl %eax, %ebx
xorl %eax, %eax
callq 0x4030
movl %ebx, 0x20(%rsp)
jmp 0x3460d
movl 0x50(%rsp), %eax
incl %eax
movl %eax, 0x50(%rsp)
cmpl 0x4c(%rsp), %eax
movq 0x10(%rsp), %r13
jbe 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74f8a(%rip), %rdi     # 0xa9445
jmp 0x34664
movl 0x20(%rsp), %eax
incl %eax
movl %eax, 0x20(%rsp)
subl 0x24(%rsp), %eax
cmpl $0x2, %eax
jb 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74e78(%rip), %rdi     # 0xa935a
jmp 0x34664
movl 0x40(%rsp), %eax
incl %eax
movl %eax, 0x40(%rsp)
cmpl 0x30(%rsp), %eax
movq 0x10(%rsp), %r13
jbe 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74e1b(%rip), %rdi     # 0xa9326
jmp 0x34664
movl 0x24(%rsp), %eax
incl %eax
cmpl 0x20(%rsp), %eax
movl %eax, 0x24(%rsp)
jbe 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74e63(%rip), %rdi     # 0xa9392
jmp 0x34664
incl 0x4c(%rsp)
movq 0x10(%rsp), %r13
callq 0xe158
leaq 0x9c0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
leaq 0x74f63(%rip), %rsi     # 0xa94c2
callq 0x4280
testq %rax, %rax
je 0x34597
movq $-0x1, %r13
movq %r13, %rbx
incq %r13
xorl %edi, %edi
leaq 0x74f43(%rip), %rsi     # 0xa94c2
callq 0x4280
movq %rax, 0x6a8(%rsp,%rbx,8)
cmpq $0x61, %rbx
jg 0x34597
testq %rax, %rax
jne 0x34570
testl %r13d, %r13d
jle 0x345c6
movl %r13d, %r14d
xorl %ebx, %ebx
movq 0x380(%rsp,%rbx,8), %rdi
movq 0x6a0(%rsp,%rbx,8), %rsi
callq 0x3b494
movq %rax, 0x380(%rsp,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x345a1
movq 0x28(%rsp), %r8
movl 0x1c(%rsp), %r9d
leaq 0x60(%rsp), %rdi
movl %r12d, %esi
leaq 0x380(%rsp), %rdx
movl %r13d, %ecx
callq 0x33a00
cmpl $-0x1, %eax
je 0x3460d
cltq
movq 0x60(%rsp,%rax,8), %rdx
movl $0x0, 0xc(%rsp)
leaq 0x74ec5(%rip), %rdi     # 0xa94c8
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
movq 0x58(%rsp), %rbx
jmp 0x34138
movl 0x48(%rsp), %eax
incl %eax
movl %eax, 0x48(%rsp)
cmpl 0x44(%rsp), %eax
jbe 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74dd5(%rip), %rdi     # 0xa940f
jmp 0x34664
movl 0x54(%rsp), %eax
incl %eax
movl %eax, 0x54(%rsp)
cmpl 0x30(%rsp), %eax
movq 0x10(%rsp), %r13
jbe 0x3453d
movl $0x0, 0xc(%rsp)
leaq 0x74c9b(%rip), %rdi     # 0xa92ff
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x34138
movl 0x30(%rsp), %eax
cmpl 0x40(%rsp), %eax
movl 0xc(%rsp), %ebp
jbe 0x34694
leaq 0x74e7e(%rip), %rdi     # 0xa9506
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
movl 0x20(%rsp), %eax
cmpl 0x24(%rsp), %eax
jbe 0x346b1
leaq 0x74e88(%rip), %rdi     # 0xa952d
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
movl 0x44(%rsp), %eax
cmpl 0x48(%rsp), %eax
jbe 0x346ce
leaq 0x74e96(%rip), %rdi     # 0xa9558
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
movl 0x4c(%rsp), %eax
cmpl 0x50(%rsp), %eax
jbe 0x346eb
leaq 0x74ea1(%rip), %rdi     # 0xa9580
xorl %ebp, %ebp
movl %r15d, %esi
xorl %eax, %eax
callq 0x4030
testq %rbx, %rbx
je 0x346f8
movq %rbx, %rdi
callq 0x3a180
testl %r12d, %r12d
jle 0x3471e
movl %r12d, %ebx
xorl %r14d, %r14d
movq 0x60(%rsp,%r14,8), %rdi
callq 0x3a180
movq $0x0, 0x60(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x34703
testl %r13d, %r13d
jle 0x34764
movl %r13d, %ebx
xorl %r14d, %r14d
movq 0x380(%rsp,%r14,8), %rdi
callq 0x3a180
movq $0x0, 0x380(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x34729
jmp 0x34764
leaq 0x71ab7(%rip), %rdi     # 0xa620a
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x3477d
movl $0x1, %ebp
movq 0x28(%rsp), %rbx
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0x34846
movq %rbx, %rdi
callq 0x3a180
movl %ebp, %eax
addq $0x7aae8, %rsp          # imm = 0x7AAE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq