// File: /workspace/github_c_makefile_star2_O2/rafa9811[P]theIndiependenceGame/theindiependencegame.c
// Function: intro
void _intro(){
    sc_rectangle *intro;
    FILE * in;
    char *dialog=NULL, *ini, line[INTRO_LINE],choice, buff[MAX], *intropath = "intro.txt";
    int len,j=0,linenumber,x,y;

    intro = win_new(0,0,INTROY,INTROX,BGCOLOR,CHARCOLOR); /*Creating the intro window, which occupies all the screen.*/
    in = (FILE*) fopen(intropath, "r"); /*Openning the intro txt file which contains every dialog from the intro.*/

	if(!in) exit(-1);
    if (!intro) exit(-1);

	while(!feof(in)){
	  win_cls(intro);
		fscanf(in,"%d\t%d\t%[^\n]s",&x,&y,buff);
		linenumber=y;
		if(dialog) free(dialog);
		len = strlen(buff);
		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,linenumber,x,line);
      j+=INTRO_LINE;
      linenumber++;
    }
		dialog = ini;
		choice = fgetc(stdin);
		while(choice!='a' && choice!='A' && choice!='\n'){
		    choice = fgetc(stdin);
		}
		if(choice=='\n'){
		    break;
		}
	}

	fclose(in);
	in = (FILE*) fopen("startmenu.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++;
    }
		
    }
		choice = fgetc(stdin);
		while(choice!='q' && choice!='Q' && choice!='\n'){
		    choice = fgetc(stdin);
		}
		if(choice=='q' || choice == 'Q'){
		    exit(0);
		}
    fclose(in);
    win_delete(intro);
		if(dialog) free(dialog);
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2788, %rsp           # imm = 0x2788
pushq $0x2e
popq %rdx
pushq $0x78
popq %rcx
pushq $0x1
popq %r8
xorl %edi, %edi
xorl %esi, %esi
xorl %r9d, %r9d
callq 0x3c28
movq %rax, %rbx
leaq 0x4b8b(%rip), %rdi      # 0x6030
leaq 0x4b8e(%rip), %rsi      # 0x603a
callq 0x11a0
testq %rax, %rax
je 0x171f
movq %rbx, 0x10(%rsp)
testq %rbx, %rbx
je 0x171f
movq %rax, %r14
leaq 0x20(%rsp), %r12
pushq $0x41
popq %r13
xorl %r15d, %r15d
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x15cc
movq 0x10(%rsp), %rdi
callq 0x3c71
movq %r14, %rdi
leaq 0x4b3c(%rip), %rsi      # 0x603c
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x70(%rsp), %rbx
movq %rbx, %r8
xorl %eax, %eax
callq 0x1060
movl 0x8(%rsp), %ebp
movq %r15, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1080
movq %rax, %r14
movq %rax, %rdi
shlq $0x20, %rdi
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rdi
sarq $0x20, %rdi
callq 0x1130
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1050
movslq %r14d, %rbx
xorl %r14d, %r14d
cmpq %rbx, %r14
jge 0x1595
cmpl $0x2e, %ebp
jge 0x1595
leaq (%r15,%r14), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x1100
movl 0xc(%rsp), %edx
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movq %r12, %rcx
callq 0x3d9a
addq $0x41, %r14
incl %ebp
jmp 0x1561
movq 0x8a44(%rip), %rax      # 0x9fe0
movq (%rax), %rdi
callq 0x10d0
movl %eax, %ecx
shll $0x18, %ecx
andl $0xdf, %eax
cmpl $0x41, %eax
je 0x15bb
cmpl $0xa000000, %ecx        # imm = 0xA000000
jne 0x1595
cmpl $0xa000000, %ecx        # imm = 0xA000000
movq 0x18(%rsp), %r14
jne 0x14dc
movq %r14, %rdi
callq 0x1070
leaq 0x4a6e(%rip), %rdi      # 0x6049
leaq 0x4a58(%rip), %rsi      # 0x603a
callq 0x11a0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x3c71
leaq 0x20(%rsp), %r12
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0x10f0
testl %eax, %eax
jne 0x16c2
movq %rbx, %rdi
leaq 0x4a24(%rip), %rsi      # 0x603c
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x70(%rsp), %rbx
movq %rbx, %r8
xorl %eax, %eax
callq 0x1060
movq %rbx, %rdi
callq 0x1080
movq %rax, %r13
movq %r15, %rdi
callq 0x1030
movq %r13, %rdi
shlq $0x20, %rdi
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rdi
sarq $0x20, %rdi
callq 0x1130
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1050
movslq %r13d, %r13
xorl %ebx, %ebx
movq %r14, %r15
cmpq %r13, %rbx
jge 0x16b0
cmpl $0x2d, %ebp
jg 0x16b0
leaq (%r14,%rbx), %r15
movq %r12, %rdi
movq %r15, %rsi
pushq $0x41
popq %rdx
callq 0x1100
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq 0x10(%rsp), %rdi
movq %r12, %rcx
callq 0x3d9a
addq $0x41, %rbx
incl %ebp
jmp 0x1677
movq 0x18(%rsp), %rbx
jmp 0x15fe
cmpl $0xa000000, %ecx        # imm = 0xA000000
je 0x16e3
movq 0x8917(%rip), %rax      # 0x9fe0
movq (%rax), %rdi
callq 0x10d0
movl %eax, %ecx
shll $0x18, %ecx
movl %eax, %edx
andl $0xdf, %edx
cmpl $0x51, %edx
jne 0x16ba
cmpl $0x71000000, %ecx       # imm = 0x71000000
je 0x1727
andl $0x7b, %eax
cmpl $0x51, %eax
je 0x1727
movq %rbx, %rdi
callq 0x1070
movq 0x10(%rsp), %rdi
callq 0x3d19
movq %r15, %rdi
callq 0x1030
addq $0x2788, %rsp           # imm = 0x2788
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rdi
callq 0x11c0
xorl %edi, %edi
callq 0x11c0