// File: /workspace/github_c_makefile_star2_O2/S01den[P]Lost_CavernRL/screen.c
// Function: calcFOV
void calcFOV(Map map[LONGUEUR][LARGEUR], int view, int posX, int posY, WINDOW *win_map, Ennemy ennemies[], int nbrEnnemies, int *ennemyPresent, int colorBlind, int stone, Drug drugList[], int nbrDrugs, Weapons weaponOnFloor[], int nbrWeapons, Armor armorOnFloor[], int nbrArmors, Pnj pnjOnFloor[], int nbrPnjOnFloor)
{
	const char tileset_ennemies[] = "dtgn";
	const char tileset_pnj[] = "cwes";
	const char tileset[] = " .#>=!+]/;* ?";

	float i = 0;
	float j = 0;
	int angle = 0; // en radian
	float ox,oy = 0;
	int c = 0;
	int colorWeapon = 22;
	int colorArmor = 22;

	for(angle = 0; angle < nbrEnnemies; angle++)
	{
		ennemies[angle].seen = 0;
	}

	for(angle = 0; angle < 360; angle++)
	{
		i = cos((float)angle*0.01745f); // 1° = 0.01745 rad because 360° = 2pi rad
		j = sin((float)angle*0.01745f);
		ox = (float)posX+0.5f;
		oy = (float)posY+0.5f;

			for(c = 0; c < view && (int)ox+i <= LONGUEUR && (int)ox+i >= -1 && (int)oy+j >= -1 && (int)oy+j <= LARGEUR;c++)
			{
				if(!stone)
				{
					if(map[(int)ox][(int)oy].effect == 0)
					{
						wattron(win_map,A_BOLD);
						mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
						wattroff(win_map,A_BOLD);					
					}
					else if(map[(int)ox][(int)oy].effect == 1) // on fire
					{
						if(rand()%300 <= 298)
						{
							if(rand()%4 == 3)
							{
								wattron(win_map,COLOR_PAIR(10));
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
								wattroff(win_map,COLOR_PAIR(10));		
							}
							else
							{
								wattron(win_map,COLOR_PAIR(203));
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
								wattroff(win_map,COLOR_PAIR(203));
							}					
						}
						else
						{
							map[(int)ox][(int)oy].effect = 0;
							wattron(win_map,A_BOLD);
							mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
							wattroff(win_map,A_BOLD);						
						}

						if(map[(int)ox][(int)oy].content == WALL && rand()%10 == 2)
						{
							if(map[(int)ox][(int)oy].resistance-1 > 0)
							{
								map[(int)ox][(int)oy].resistance--;
							}
							else
							{
								map[(int)ox][(int)oy].resistance = 0;
								if(rand()%100 <= 90)
									map[(int)ox][(int)oy].content = FLOOR;
								else
								{
									map[(int)ox][(int)oy].content = MINES;
									map[(int)ox][(int)oy].trap = 1;
								}
							}
						}
					}
					else if(map[(int)ox][(int)oy].effect == 2) // radioactive
					{
						wattron(win_map,COLOR_PAIR(83));
						mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
						wattroff(win_map,COLOR_PAIR(83));				
					}
					else if(map[(int)ox][(int)oy].effect == 3) // lava
					{
						if(rand()%4 == 0)
						{
							wattron(win_map,COLOR_PAIR(203));
							mvwprintw(win_map,(int)ox+1,(int)oy+1,"*");
							wattroff(win_map,COLOR_PAIR(203));
						}
						else
						{
							wattron(win_map,COLOR_PAIR(COLOR_LAVA));
							mvwprintw(win_map,(int)ox+1,(int)oy+1,"*");
							wattroff(win_map,COLOR_PAIR(COLOR_LAVA));	
						}			
					}
					else if(map[(int)ox][(int)oy].effect == 4) // gem
					{
						wattron(win_map,COLOR_PAIR(124));
						mvwprintw(win_map,j+1,i+1,"#");
						wattroff(win_map,COLOR_PAIR(124));				
					}

					map[(int)ox][(int)oy].seen = 1;

					int testPnj = testPnjOnPos(pnjOnFloor,(int)ox,(int)oy,nbrPnjOnFloor);
					if(testPnj >= 0)
					{
							wattron(win_map,COLOR_PAIR(STAIRS_COLOR));
							mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset_pnj[pnjOnFloor[testPnj].type]);
							wattroff(win_map,COLOR_PAIR(STAIRS_COLOR));	
							map[(int)ox][(int)oy].typePnj = pnjOnFloor[testPnj].type;
					}

					int testEnnemy = testEnnemyOnPos(ennemies,(int)ox,(int)oy,nbrEnnemies);
					
					if(testEnnemy >= 0 && ennemies[testEnnemy].life > 0 && ennemies[testEnnemy].type > 0)
					{
						*ennemyPresent = 1;
						ennemies[testEnnemy].seen = 1;
						map[(int)ox][(int)oy].typeEnnemy = ennemies[testEnnemy].type;
						if(ennemies[testEnnemy].effect == 1)
						{
							wattron(win_map,COLOR_PAIR(BURN_EFFECT));
							if(ennemies[testEnnemy].boss == 0)
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset_ennemies[map[(int)ox][(int)oy].typeEnnemy-1]);
							else
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset_ennemies[map[(int)ox][(int)oy].typeEnnemy-1]-32);
							wattroff(win_map,COLOR_PAIR(BURN_EFFECT));
						}
						else
						{
							wattron(win_map,COLOR_PAIR(ENEMY_COLORS+1));
							if(ennemies[testEnnemy].boss == 0)
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset_ennemies[map[(int)ox][(int)oy].typeEnnemy-1]);
							else
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset_ennemies[map[(int)ox][(int)oy].typeEnnemy-1]-32);
							wattroff(win_map,COLOR_PAIR(ENEMY_COLORS+1));
						}
					}
					else
					{
						map[(int)ox][(int)oy].typeEnnemy = 0;
					}

					if(map[(int)ox][(int)oy].typeEnnemy == 0)
					{
							if(map[(int)ox][(int)oy].content == WALL)
							{
								if(colorBlind == 0 && map[(int)ox][(int)oy].effect == 0)
								{
									switch(map[(int)ox][(int)oy].resistance/10)
									{
										case 0:
											wattron(win_map,COLOR_PAIR(COLOR_RESIST_1));
											mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
											wattroff(win_map,COLOR_PAIR(COLOR_RESIST_1));
											break;
										case 1:
											wattron(win_map,COLOR_PAIR(COLOR_RESIST_2));
											mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
											wattroff(win_map,COLOR_PAIR(COLOR_RESIST_2));
											break;
										case 2:
											wattron(win_map,COLOR_PAIR(COLOR_RESIST_3));
											mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
											wattroff(win_map,COLOR_PAIR(COLOR_RESIST_3));
											break;
										default:
											wattron(win_map,COLOR_PAIR(COLOR_RESIST_3));
											mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
											wattroff(win_map,COLOR_PAIR(COLOR_RESIST_3));
											break;
									}
								}
								else if(colorBlind == 1)
								{
									wattron(win_map,A_DIM);
									mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
									wattroff(win_map,A_DIM);
								}
								else if(map[(int)ox][(int)oy].effect == 2)
								{
									wattron(win_map,COLOR_PAIR(83));
									mvwprintw(win_map,(int)ox+1,(int)oy+1,"#");
									wattroff(win_map,COLOR_PAIR(83));
								}
								break;
							}
							else if(map[(int)ox][(int)oy].content == STAIRS)
							{
								wattron(win_map,COLOR_PAIR(STAIRS_COLOR));
								mvwprintw(win_map,(int)ox+1,(int)oy+1,">");
								wattroff(win_map,COLOR_PAIR(STAIRS_COLOR));		
							}
							else if(map[(int)ox][(int)oy].content == COMPUTER)
							{
								wattron(win_map,COLOR_PAIR(STAIRS_COLOR));
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"?");
								wattroff(win_map,COLOR_PAIR(STAIRS_COLOR));					
							}
							else if(map[(int)ox][(int)oy].content == HOLE)
							{
								wattron(win_map,COLOR_PAIR(COLOR_HOLE));
								mvwprintw(win_map,(int)ox+1,(int)oy+1," ");
								wattroff(win_map,COLOR_PAIR(COLOR_HOLE));	
							}
							else if(map[(int)ox][(int)oy].content == MINES && map[(int)ox][(int)oy].trap > 0)
							{
								wattron(win_map,COLOR_PAIR(map[(int)ox][(int)oy].trap+21));
								mvwprintw(win_map,(int)ox+1,(int)oy+1,"=");
								wattroff(win_map,COLOR_PAIR(map[(int)ox][(int)oy].trap+21));		
							}
							else if(map[(int)ox][(int)oy].content == DRUG)
							{
								int drug = testDrug(drugList,(int)ox,(int)oy,nbrDrugs);
								if(drug >= 0)
								{
									//mvwprintw(win_map,0,0,"%d",drugList[drug].type);
									wattron(win_map,COLOR_PAIR(drugList[drug].color));
									mvwprintw(win_map,(int)ox+1,(int)oy+1,"!");
									wattroff(win_map,COLOR_PAIR(drugList[drug].color));					
								}
								else
								{
									map[(int)ox][(int)oy].content = FLOOR;
								}

							}
							else if(map[(int)ox][(int)oy].content == CONTACT_WEAPON)
							{
								int weapon = testWeapon(weaponOnFloor,(int)ox,(int)oy,nbrWeapons);
								switch(weaponOnFloor[weapon].rarity)
								{
									case 1:
										colorWeapon = 22;
										break;
									case 2:
										colorWeapon = 166;
										break;
									case 3:
										colorWeapon = 12;
										break;
									default:
										colorWeapon = 22;
										break;
								}
								if(weapon >= 0)
								{
									wattron(win_map,COLOR_PAIR(colorWeapon));
									mvwprintw(win_map,(int)ox+1,(int)oy+1,"/");
									wattroff(win_map,COLOR_PAIR(colorWeapon));
								}	
								else
								{
									map[(int)ox][(int)oy].content = FLOOR;
								}
							}
							else if(map[(int)ox][(int)oy].content == DIST_WEAPON)
							{
								int weapon = testWeapon(weaponOnFloor,(int)ox,(int)oy,nbrWeapons);
								switch(weaponOnFloor[weapon].rarity)
								{
									case 1:
										colorWeapon = 22;
										break;
									case 2:
										colorWeapon = 166;
										break;
									case 3:
										colorWeapon = 12;
										break;
									default:
										colorWeapon = 22;
										break;
								}
								if(weapon >= 0)
								{
									wattron(win_map,COLOR_PAIR(colorWeapon));
									mvwprintw(win_map,(int)ox+1,(int)oy+1,";");
									wattroff(win_map,COLOR_PAIR(colorWeapon));	
								}
								else
								{
									map[(int)ox][(int)oy].content = FLOOR;
								}
							}
							else if(map[(int)ox][(int)oy].content == ARMOR)
							{
								int armor = testArmor(armorOnFloor, (int)ox, (int)oy, nbrArmors);
								switch(armorOnFloor[armor].rarity)
								{
									case 1:
										colorArmor = 22;
										break;
									case 2:
										colorArmor = 166;
										break;
									case 3:
										colorArmor = 12;
										break;
									default:
										colorArmor = 22;
										break;
								}
								if(armor >= 0)
								{
									wattron(win_map,COLOR_PAIR(colorArmor));
									mvwprintw(win_map,(int)ox+1,(int)oy+1,"]");
									wattroff(win_map,COLOR_PAIR(colorArmor));	
								}
								else
								{
									map[(int)ox][(int)oy].content = FLOOR;
								}	
							}
						}
				}
				else
				{
					int colorRand = rand()%256;
					wattron(win_map,COLOR_PAIR(colorRand));
					mvwprintw(win_map,(int)ox+1,(int)oy+1,"%c",tileset[map[(int)ox][(int)oy].content]);
					wattroff(win_map,COLOR_PAIR(colorRand));
					map[(int)ox][(int)oy].seen = 1;
				}			

				ox+=i;
				oy+=j;
			}
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, 0x48(%rsp)
movl 0xc0(%rsp), %r10d
xorl %eax, %eax
testl %r10d, %r10d
movl $0x0, %edi
cmovgl %r10d, %edi
imulq $0x38, %rdi, %rdi
cmpq %rax, %rdi
je 0xb57d
andl $0x0, 0xc(%r9,%rax)
addq $0x38, %rax
jmp 0xb56c
movq %r8, 0x8(%rsp)
movd %edx, %xmm0
movd %ecx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm0
addps 0x2968(%rip), %xmm0     # 0xdf00
movaps %xmm0, 0x60(%rsp)
xorl %eax, %eax
testl %esi, %esi
cmovlel %eax, %esi
movl %esi, 0x2c(%rsp)
xorl %eax, %eax
movq %r9, 0x40(%rsp)
cmpl $0x168, %eax            # imm = 0x168
je 0xbfca
movl %eax, 0x38(%rsp)
cvtsi2ss %eax, %xmm0
mulss 0x292e(%rip), %xmm0     # 0xdef8
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x10c0
movaps %xmm0, 0x50(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x1200
unpcklpd 0x50(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
cvtpd2ps %xmm0, %xmm0
movapd %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movaps %xmm0, 0x50(%rsp)
movss 0x4360(%rip), %xmm1     # 0xf968
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x34(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x30(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x3c(%rsp)
movaps 0x60(%rsp), %xmm3
subl $0x1, 0x3c(%rsp)
jb 0xbf8b
movaps %xmm3, %xmm0
shufps $0x55, %xmm3, %xmm0     # xmm0 = xmm0[1,1],xmm3[1,1]
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
addss 0x70(%rsp), %xmm1
movss 0x2898(%rip), %xmm2     # 0xdef4
ucomiss %xmm1, %xmm2
jb 0xbf8b
ucomiss 0x4300(%rip), %xmm1     # 0xf96c
jb 0xbf8b
cvttps2dq %xmm3, %xmm1
cvtdq2ps %xmm1, %xmm1
addss 0x50(%rsp), %xmm1
ucomiss 0x42e6(%rip), %xmm1     # 0xf96c
jb 0xbf8b
movss 0x285c(%rip), %xmm2     # 0xdef0
ucomiss %xmm1, %xmm2
jb 0xbf8b
cvttss2si %xmm0, %r13d
movaps %xmm3, 0x10(%rsp)
cvttss2si %xmm3, %ebp
movslq %r13d, %r14
movslq %ebp, %r12
cmpl $0x0, 0xd8(%rsp)
je 0xb738
callq 0x11d0
cltd
movl $0x100, %ecx            # imm = 0x100
idivl %ecx
shll $0x8, %edx
movzwl %dx, %ebx
movq 0x8(%rsp), %r13
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r14), %esi
leal 0x1(%r12), %edx
imulq $0xe38, %r14, %r14      # imm = 0xE38
addq 0x48(%rsp), %r14
imulq $0x1c, %r12, %r12
movslq (%r12,%r14), %rax
leaq 0x430b(%rip), %rcx      # 0xfa0e
movsbl (%rax,%rcx), %r8d
movq %r13, %rdi
leaq 0x42ee(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
movl $0x1, 0x8(%r12,%r14)
movaps 0x10(%rsp), %xmm3
jmp 0xbb07
imulq $0xe38, %r14, %rax      # imm = 0xE38
addq 0x48(%rsp), %rax
imulq $0x1c, %r12, %rcx
leaq (%rax,%rcx), %r14
movl 0x4(%rcx,%rax), %eax
cmpq $0x4, %rax
movq 0x40(%rsp), %r12
ja 0xb953
leaq 0x420a(%rip), %rcx      # 0xf970
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r13), %esi
leal 0x1(%rbp), %edx
movslq (%r14), %rax
leaq 0x427a(%rip), %rcx      # 0xfa0e
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x425d(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
jmp 0xb94c
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x11c0
movq %rbx, %rdi
movl 0x34(%rsp), %esi
movl 0x30(%rsp), %edx
leaq 0x4226(%rip), %rcx      # 0xfa03
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
jmp 0xb94c
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r13), %esi
leal 0x1(%rbp), %edx
movslq (%r14), %rax
leaq 0x41f8(%rip), %rcx      # 0xfa0e
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x41db(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
jmp 0xb94c
callq 0x11d0
leal 0x1(%r13), %r15d
leal 0x1(%rbp), %ebx
testb $0x3, %al
je 0xb919
movl %ebx, %r12d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x11c0
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
movq 0x40(%rsp), %r12
leaq 0x3930(%rip), %rcx      # 0xf1a9
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xf500, %esi           # imm = 0xF500
jmp 0xb94c
callq 0x11d0
cltd
movl $0x12c, %ecx            # imm = 0x12C
idivl %ecx
cmpl $0x12a, %edx            # imm = 0x12A
jg 0xb8dc
callq 0x11d0
andl $0x80000003, %eax       # imm = 0x80000003
leal 0x1(%r13), %ecx
movl %ecx, 0x20(%rsp)
leal 0x1(%rbp), %ecx
movl %ecx, 0x28(%rsp)
cmpl $0x3, %eax
jne 0xbb66
movl $0xa00, %r15d           # imm = 0xA00
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xa00, %esi            # imm = 0xA00
jmp 0xbb79
andl $0x0, 0x4(%r14)
movl $0x200000, %r15d        # imm = 0x200000
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r13), %esi
leal 0x1(%rbp), %edx
movslq (%r14), %rax
leaq 0x4102(%rip), %rcx      # 0xfa0e
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
jmp 0xbb9a
movq 0x8(%rsp), %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movq 0x8(%rsp), %rdi
movl %r15d, %esi
movl %ebx, %edx
leaq 0x386e(%rip), %rcx      # 0xf1a9
xorl %eax, %eax
callq 0x1070
movq 0x8(%rsp), %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x1060
movq %r12, %r15
movl $0x1, 0x8(%r14)
movq 0x110(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0x118(%rsp), %ecx
callq 0xacc8
testl %eax, %eax
js 0xb9e5
movl %eax, %ebx
movq %r14, 0x20(%rsp)
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r13), %esi
leal 0x1(%rbp), %edx
movl %ebx, %ebx
shlq $0x5, %rbx
movslq 0x8(%r12,%rbx), %rax
leaq 0x406a(%rip), %rcx      # 0xfa1c
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
leaq 0x403f(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movq 0x20(%rsp), %r14
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
movl 0x8(%r12,%rbx), %eax
movl %eax, 0x10(%r14)
movq %r15, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xc0(%rsp), %ecx
callq 0x4f9a
testl %eax, %eax
js 0xba99
movl %eax, %eax
imulq $0x38, %rax, %rbx
cmpl $0x0, 0x8(%r15,%rbx)
jle 0xba99
addq %r15, %rbx
cmpl $0x0, 0x20(%rbx)
jle 0xba99
movq 0xc8(%rsp), %rax
pushq $0x1
popq %rcx
movl %ecx, (%rax)
movl %ecx, 0xc(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0xc(%r14)
leal 0x1(%r13), %r15d
leal 0x1(%rbp), %eax
movl %eax, 0x20(%rsp)
cmpl %ecx, 0x24(%rbx)
movq %r14, %r12
jne 0xbaa0
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xf600, %esi           # imm = 0xF600
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r12), %rax
leaq 0x3fa3(%rip), %rcx      # 0xfa09
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r14, %rdi
movl %r15d, %esi
movl 0x20(%rsp), %edx
leaq 0x3f78(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf600, %esi           # imm = 0xF600
jmp 0xbaf1
andl $0x0, 0xc(%r14)
jmp 0xbafb
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r12), %rax
leaq 0x3f49(%rip), %rcx      # 0xfa09
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r14, %rdi
movl %r15d, %esi
movl 0x20(%rsp), %edx
leaq 0x3f1e(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x1060
movq %r12, %r14
cmpl $0x0, 0xc(%r14)
movaps 0x10(%rsp), %xmm3
je 0xbb11
addps 0x50(%rsp), %xmm3
jmp 0xb635
movl (%r14), %eax
cmpq $0xc, %rax
ja 0xbb07
leaq 0x3e63(%rip), %rcx      # 0xf984
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xea00, %esi           # imm = 0xEA00
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x16ac(%rip), %rcx      # 0xd1fe
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xea00, %esi           # imm = 0xEA00
jmp 0xbe85
movl $0xcb00, %r15d          # imm = 0xCB00
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movslq (%r14), %rax
leaq 0x3e84(%rip), %rcx      # 0xfa0e
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
movl 0x20(%rsp), %esi
movl 0x28(%rsp), %edx
leaq 0x3e5f(%rip), %rcx      # 0xfa00
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x1060
cmpl $0x2, (%r14)
jne 0xb953
callq 0x11d0
cltd
pushq $0xa
popq %rcx
idivl %ecx
cmpl $0x2, %edx
jne 0xb953
movl 0x14(%r14), %eax
cmpl $0x2, %eax
jl 0xbe9d
decl %eax
movl %eax, 0x14(%r14)
jmp 0xb953
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x3df2(%rip), %rcx      # 0xfa05
jmp 0xbd2b
movq 0x100(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0x108(%rsp), %ecx
callq 0x722c
testl %eax, %eax
js 0xbe91
movl %eax, %eax
imulq $0x30, %rax, %rax
movl 0x24(%rbx,%rax), %eax
cmpl $0x2, %eax
movl $0x1600, %ebx           # imm = 0x1600
movl $0xa600, %ecx           # imm = 0xA600
cmovel %ecx, %ebx
cmpl $0x3, %eax
movl $0xc00, %eax            # imm = 0xC00
cmovel %eax, %ebx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x1ac4(%rip), %rcx      # 0xd74a
jmp 0xbe79
movq 0xe0(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xe8(%rsp), %ecx
callq 0x71d6
testl %eax, %eax
js 0xbe91
movl %eax, %eax
imulq $0x1c, %rax, %rbx
movl 0x8(%r12,%rbx), %esi
shll $0x8, %esi
movl $0xffff, %r15d          # imm = 0xFFFF
andl %r15d, %esi
movq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x33e9(%rip), %rcx      # 0xf0d2
xorl %eax, %eax
callq 0x1070
movl 0x8(%r12,%rbx), %esi
shll $0x8, %esi
andl %r15d, %esi
movq %r14, %rdi
jmp 0xbe85
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x3cef(%rip), %rcx      # 0xfa1a
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
jmp 0xbe85
movl 0x18(%r14), %esi
testl %esi, %esi
jle 0xbb07
shll $0x8, %esi
movl $0x1500, %r15d          # imm = 0x1500
addl %r15d, %esi
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x3c84(%rip), %rcx      # 0xfa07
xorl %eax, %eax
callq 0x1070
movl 0x18(%r14), %esi
shll $0x8, %esi
addl %r15d, %esi
andl %r12d, %esi
movq %rbx, %rdi
jmp 0xbe85
movq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x7201
testl %eax, %eax
js 0xbe91
movl %eax, %eax
shlq $0x6, %rax
movl 0x30(%rbx,%rax), %eax
cmpl $0x2, %eax
movl $0x1600, %ebx           # imm = 0x1600
movl $0xa600, %ecx           # imm = 0xA600
cmovel %ecx, %ebx
cmpl $0x3, %eax
movl $0xc00, %eax            # imm = 0xC00
cmovel %eax, %ebx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x24dc(%rip), %rcx      # 0xe2e9
jmp 0xbe79
movq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x7201
testl %eax, %eax
js 0xbe91
movl %eax, %eax
shlq $0x6, %rax
movl 0x30(%rbx,%rax), %eax
cmpl $0x2, %eax
movl $0x1600, %ebx           # imm = 0x1600
movl $0xa600, %ecx           # imm = 0xA600
cmovel %ecx, %ebx
cmpl $0x3, %eax
movl $0xc00, %eax            # imm = 0xC00
cmovel %eax, %ebx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x2476(%rip), %rcx      # 0xe2ef
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
jmp 0xb72e
movl $0x1, (%r14)
jmp 0xb72e
andl $0x0, 0x14(%r14)
callq 0x11d0
cltd
pushq $0x64
popq %rcx
idivl %ecx
cmpl $0x5a, %edx
jg 0xbebe
movl $0x1, (%r14)
jmp 0xb953
movl $0x4, (%r14)
movl $0x1, 0x18(%r14)
jmp 0xb953
movl 0xd0(%rsp), %eax
cmpl $0x1, %eax
je 0xbf2b
testl %eax, %eax
jne 0xbf40
movl 0x4(%r14), %eax
testl %eax, %eax
jne 0xbf44
movl 0x14(%r14), %eax
cltd
pushq $0xa
popq %rcx
idivl %ecx
incl %r13d
incl %ebp
cmpl $0x2, %eax
je 0xbfa6
cmpl $0x1, %eax
movq 0x8(%rsp), %rbx
je 0xbf96
testl %eax, %eax
jne 0xbfb3
movl $0x1300, %r14d          # imm = 0x1300
movq %rbx, %rdi
movl $0x1300, %esi           # imm = 0x1300
jmp 0xbfc1
movl $0x100000, %r14d        # imm = 0x100000
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x100000, %esi         # imm = 0x100000
jmp 0xbf5c
movl 0x4(%r14), %eax
cmpl $0x2, %eax
jne 0xbf8b
movl $0x5300, %r14d          # imm = 0x5300
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x11c0
incl %r13d
incl %ebp
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
leaq 0x3a8c(%rip), %rcx      # 0xfa03
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1060
movl 0x38(%rsp), %eax
incl %eax
jmp 0xb5af
movl $0x1800, %r14d          # imm = 0x1800
movq %rbx, %rdi
movl $0x1800, %esi           # imm = 0x1800
jmp 0xbfc1
movl $0xef00, %r14d          # imm = 0xEF00
movq 0x8(%rsp), %rbx
jmp 0xbfb9
movl $0xef00, %r14d          # imm = 0xEF00
movq %rbx, %rdi
movl $0xef00, %esi           # imm = 0xEF00
xorl %edx, %edx
callq 0x11c0
jmp 0xbf68
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq