// File: /workspace/github_c_makefile_star2_O1/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 %r14d, %r14d
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, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x7532b(%rip), %rsi     # 0xa888f
movq %rbx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x33c34
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x33309
leaq 0x9c0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r12, %rdx
callq 0x4120
testq %rax, %rax
je 0x33c4c
movl $0x1, 0x14(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x0, 0x24(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r12, 0x48(%rsp)
testq %rbx, %rbx
je 0x33611
movq %rbx, %rdi
callq 0x39194
testl %r14d, %r14d
jle 0x33637
movl %r14d, %ebx
xorl %r15d, %r15d
movq 0x60(%rsp,%r15,8), %rdi
callq 0x39194
movq $0x0, 0x60(%rsp,%r15,8)
incq %r15
cmpq %r15, %rbx
jne 0x3361c
testl %r13d, %r13d
jle 0x33663
movl %r13d, %ebx
xorl %r15d, %r15d
movq 0x380(%rsp,%r15,8), %rdi
callq 0x39194
movq $0x0, 0x380(%rsp,%r15,8)
incq %r15
cmpq %r15, %rbx
jne 0x33642
incl %ebp
leaq 0x9c0(%rsp), %rdi
leaq 0x72af5(%rip), %rsi     # 0xa6169
callq 0x4280
testq %rax, %rax
je 0x33747
movq %rax, %rbx
movq %r13, 0x8(%rsp)
movq $-0x1, %r14
xorl %ecx, %ecx
movq %r14, %r13
movq %rcx, %r15
incq %r14
xorl %edi, %edi
leaq 0x72ac4(%rip), %rsi     # 0xa6169
callq 0x4280
movq %rax, 0x6a8(%rsp,%r13,8)
cmpq $0x61, %r13
jg 0x336c1
leaq 0x1(%r15), %rcx
testq %rax, %rax
jne 0x33693
xorl %edi, %edi
movq %rbx, %rsi
callq 0x3a404
movq %rax, %rbx
movq 0x28(%rsp), %rsi
movl 0x18(%rsp), %edx
movq %rax, %rdi
callq 0x33da0
testl %eax, %eax
jne 0x336fe
movl $0x0, 0x14(%rsp)
leaq 0x72aa7(%rip), %rdi     # 0xa6199
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq %rbx, 0x58(%rsp)
movl %ebp, %r12d
movq %r14, %r13
decq %r13
js 0x33733
movq %r15, %rbp
xorl %ebx, %ebx
movq 0x60(%rsp,%rbx), %rdi
movq 0x6a0(%rsp,%rbx), %rsi
callq 0x3a404
movq %rax, 0x60(%rsp,%rbx)
addq $0x8, %rbx
decq %rbp
jne 0x33713
movq 0x58(%rsp), %rbx
cmpb $0x27, (%rbx)
jne 0x3374b
movq 0x8(%rsp), %r13
movl %r12d, %ebp
jmp 0x33764
xorl %ebx, %ebx
jmp 0x33769
movq %rbx, %rdi
movl $0x25, %esi
callq 0x3a200
testl %eax, %eax
movl %r12d, %ebp
je 0x3378c
movq 0x8(%rsp), %r13
movq 0x48(%rsp), %r12
leaq 0x9c0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r12, %rdx
callq 0x4120
testq %rax, %rax
jne 0x33604
jmp 0x33c9b
movq %rbx, %rdi
callq 0xe0e0
cmpl $-0x1, %eax
movq 0x48(%rsp), %r12
je 0x337d8
movq %rax, %r12
movl %r12d, %edi
callq 0xe0cc
movq %rax, %rdi
movl $0x3c, %esi
callq 0x3a200
cmpl %r14d, %eax
jle 0x337fd
movl $0x0, 0x14(%rsp)
leaq 0x72a4c(%rip), %rdi     # 0xa6216
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
jmp 0x3375f
movl $0x0, 0x14(%rsp)
leaq 0x729fb(%rip), %rdi     # 0xa61e2
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq 0x8(%rsp), %r13
jmp 0x33769
cmpl $0x47, %r12d
movq %r12, %rdi
jle 0x3387f
cmpl $0x48, %edi
movq 0x48(%rsp), %r12
je 0x33974
cmpl $0x98, %edi
je 0x339dd
cmpl $0x135, %edi            # imm = 0x135
jne 0x338e5
testq %r13, %r13
js 0x33b56
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x5, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x3338a
testl %eax, %eax
jne 0x33871
movq (%r13), %rdx
leaq 0x72be9(%rip), %rdi     # 0xa6451
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r15
jne 0x3383d
jmp 0x33a2b
cmpl $0x46, %edi
movq 0x48(%rsp), %r12
je 0x33924
cmpl $0x47, %edi
jne 0x338e5
testq %r13, %r13
js 0x33b56
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x1, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x3338a
testl %eax, %eax
jne 0x338d7
movq (%r13), %rdx
leaq 0x72b83(%rip), %rdi     # 0xa6451
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r15
jne 0x338a3
jmp 0x33a2b
cmpl %r13d, %eax
jg 0x33908
movq %rdi, %r12
leaq 0x7297e(%rip), %rdi     # 0xa6272
movl %ebp, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x4030
movq %r12, %rdi
movq 0x48(%rsp), %r12
leal -0x46(%rdi), %eax
cmpl $0x1f, %eax
ja 0x339c4
leaq 0x723e1(%rip), %rcx     # 0xa5cfc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testq %r13, %r13
js 0x33b56
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
xorl %edi, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x3338a
testl %eax, %eax
jne 0x33966
movq (%r13), %rdx
leaq 0x72af4(%rip), %rdi     # 0xa6451
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r15
jne 0x33935
jmp 0x33a2b
testq %r13, %r13
js 0x33b56
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x2, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x3338a
testl %eax, %eax
jne 0x339b9
movq (%r13), %rdx
leaq 0x72aa1(%rip), %rdi     # 0xa6451
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r15
jne 0x33985
jmp 0x33a2b
cmpl $0x98, %edi
je 0x339dd
cmpl $0x135, %edi            # imm = 0x135
je 0x3382c
jmp 0x33b56
testq %r13, %r13
js 0x33b56
movq %rdi, %rbx
leaq 0x60(%rsp), %r13
movl $0x4, %edi
movq %r13, %rsi
movl $0x1, %edx
leaq 0x28(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x3338a
testl %eax, %eax
jne 0x33a22
movq (%r13), %rdx
leaq 0x72a38(%rip), %rdi     # 0xa6451
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
addq $0x8, %r13
decq %r15
jne 0x339ee
movq 0x8(%rsp), %r13
movq %rbx, %rdi
jmp 0x33b5b
movl 0x44(%rsp), %eax
incl %eax
movl %eax, 0x44(%rsp)
cmpl 0x40(%rsp), %eax
jbe 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x729bc(%rip), %rdi     # 0xa6417
jmp 0x33b48
movl 0x1c(%rsp), %eax
cmpl 0x20(%rsp), %eax
jne 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x72923(%rip), %rdi     # 0xa63a0
jmp 0x33b48
movl 0x3c(%rsp), %eax
incl %eax
movl %eax, 0x3c(%rsp)
cmpl 0x38(%rsp), %eax
jbe 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x7293c(%rip), %rdi     # 0xa63e1
jmp 0x33b48
incl 0x40(%rsp)
jmp 0x33b56
movl 0x1c(%rsp), %eax
incl %eax
movl %eax, 0x1c(%rsp)
subl 0x20(%rsp), %eax
cmpl $0x2, %eax
jb 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x72853(%rip), %rdi     # 0xa632c
jmp 0x33b48
incl 0x38(%rsp)
jmp 0x33b56
movl 0x20(%rsp), %eax
incl %eax
movl %eax, 0x20(%rsp)
cmpl 0x1c(%rsp), %eax
jbe 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x72864(%rip), %rdi     # 0xa6364
jmp 0x33b48
incl 0x24(%rsp)
jmp 0x33b56
movl 0x34(%rsp), %eax
incl %eax
movl %eax, 0x34(%rsp)
cmpl 0x24(%rsp), %eax
jbe 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x727d1(%rip), %rdi     # 0xa62f8
jmp 0x33b48
movl 0x54(%rsp), %eax
incl %eax
movl %eax, 0x54(%rsp)
cmpl 0x24(%rsp), %eax
jbe 0x33b56
movl $0x0, 0x14(%rsp)
leaq 0x72789(%rip), %rdi     # 0xa62d1
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x337f3
movq 0x8(%rsp), %r13
callq 0xe0cc
leaq 0x9c0(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4270
movq %rbx, %rdi
leaq 0x72917(%rip), %rsi     # 0xa6494
callq 0x4280
testq %rax, %rax
je 0x33bb5
movq $-0x1, %r13
movq %r13, %rbx
incq %r13
xorl %edi, %edi
leaq 0x728f7(%rip), %rsi     # 0xa6494
callq 0x4280
movq %rax, 0x6a8(%rsp,%rbx,8)
cmpq $0x61, %rbx
jg 0x33bb5
testq %rax, %rax
jne 0x33b8e
testl %r13d, %r13d
jle 0x33be4
movl %r13d, %r15d
xorl %ebx, %ebx
movq 0x380(%rsp,%rbx,8), %rdi
movq 0x6a0(%rsp,%rbx,8), %rsi
callq 0x3a404
movq %rax, 0x380(%rsp,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x33bbf
movq 0x28(%rsp), %r8
movl 0x18(%rsp), %r9d
leaq 0x60(%rsp), %rdi
movl %r14d, %esi
leaq 0x380(%rsp), %rdx
movl %r13d, %ecx
callq 0x33010
cmpl $-0x1, %eax
je 0x33c2a
cltq
movq 0x60(%rsp,%rax,8), %rdx
movl $0x0, 0x14(%rsp)
leaq 0x72879(%rip), %rdi     # 0xa649a
movl %ebp, %esi
xorl %eax, %eax
callq 0x4030
movq 0x58(%rsp), %rbx
jmp 0x33769
leaq 0x6f5cf(%rip), %rdi     # 0xa320a
xorl %ebp, %ebp
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x33d8c
movl $0x1, 0x14(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r13d, %r13d
movl $0x0, 0x24(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x44(%rsp)
movq %rbx, %r15
movl %ebp, %ebx
movl 0x24(%rsp), %eax
cmpl 0x34(%rsp), %eax
movl 0x14(%rsp), %ebp
jbe 0x33cc0
leaq 0x72823(%rip), %rdi     # 0xa64d8
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x1c(%rsp), %eax
cmpl 0x20(%rsp), %eax
jbe 0x33cdc
leaq 0x7282e(%rip), %rdi     # 0xa64ff
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x38(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jbe 0x33cf8
leaq 0x7283d(%rip), %rdi     # 0xa652a
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
movl 0x40(%rsp), %eax
cmpl 0x44(%rsp), %eax
jbe 0x33d14
leaq 0x72849(%rip), %rdi     # 0xa6552
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
testq %r15, %r15
je 0x33d21
movq %r15, %rdi
callq 0x39194
testl %r14d, %r14d
jle 0x33d47
movl %r14d, %ebx
xorl %r14d, %r14d
movq 0x60(%rsp,%r14,8), %rdi
callq 0x39194
movq $0x0, 0x60(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x33d2c
testl %r13d, %r13d
jle 0x33d73
movl %r13d, %ebx
xorl %r14d, %r14d
movq 0x380(%rsp,%r14,8), %rdi
callq 0x39194
movq $0x0, 0x380(%rsp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x33d52
movq 0x28(%rsp), %rbx
movl 0x18(%rsp), %esi
movq %rbx, %rdi
callq 0x33e6d
movq %rbx, %rdi
callq 0x39194
movl %ebp, %eax
addq $0x7aae8, %rsp          # imm = 0x7AAE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq