// File: /workspace/github_c_makefile_star2_O1/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 %r8, 0x8(%rsp)
movl %esi, 0x4c(%rsp)
movq %rdi, 0x78(%rsp)
cmpl $0x0, 0xc0(%rsp)
jle 0xcd2c
movl 0xc0(%rsp), %eax
imulq $0x38, %rax, %rax
xorl %esi, %esi
movl $0x0, 0xc(%r9,%rsi)
addq $0x38, %rsi
cmpq %rsi, %rax
jne 0xcd1a
movq %r9, 0x80(%rsp)
movq 0x110(%rsp), %rbx
cvtsi2ss %edx, %xmm1
movss 0x31b4(%rip), %xmm0     # 0xfefc
addss %xmm0, %xmm1
movss %xmm1, 0x68(%rsp)
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x64(%rsp)
xorl %eax, %eax
movl %eax, 0x74(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x3180(%rip), %xmm0     # 0xfef8
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
callq 0x10c0
movsd %xmm0, 0x50(%rsp)
movsd 0x58(%rsp), %xmm0
callq 0x1200
cmpl $0x0, 0x4c(%rsp)
jle 0xd82b
xorps %xmm2, %xmm2
cvtsd2ss 0x50(%rsp), %xmm2
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x50(%rsp)
movss 0x4aea(%rip), %xmm1     # 0x118a8
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x70(%rsp)
movss %xmm2, 0x58(%rsp)
movaps %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x6c(%rsp)
movl 0x4c(%rsp), %r15d
movss 0x68(%rsp), %xmm2
movss 0x64(%rsp), %xmm3
cvttps2dq %xmm2, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0x58(%rsp), %xmm0
movss 0x30ef(%rip), %xmm1     # 0xfef4
ucomiss %xmm0, %xmm1
jb 0xd82b
ucomiss 0x4a97(%rip), %xmm0     # 0x118ac
jb 0xd82b
cvttps2dq %xmm3, %xmm0
cvtdq2ps %xmm0, %xmm0
addss 0x50(%rsp), %xmm0
ucomiss 0x4a7d(%rip), %xmm0     # 0x118ac
jb 0xd82b
movss 0x30b3(%rip), %xmm1     # 0xfef0
ucomiss %xmm0, %xmm1
jb 0xd82b
movaps %xmm2, 0x30(%rsp)
cvttss2si %xmm2, %r13d
movaps %xmm3, 0x20(%rsp)
cvttss2si %xmm3, %ebp
movslq %r13d, %r14
movslq %ebp, %r12
cmpl $0x0, 0xd8(%rsp)
je 0xcef6
callq 0x11d0
shll $0x8, %eax
movzwl %ax, %ebx
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r14), %esi
leal 0x1(%r12), %edx
imulq $0xe38, %r14, %r14      # imm = 0xE38
addq 0x78(%rsp), %r14
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %r13
addq %r12, %r13
movslq (%r14,%r13), %rax
leaq 0x4aae(%rip), %rcx      # 0x11962
movsbl (%rax,%rcx), %r8d
movq %rbp, %rdi
leaq 0x4a91(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %rbp, %rdi
movl %ebx, %esi
movq 0x110(%rsp), %rbx
xorl %edx, %edx
callq 0x1060
movl $0x1, 0x8(%r14,%r13)
movaps 0x30(%rsp), %xmm2
movaps 0x20(%rsp), %xmm3
jmp 0xd416
imulq $0xe38, %r14, %rax      # imm = 0xE38
addq 0x78(%rsp), %rax
leaq (%r12,%r12,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %r12, %rcx
leaq (%rax,%rcx), %r14
movl 0x4(%rax,%rcx), %eax
cmpq $0x4, %rax
movq %r14, 0x18(%rsp)
ja 0xd239
leaq 0x4985(%rip), %rcx      # 0x118b0
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 0x4a09(%rip), %rcx      # 0x11962
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x49ec(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
movl $0x200000, %esi         # imm = 0x200000
jmp 0xd00e
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x11c0
movq %rbx, %rdi
movl 0x70(%rsp), %esi
movl 0x6c(%rsp), %edx
leaq 0x49ad(%rip), %rcx      # 0x11957
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
movl $0x7c00, %esi           # imm = 0x7C00
jmp 0xd00e
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 0x497a(%rip), %rcx      # 0x11962
movsbl (%rax,%rcx), %r8d
movq %rbx, %rdi
leaq 0x495d(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
movl $0x5300, %esi           # imm = 0x5300
xorl %edx, %edx
callq 0x1060
jmp 0xd239
callq 0x11d0
leal 0x1(%r13), %ebx
leal 0x1(%rbp), %r12d
testb $0x3, %al
je 0xd10c
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x11c0
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
leaq 0x40b7(%rip), %rcx      # 0x11109
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
jmp 0xd13e
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 0xd0c9
callq 0x11d0
andl $0x80000003, %eax       # imm = 0x80000003
leal 0x1(%r13), %ecx
movl %ecx, 0x14(%rsp)
leal 0x1(%rbp), %ecx
movl %ecx, 0x10(%rsp)
cmpl $0x3, %eax
jne 0xd157
movl $0xa00, %ebx            # imm = 0xA00
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xa00, %esi            # imm = 0xA00
jmp 0xd169
movl $0x0, 0x4(%r14)
movl $0x200000, %ebx         # imm = 0x200000
movq %r14, %r12
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
leal 0x1(%r13), %esi
leal 0x1(%rbp), %edx
movslq (%r12), %rax
leaq 0x4863(%rip), %rcx      # 0x11962
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
jmp 0xd190
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
leaq 0x3fda(%rip), %rcx      # 0x11109
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x1060
movq 0x110(%rsp), %rbx
movq 0x18(%rsp), %r14
jmp 0xd239
movl $0xcb00, %ebx           # imm = 0xCB00
movq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %edx, %edx
callq 0x11c0
movq 0x18(%rsp), %r12
movslq (%r12), %rax
leaq 0x47e2(%rip), %rcx      # 0x11962
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
leaq 0x47bd(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x1060
cmpl $0x2, (%r12)
movq 0x110(%rsp), %rbx
movq %r12, %r14
jne 0xd239
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 0xd239
movl 0x14(%r14), %eax
cmpl $0x2, %eax
jl 0xd1f4
decl %eax
movl %eax, 0x14(%r14)
jmp 0xd239
movl $0x0, 0x14(%r14)
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 0xd22a
movl $0x1, (%r14)
jmp 0xd239
movl $0x4, (%r14)
movl $0x1, 0x18(%r14)
movl %r15d, 0x14(%rsp)
movl $0x1, 0x8(%r14)
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0x118(%rsp), %ecx
callq 0xc2b8
testl %eax, %eax
js 0xd2c1
movq %rbx, %r12
movl %eax, %ebx
movq %r14, %r15
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 0x46dd(%rip), %rcx      # 0x11970
movsbl (%rax,%rcx), %r8d
movq %r14, %rdi
leaq 0x46b2(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
movl 0x8(%r12,%rbx), %eax
movl %eax, 0x10(%r15)
movq 0x80(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xc0(%rsp), %ecx
callq 0x57a3
testl %eax, %eax
movl 0x14(%rsp), %r15d
js 0xd38e
movl %eax, %eax
imulq $0x38, %rax, %rbx
cmpl $0x0, 0x8(%r14,%rbx)
jle 0xd38e
addq %r14, %rbx
cmpl $0x0, 0x20(%rbx)
jle 0xd38e
movq 0xc8(%rsp), %rax
movl $0x1, %ecx
movl %ecx, (%rax)
movl %ecx, 0xc(%rbx)
movl 0x20(%rbx), %eax
movq 0x18(%rsp), %r14
movl %eax, 0xc(%r14)
leal 0x1(%r13), %eax
movl %eax, 0x10(%rsp)
leal 0x1(%rbp), %eax
movl %eax, 0x48(%rsp)
cmpl %ecx, 0x24(%rbx)
jne 0xd39d
movq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0xf600, %esi           # imm = 0xF600
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r14), %rax
leaq 0x4603(%rip), %rcx      # 0x1195d
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r12, %rdi
movl 0x10(%rsp), %esi
movl 0x48(%rsp), %edx
leaq 0x45d7(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
movl $0xf600, %esi           # imm = 0xF600
jmp 0xd3ee
movq 0x18(%rsp), %r14
movl $0x0, 0xc(%r14)
jmp 0xd3f5
movq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x11c0
movslq 0xc(%r14), %rax
leaq 0x45a1(%rip), %rcx      # 0x1195d
movsbl -0x1(%rax,%rcx), %eax
leal -0x20(%rax), %r8d
cmpl $0x0, 0x28(%rbx)
cmovel %eax, %r8d
movq %r12, %rdi
movl 0x10(%rsp), %esi
movl 0x48(%rsp), %edx
leaq 0x4575(%rip), %rcx      # 0x11954
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
movl $0xf100, %esi           # imm = 0xF100
xorl %edx, %edx
callq 0x1060
movq 0x100(%rsp), %r12
cmpl $0x0, 0xc(%r14)
movq 0x110(%rsp), %rbx
movaps 0x30(%rsp), %xmm2
movaps 0x20(%rsp), %xmm3
je 0xd430
addss 0x58(%rsp), %xmm2
addss 0x50(%rsp), %xmm3
decl %r15d
jne 0xcdf0
jmp 0xd82b
movl (%r14), %eax
cmpq $0xc, %rax
ja 0xd416
leaq 0x4484(%rip), %rdx      # 0x118c4
movslq (%rdx,%rax,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
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 0x1d8d(%rip), %rcx      # 0xf1fe
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
movl $0xea00, %esi           # imm = 0xEA00
jmp 0xd566
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 0x44a4(%rip), %rcx      # 0x11959
jmp 0xd4df
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 0x448f(%rip), %rcx      # 0x1196e
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
movl $0xfe00, %esi           # imm = 0xFE00
jmp 0xd566
movl 0x18(%r14), %esi
testl %esi, %esi
jle 0xd57c
shll $0x8, %esi
movq %r13, %r15
movq %rbp, %r13
movq %r14, %rbp
movl $0x1500, %r14d          # imm = 0x1500
addl %r14d, %esi
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11c0
incl %r15d
incl %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl 0x14(%rsp), %r15d
movl %r13d, %edx
leaq 0x4413(%rip), %rcx      # 0x1195b
xorl %eax, %eax
callq 0x1070
movl 0x18(%rbp), %esi
shll $0x8, %esi
addl %r14d, %esi
andl %r12d, %esi
movq %rbx, %rdi
movq 0x110(%rsp), %rbx
xorl %edx, %edx
callq 0x1060
movaps 0x20(%rsp), %xmm3
movaps 0x30(%rsp), %xmm2
jmp 0xd416
addl $-0x5, %eax
cmpl $0x4, %eax
ja 0xd416
leaq 0x4369(%rip), %rcx      # 0x118f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xe0(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xe8(%rsp), %ecx
callq 0x8083
testl %eax, %eax
js 0xd79d
movl %eax, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rbx
addq %rax, %rbx
movl 0x8(%r12,%rbx), %esi
shll $0x8, %esi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %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 0x3a37(%rip), %rcx      # 0x11032
xorl %eax, %eax
callq 0x1070
movl 0x8(%r12,%rbx), %esi
movq 0x110(%rsp), %rbx
shll $0x8, %esi
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %esi
movq %r14, %rdi
jmp 0xd781
movq 0xf0(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x80af
testl %eax, %eax
js 0xd78d
movl %eax, %eax
shlq $0x6, %rax
movl 0x30(%r14,%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 0x2c3d(%rip), %rcx      # 0x102cd
jmp 0xd76d
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0x108(%rsp), %ecx
callq 0x80db
testl %eax, %eax
js 0xd79d
movl %eax, %eax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x24(%r12,%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 0x204a(%rip), %rcx      # 0xf74a
jmp 0xd76d
movq 0xf0(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl 0xf8(%rsp), %ecx
callq 0x80af
testl %eax, %eax
js 0xd78d
movl %eax, %eax
shlq $0x6, %rax
movl 0x30(%r14,%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 0x2b66(%rip), %rcx      # 0x102d3
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl %ebx, %esi
movq 0x110(%rsp), %rbx
xorl %edx, %edx
callq 0x1060
jmp 0xcee7
movq 0x18(%rsp), %rax
movl $0x1, (%rax)
jmp 0xcee7
movl $0x1, (%r14)
jmp 0xcee7
movl 0xd0(%rsp), %eax
cmpl $0x1, %eax
je 0xd7c5
testl %eax, %eax
jne 0xd7da
cmpl $0x0, 0x4(%r14)
je 0xd83e
cmpl $0x1, %eax
jne 0xd7da
movl $0x100000, %r14d        # imm = 0x100000
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x100000, %esi         # imm = 0x100000
jmp 0xd7f4
cmpl $0x2, 0x4(%r14)
jne 0xd82b
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 0x4148(%rip), %rcx      # 0x11957
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x1060
movq 0x110(%rsp), %rbx
movl 0x74(%rsp), %eax
incl %eax
cmpl $0x168, %eax            # imm = 0x168
jne 0xcd65
jmp 0xd8b5
movslq 0x14(%r14), %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
incl %r13d
incl %ebp
cmpl $0x2, %eax
je 0xd88e
cmpl $0x1, %eax
movq 0x8(%rsp), %rbx
je 0xd87e
testl %eax, %eax
jne 0xd89b
movl $0x1300, %r14d          # imm = 0x1300
movq %rbx, %rdi
movl $0x1300, %esi           # imm = 0x1300
jmp 0xd8a9
movl $0x1800, %r14d          # imm = 0x1800
movq %rbx, %rdi
movl $0x1800, %esi           # imm = 0x1800
jmp 0xd8a9
movl $0xef00, %r14d          # imm = 0xEF00
movq 0x8(%rsp), %rbx
jmp 0xd8a1
movl $0xef00, %r14d          # imm = 0xEF00
movq %rbx, %rdi
movl $0xef00, %esi           # imm = 0xEF00
xorl %edx, %edx
callq 0x11c0
jmp 0xd800
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq