// File: /workspace/github_c_makefile_star2_O0/rafa9811[P]theIndiependenceGame/theindiependencegame.c
// Function: GetEnd
void GetEnd(Interact *interact){
	    sc_rectangle *intro;
	    FILE * in;
			Stat* stat;
	    char *dialog=NULL, *ini, line[INTRO_LINE],choice, buff[MAX], endpath[INTRO_LINE];
	    int len,j=0,linenumber,x,y,boxes,printers,meetings,motivation, chaos, nodanger, score, money;
			
			boxes = interact_getBoxes(interact);
			printers = interact_getPrinters(interact);
			meetings = interact_getMeetings(interact);
			stat = interact_getStat(interact);
			motivation = stat_get_motivation(stat);
			chaos = stat_get_chaos(stat);
			nodanger = -stat_get_nodanger(stat);
			money = stat_get_money(stat);
			
			if(end==2){
				strcpy(endpath,"endarrested.txt");
				goto endlabel;
			}
						
			if (boxes == 0 && printers == 0 && meetings == 0) {
					strcpy(endpath, "endsuicide.txt");
					goto endlabel;
			}
			if (boxes == 3 && printers == 3 && meetings == 3) {
					strcpy(endpath, "endbrussels.txt");
					goto endlabel;
			}
			if ((boxes + meetings + printers <= 10) || boxes<3 || meetings<3 || printers<3) {
					if((boxes==0 && meetings + printers > 6)|| (meetings==0 && boxes + printers > 6) || (printers==0 && boxes + meetings >6)) goto nosomething;
					strcpy(endpath, "endlose.txt");
					goto endlabel;
			}

			if (boxes == 5 && printers == 5 && meetings == 5) {
					strcpy(endpath, "endempire.txt");
					goto endlabel;
			}
			if ((boxes + meetings + printers >= 11) || boxes==0 || meetings==0 || printers==0) {
					nosomething: if (boxes == 0) {
							strcpy(endpath, "endnoboxes.txt");
							goto endlabel;
					}
					if (meetings == 0) {
							strcpy(endpath, "endnomeetings.txt");
							goto endlabel;
					}
					if (printers == 0) {
							strcpy(endpath, "endnoprinters.txt");
							goto endlabel;
					}
					strcpy(endpath, "endwin.txt");
					goto endlabel;
			}
			
			
	    endlabel: intro = win_new(0,0,INTROY,INTROX,BGCOLOR,CHARCOLOR); /*Creating the intro window, which occupies all the screen.*/
	    in = (FILE*) fopen(endpath, "r"); /*Openning the intro txt file which contains every dialog from the intro.*/
	
		if(!in) exit(-1);
	  if (!intro) exit(-1);
			win_cls(intro);
			usleep(1000000);
		while(!feof(in)){
			fscanf(in,"%d\t%d\t%[^\n]s",&x,&y,buff);
			if(dialog) free(dialog);
			len = strlen(buff);
			dialog = (char*) malloc(len+1);
			strcpy(dialog,buff);
	    win_write_line_at(intro,y,x,dialog);
	    j+=INTRO_LINE;
			choice = fgetc(stdin);
			while(choice!='a' && choice!='A' && choice!='\n'){
			    choice = fgetc(stdin);
			}
			if(choice=='\n'){
			    break;
			}
		}
	
		fclose(in);
		in = (FILE*) fopen("endmenu.txt", "r");
		win_cls(intro);
	    while(!feof(in)){
			fscanf(in,"%d\t%d\t%[^\n]s",&x,&y,buff);
			len = strlen(buff);
			if(dialog) free(dialog);
			dialog = (char*) malloc(len+1);
			strcpy(dialog,buff);
	    ini=dialog;
	    j=0;
	    while(j<len && linenumber<INTROY){
	      dialog = ini + j;
	      memcpy(line,dialog,INTRO_LINE);
	      win_write_line_at(intro,y,x,line);
	      j+=INTRO_LINE;
	      linenumber++;
	    }
			
	    }
			score = (int)(2.5*motivation + 2*chaos + 1.5*nodanger + money);
			sprintf(line,"YOUR SCORE: %d PuidgePoints",score);
			win_write_line_at(intro,33,15,line);
			choice = fgetc(stdin);
			while(choice!='\n'){
			    choice = fgetc(stdin);
			}
			if(choice=='\n'){
				fclose(in);
				win_delete(intro);
				if(dialog) free(dialog);
				tcsetattr(fileno(stdin), TCSANOW, &initial);
				exit(0);
			}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2830, %rsp           # imm = 0x2830
movq %rdi, -0x8(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x27f8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x67c0
movl %eax, -0x2808(%rbp)
movq -0x8(%rbp), %rdi
callq 0x67f0
movl %eax, -0x280c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6820
movl %eax, -0x2810(%rbp)
movq -0x8(%rbp), %rdi
callq 0x68e0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x60e0
movl %eax, -0x2814(%rbp)
movq -0x20(%rbp), %rdi
callq 0x61a0
movl %eax, -0x2818(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6370
movl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x281c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6300
movl %eax, -0x2824(%rbp)
movswl 0xb786(%rip), %eax      # 0xd13a
cmpl $0x2, %eax
jne 0x19d1
leaq -0x27f0(%rbp), %rdi
leaq 0x7688(%rip), %rsi      # 0x904f
callq 0x1040
jmp 0x1ba9
cmpl $0x0, -0x2808(%rbp)
jne 0x1a04
cmpl $0x0, -0x280c(%rbp)
jne 0x1a04
cmpl $0x0, -0x2810(%rbp)
jne 0x1a04
leaq -0x27f0(%rbp), %rdi
leaq 0x7665(%rip), %rsi      # 0x905f
callq 0x1040
jmp 0x1ba9
cmpl $0x3, -0x2808(%rbp)
jne 0x1a37
cmpl $0x3, -0x280c(%rbp)
jne 0x1a37
cmpl $0x3, -0x2810(%rbp)
jne 0x1a37
leaq -0x27f0(%rbp), %rdi
leaq 0x7641(%rip), %rsi      # 0x906e
callq 0x1040
jmp 0x1ba9
movl -0x2808(%rbp), %eax
addl -0x2810(%rbp), %eax
addl -0x280c(%rbp), %eax
cmpl $0xa, %eax
jle 0x1a69
cmpl $0x3, -0x2808(%rbp)
jl 0x1a69
cmpl $0x3, -0x2810(%rbp)
jl 0x1a69
cmpl $0x3, -0x280c(%rbp)
jge 0x1ad1
cmpl $0x0, -0x2808(%rbp)
jne 0x1a83
movl -0x2810(%rbp), %eax
addl -0x280c(%rbp), %eax
cmpl $0x6, %eax
jg 0x1ab7
cmpl $0x0, -0x2810(%rbp)
jne 0x1a9d
movl -0x2808(%rbp), %eax
addl -0x280c(%rbp), %eax
cmpl $0x6, %eax
jg 0x1ab7
cmpl $0x0, -0x280c(%rbp)
jne 0x1ab9
movl -0x2808(%rbp), %eax
addl -0x2810(%rbp), %eax
cmpl $0x6, %eax
jle 0x1ab9
jmp 0x1b38
leaq -0x27f0(%rbp), %rdi
leaq 0x75b7(%rip), %rsi      # 0x907e
callq 0x1040
jmp 0x1ba9
cmpl $0x5, -0x2808(%rbp)
jne 0x1b04
cmpl $0x5, -0x280c(%rbp)
jne 0x1b04
cmpl $0x5, -0x2810(%rbp)
jne 0x1b04
leaq -0x27f0(%rbp), %rdi
leaq 0x7590(%rip), %rsi      # 0x908a
callq 0x1040
jmp 0x1ba9
movl -0x2808(%rbp), %eax
addl -0x2810(%rbp), %eax
addl -0x280c(%rbp), %eax
cmpl $0xb, %eax
jge 0x1b36
cmpl $0x0, -0x2808(%rbp)
je 0x1b36
cmpl $0x0, -0x2810(%rbp)
je 0x1b36
cmpl $0x0, -0x280c(%rbp)
jne 0x1ba7
jmp 0x1b38
cmpl $0x0, -0x2808(%rbp)
jne 0x1b56
leaq -0x27f0(%rbp), %rdi
leaq 0x7549(%rip), %rsi      # 0x9098
callq 0x1040
jmp 0x1ba9
cmpl $0x0, -0x2810(%rbp)
jne 0x1b74
leaq -0x27f0(%rbp), %rdi
leaq 0x753a(%rip), %rsi      # 0x90a7
callq 0x1040
jmp 0x1ba9
cmpl $0x0, -0x280c(%rbp)
jne 0x1b92
leaq -0x27f0(%rbp), %rdi
leaq 0x752e(%rip), %rsi      # 0x90b9
callq 0x1040
jmp 0x1ba9
leaq -0x27f0(%rbp), %rdi
leaq 0x752b(%rip), %rsi      # 0x90cb
callq 0x1040
jmp 0x1ba9
jmp 0x1ba9
xorl %r9d, %r9d
movl $0x2e, %edx
movl $0x78, %ecx
movl $0x1, %r8d
movl %r9d, %edi
movl %r9d, %esi
callq 0x5b20
movq %rax, -0x10(%rbp)
leaq -0x27f0(%rbp), %rdi
leaq 0x7459(%rip), %rsi      # 0x9032
callq 0x1190
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1bf3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11b0
cmpq $0x0, -0x10(%rbp)
jne 0x1c04
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11b0
movq -0x10(%rbp), %rdi
callq 0x5b90
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x11c0
movq -0x18(%rbp), %rdi
callq 0x10f0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1c31
jmp 0x1d4d
movq -0x18(%rbp), %rdi
leaq -0x27a0(%rbp), %r8
leaq 0x73f1(%rip), %rsi      # 0x9034
leaq -0x2800(%rbp), %rdx
leaq -0x2804(%rbp), %rcx
movb $0x0, %al
callq 0x1050
cmpq $0x0, -0x28(%rbp)
je 0x1c68
movq -0x28(%rbp), %rdi
callq 0x1030
leaq -0x27a0(%rbp), %rdi
callq 0x1070
movl %eax, -0x27f4(%rbp)
movl -0x27f4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x1130
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x27a0(%rbp), %rsi
callq 0x1040
movq -0x10(%rbp), %rdi
movl -0x2804(%rbp), %esi
movl -0x2800(%rbp), %edx
movq -0x28(%rbp), %rcx
callq 0x5dd0
movl -0x27f8(%rbp), %eax
addl $0x41, %eax
movl %eax, -0x27f8(%rbp)
movq 0xb312(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x10c0
movb %al, -0x81(%rbp)
movsbl -0x81(%rbp), %ecx
xorl %eax, %eax
cmpl $0x61, %ecx
movb %al, -0x2825(%rbp)
je 0x1d17
movsbl -0x81(%rbp), %ecx
xorl %eax, %eax
cmpl $0x41, %ecx
movb %al, -0x2825(%rbp)
je 0x1d17
movsbl -0x81(%rbp), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x2825(%rbp)
movb -0x2825(%rbp), %al
testb $0x1, %al
jne 0x1d23
jmp 0x1d3a
movq 0xb2b6(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x10c0
movb %al, -0x81(%rbp)
jmp 0x1cdc
movsbl -0x81(%rbp), %eax
cmpl $0xa, %eax
jne 0x1d48
jmp 0x1d4d
jmp 0x1c17
movq -0x18(%rbp), %rdi
callq 0x1060
leaq 0x7379(%rip), %rdi      # 0x90d6
leaq 0x72ce(%rip), %rsi      # 0x9032
callq 0x1190
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5b90
movq -0x18(%rbp), %rdi
callq 0x10f0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1d90
jmp 0x1ea7
movq -0x18(%rbp), %rdi
leaq -0x27a0(%rbp), %r8
leaq 0x7292(%rip), %rsi      # 0x9034
leaq -0x2800(%rbp), %rdx
leaq -0x2804(%rbp), %rcx
movb $0x0, %al
callq 0x1050
leaq -0x27a0(%rbp), %rdi
callq 0x1070
movl %eax, -0x27f4(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1dd9
movq -0x28(%rbp), %rdi
callq 0x1030
movl -0x27f4(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x1130
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x27a0(%rbp), %rsi
callq 0x1040
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x27f8(%rbp)
movl -0x27f8(%rbp), %ecx
xorl %eax, %eax
cmpl -0x27f4(%rbp), %ecx
movb %al, -0x2826(%rbp)
jge 0x1e36
cmpl $0x2e, -0x27fc(%rbp)
setl %al
movb %al, -0x2826(%rbp)
movb -0x2826(%rbp), %al
testb $0x1, %al
jne 0x1e42
jmp 0x1ea2
movq -0x30(%rbp), %rax
movslq -0x27f8(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x41, %edx
callq 0x1100
movq -0x10(%rbp), %rdi
movl -0x2804(%rbp), %esi
movl -0x2800(%rbp), %edx
leaq -0x80(%rbp), %rcx
callq 0x5dd0
movl -0x27f8(%rbp), %eax
addl $0x41, %eax
movl %eax, -0x27f8(%rbp)
movl -0x27fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27fc(%rbp)
jmp 0x1e10
jmp 0x1d76
cvtsi2sdl -0x2814(%rbp), %xmm1
movl -0x2818(%rbp), %eax
shll %eax
cvtsi2sd %eax, %xmm0
movsd 0x715d(%rip), %xmm2     # 0x9020
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvtsi2sdl -0x281c(%rbp), %xmm0
movsd 0x713d(%rip), %xmm2     # 0x9018
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x2824(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2820(%rbp)
leaq -0x80(%rbp), %rdi
movl -0x2820(%rbp), %edx
leaq 0x71d8(%rip), %rsi      # 0x90e2
movb $0x0, %al
callq 0x11a0
movq -0x10(%rbp), %rdi
leaq -0x80(%rbp), %rcx
movl $0x21, %esi
movl $0xf, %edx
callq 0x5dd0
movq 0xb0b1(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x10c0
movb %al, -0x81(%rbp)
movsbl -0x81(%rbp), %eax
cmpl $0xa, %eax
je 0x1f60
movq 0xb090(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x10c0
movb %al, -0x81(%rbp)
jmp 0x1f3d
movsbl -0x81(%rbp), %eax
cmpl $0xa, %eax
jne 0x1fb4
movq -0x18(%rbp), %rdi
callq 0x1060
movq -0x10(%rbp), %rdi
callq 0x5ca0
cmpq $0x0, -0x28(%rbp)
je 0x1f8e
movq -0x28(%rbp), %rdi
callq 0x1030
movq 0xb04b(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
callq 0x1120
movl %eax, %edi
xorl %esi, %esi
leaq 0xb154(%rip), %rdx      # 0xd0fc
callq 0x1180
xorl %edi, %edi
callq 0x11b0
addq $0x2830, %rsp           # imm = 0x2830
popq %rbp
retq
nopl (%rax)