// File: /workspace/github_c_makefile_star2_O3/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
movl %esi, 0x28(%rsp)
movq %rdi, 0x38(%rsp)
movl 0xc0(%rsp), %eax
testl %eax, %eax
jle 0xcef7
movl 0xc0(%rsp), %eax
movq %rax, %rsi
movl %esi, %eax
addl $0x3, %esi
decq %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %esi
imulq $0xe0, %rsi, %rax
movdqa 0x2251(%rip), %xmm1     # 0xf060
movdqa 0x2259(%rip), %xmm2     # 0xf070
xorl %esi, %esi
movdqa 0x225f(%rip), %xmm3     # 0xf080
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x4b8f(%rip), %xmm5     # 0x119c0
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edi
notl %edi
testb $0x1, %dil
je 0xce6f
movl $0x0, 0xc(%r9,%rsi)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edi
testb $0x1, %dil
je 0xce87
movl $0x0, 0x44(%r9,%rsi)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edi
testb $0x1, %dil
je 0xcec8
movl $0x0, 0x7c(%r9,%rsi)
pextrw $0x4, %xmm6, %edi
testb $0x1, %dil
je 0xcedf
movl $0x0, 0xb4(%r9,%rsi)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0xe0, %rsi
cmpq %rsi, %rax
jne 0xce31
movq %r8, (%rsp)
movq %r9, 0x58(%rsp)
movd %ecx, %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2ps %xmm1, %xmm0
addps 0x302a(%rip), %xmm0     # 0xff40
movaps %xmm0, 0x60(%rsp)
xorl %eax, %eax
movl %eax, 0x34(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x3008(%rip), %xmm0     # 0xff38
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
callq 0x10c0
movaps %xmm0, 0x10(%rsp)
movsd 0x40(%rsp), %xmm0
callq 0x1200
cmpl $0x0, 0x28(%rsp)
jle 0xd974
movapd 0x10(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvtpd2ps %xmm1, %xmm2
movapd %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
movaps %xmm0, 0x70(%rsp)
movss 0x4a53(%rip), %xmm1     # 0x119d0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x30(%rsp)
movaps %xmm2, 0x40(%rsp)
movaps %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x2c(%rsp)
movl 0x28(%rsp), %r15d
movaps 0x60(%rsp), %xmm3
cvttps2dq %xmm3, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0x40(%rsp), %xmm0
movss 0x2f78(%rip), %xmm1     # 0xff34
ucomiss %xmm0, %xmm1
jb 0xd974
ucomiss 0x4a08(%rip), %xmm0     # 0x119d4
jb 0xd974
movaps %xmm3, %xmm0
shufps $0x55, %xmm3, %xmm0     # xmm0 = xmm0[1,1],xmm3[1,1]
cvttps2dq %xmm0, %xmm1
cvtdq2ps %xmm1, %xmm1
addss 0x70(%rsp), %xmm1
ucomiss 0x49e7(%rip), %xmm1     # 0x119d4
jb 0xd974
movss 0x2f35(%rip), %xmm2     # 0xff30
ucomiss %xmm1, %xmm2
jb 0xd974
movaps %xmm3, 0x10(%rsp)
cvttss2si %xmm3, %r12d
cvttss2si %xmm0, %ebp
movslq %r12d, %r14
movslq %ebp, %r13
cmpl $0x0, 0xd8(%rsp)
je 0xd0a7
callq 0x11d0
shll $0x8, %eax
movzwl %ax, %ebx
movq (%rsp), %rbp
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r14), %esi
leal 0x1(%r13), %edx
imulq $0xe38, %r14, %r14      # imm = 0xE38
addq 0x38(%rsp), %r14
leaq (,%r13,8), %rax
addq %r13, %rax
leaq (%rax,%rax,2), %r12
addq %r13, %r12
movslq (%r14,%r12), %rax
leaq 0x4a04(%rip), %rcx      # 0x11a76
movsbl (%rax,%rcx), %r8d
movq %rbp, %rdi
leaq 0x49e7(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
movl $0x1, 0x8(%r14,%r12)
movaps 0x10(%rsp), %xmm3
jmp 0xd598
imulq $0xe38, %r14, %rax      # imm = 0xE38
addq 0x38(%rsp), %rax
leaq (,%r13,8), %rcx
addq %r13, %rcx
leaq (%rcx,%rcx,2), %rcx
addq %r13, %rcx
leaq (%rax,%rcx), %r13
movl 0x4(%rax,%rcx), %eax
cmpq $0x4, %rax
movq 0x110(%rsp), %r14
ja 0xd3cc
leaq 0x48f2(%rip), %rcx      # 0x119d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r12), %esi
leal 0x1(%rbp), %edx
movslq (%r13), %rax
leaq 0x4961(%rip), %rcx      # 0x11a76
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x4944(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
jmp 0xd1af
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x11c0
movq %rbx, %rdi
movl 0x30(%rsp), %esi
movl 0x2c(%rsp), %edx
leaq 0x4911(%rip), %rcx      # 0x11a6b
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
jmp 0xd1af
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r12), %esi
leal 0x1(%rbp), %edx
movslq (%r13), %rax
leaq 0x48e5(%rip), %rcx      # 0x11a76
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x48c8(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x1060
jmp 0xd3cc
callq 0x11d0
leal 0x1(%r12), %ebx
leal 0x1(%rbp), %ecx
movl %ecx, 0x8(%rsp)
testb $0x3, %al
je 0xd2ab
movq (%rsp), %r14
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x11c0
movq %r14, %rdi
movl %ebx, %esi
movl 0x8(%rsp), %edx
leaq 0x3ff2(%rip), %rcx      # 0x111e9
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
jmp 0xd2dd
callq 0x11d0
cltq
imulq $0x1b4e81b5, %rax, %rcx # imm = 0x1B4E81B5
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x12c, %ecx, %ecx      # imm = 0x12C
subl %ecx, %eax
cmpl $0x12a, %eax            # imm = 0x12A
jg 0xd26e
callq 0x11d0
andl $0x80000003, %eax       # imm = 0x80000003
leal 0x1(%r12), %ecx
movl %ecx, 0x8(%rsp)
leal 0x1(%rbp), %ecx
movl %ecx, 0xc(%rsp)
cmpl $0x3, %eax
jne 0xd2f1
movl $0xa00, %ebx            # imm = 0xA00
movq (%rsp), %r14
movq %r14, %rdi
movl $0xa00, %esi            # imm = 0xA00
jmp 0xd302
movl $0x0, 0x4(%r13)
movl $0x200000, %ebx         # imm = 0x200000
movq (%rsp), %r14
movq %r14, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r12), %esi
leal 0x1(%rbp), %edx
movslq (%r13), %rax
leaq 0x47d5(%rip), %rcx      # 0x11a76
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
jmp 0xd324
movq (%rsp), %r14
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movq %r14, %rdi
movl %ebx, %esi
movl 0x8(%rsp), %edx
leaq 0x3f1b(%rip), %rcx      # 0x111e9
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x1060
movq 0x110(%rsp), %r14
jmp 0xd3cc
movl $0xcb00, %ebx           # imm = 0xCB00
movq (%rsp), %r14
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movslq (%r13), %rax
leaq 0x4762(%rip), %rcx      # 0x11a76
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
leaq 0x473d(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
cmpl $0x2, (%r13)
movq 0x110(%rsp), %r14
jne 0xd3cc
callq 0x11d0
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cmpl $0x2, %eax
jne 0xd3cc
movl 0x14(%r13), %eax
cmpl $0x2, %eax
jl 0xd385
decl %eax
movl %eax, 0x14(%r13)
jmp 0xd3cc
movl $0x0, 0x14(%r13)
callq 0x11d0
cltq
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
cmpl $0x5a, %eax
jg 0xd3bc
movl $0x1, (%r13)
jmp 0xd3cc
movl $0x4, (%r13)
movl $0x1, 0x18(%r13)
movl $0x1, 0x8(%r13)
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0x118(%rsp), %ecx
callq 0xc3dc
testl %eax, %eax
js 0xd459
movl %eax, %ebx
movq (%rsp), %r14
movq %r14, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r12), %esi
leal 0x1(%rbp), %edx
movl %ebx, %ebx
shlq $0x5, %rbx
movq 0x110(%rsp), %rax
movslq 0x8(%rax,%rbx), %rax
leaq 0x4661(%rip), %rcx      # 0x11a84
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
leaq 0x4636(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movq 0x110(%rsp), %r14
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
movl 0x8(%r14,%rbx), %eax
movl %eax, 0x10(%r13)
movq 0x58(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0xc0(%rsp), %ecx
callq 0x5820
testl %eax, %eax
js 0xd51b
movq %rbx, %rcx
movl %eax, %eax
imulq $0x38, %rax, %rbx
cmpl $0x0, 0x8(%rcx,%rbx)
jle 0xd51b
addq %rcx, %rbx
cmpl $0x0, 0x20(%rbx)
jle 0xd51b
movq 0xc8(%rsp), %rax
movl $0x1, %ecx
movl %ecx, (%rax)
movl %ecx, 0xc(%rbx)
movl 0x20(%rbx), %eax
movl %eax, 0xc(%r13)
leal 0x1(%r12), %eax
movl %eax, 0x8(%rsp)
leal 0x1(%rbp), %eax
movl %eax, 0xc(%rsp)
cmpl %ecx, 0x24(%rbx)
jne 0xd525
movq (%rsp), %r14
movq %r14, %rdi
movl $0xf600, %esi           # imm = 0xF600
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r13), %rax
leaq 0x458a(%rip), %rcx      # 0x11a71
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
leaq 0x455e(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf600, %esi           # imm = 0xF600
jmp 0xd575
movl $0x0, 0xc(%r13)
jmp 0xd57c
movq (%rsp), %r14
movq %r14, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r13), %rax
leaq 0x452e(%rip), %rcx      # 0x11a71
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r14, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
leaq 0x4502(%rip), %rcx      # 0x11a68
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x1060
cmpl $0x0, 0xc(%r13)
movq 0x100(%rsp), %rbx
movq 0xe0(%rsp), %r14
movaps 0x10(%rsp), %xmm3
je 0xd5ab
addps 0x40(%rsp), %xmm3
decl %r15d
jne 0xcfa7
jmp 0xd974
movl (%r13), %eax
cmpq $0xc, %rax
ja 0xd598
leaq 0x4430(%rip), %rcx      # 0x119ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0xea00, %esi           # imm = 0xEA00
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x1c52(%rip), %rcx      # 0xf23e
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xea00, %esi           # imm = 0xEA00
jmp 0xd897
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x4446(%rip), %rcx      # 0x11a6d
jmp 0xd73e
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0x108(%rsp), %ecx
callq 0x825b
testl %eax, %eax
js 0xd8a3
movl %eax, %eax
leaq (%rax,%rax,2), %rax
shlq $0x4, %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 (%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x20f5(%rip), %rcx      # 0xf78a
jmp 0xd88b
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0xe8(%rsp), %ecx
callq 0x8203
testl %eax, %eax
js 0xd8a3
movl %eax, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rbx
addq %rax, %rbx
movl 0x8(%r14,%rbx), %esi
shll $0x8, %esi
movl $0xffff, %r13d          # imm = 0xFFFF
andl %r13d, %esi
movq (%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x3a1c(%rip), %rcx      # 0x11112
xorl %eax, %eax
callq 0x1070
movq 0xe0(%rsp), %rax
movl 0x8(%rax,%rbx), %esi
shll $0x8, %esi
andl %r13d, %esi
movq %r14, %rdi
jmp 0xd897
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x4344(%rip), %rcx      # 0x11a82
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
jmp 0xd897
movl 0x18(%r13), %esi
testl %esi, %esi
jle 0xd598
shll $0x8, %esi
movl $0x1500, %r14d          # imm = 0x1500
addl %r14d, %esi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %esi
movq (%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x42dc(%rip), %rcx      # 0x11a6f
xorl %eax, %eax
callq 0x1070
movl 0x18(%r13), %esi
shll $0x8, %esi
addl %r14d, %esi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %esi
movq %rbx, %rdi
jmp 0xd897
movq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x822f
testl %eax, %eax
js 0xd8a3
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 (%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x2b09(%rip), %rcx      # 0x10329
jmp 0xd88b
movq 0xf0(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x822f
testl %eax, %eax
js 0xd8a3
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 (%rsp), %r14
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x2aa4(%rip), %rcx      # 0x1032f
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
jmp 0xd09d
movl $0x1, (%r13)
jmp 0xd09d
movl 0xd0(%rsp), %eax
cmpl $0x1, %eax
je 0xd916
testl %eax, %eax
jne 0xd92a
movl 0x4(%r13), %eax
testl %eax, %eax
jne 0xd92e
movslq 0x14(%r13), %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
incl %r12d
incl %ebp
cmpl $0x2, %eax
je 0xd997
cmpl $0x1, %eax
movq (%rsp), %rbx
je 0xd987
testl %eax, %eax
jne 0xd9a3
movl $0x1300, %r14d          # imm = 0x1300
movq %rbx, %rdi
movl $0x1300, %esi           # imm = 0x1300
jmp 0xd9b1
movl $0x100000, %r14d        # imm = 0x100000
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x100000, %esi         # imm = 0x100000
jmp 0xd945
movl 0x4(%r13), %eax
cmpl $0x2, %eax
jne 0xd974
movl $0x5300, %r14d          # imm = 0x5300
movq (%rsp), %rbx
movq %rbx, %rdi
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x11c0
incl %r12d
incl %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
leaq 0x410b(%rip), %rcx      # 0x11a6b
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1060
movl 0x34(%rsp), %eax
incl %eax
cmpl $0x168, %eax            # imm = 0x168
jne 0xcf1d
jmp 0xd9ba
movl $0x1800, %r14d          # imm = 0x1800
movq %rbx, %rdi
movl $0x1800, %esi           # imm = 0x1800
jmp 0xd9b1
movl $0xef00, %r14d          # imm = 0xEF00
movq (%rsp), %rbx
jmp 0xd9a9
movl $0xef00, %r14d          # imm = 0xEF00
movq %rbx, %rdi
movl $0xef00, %esi           # imm = 0xEF00
xorl %edx, %edx
callq 0x11c0
jmp 0xd951
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq