// File: /workspace/github_cpp_makefile_star2_O3/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: play_turn()
int play_turn()
{
		if(turn_count%100 == 50)
		{
			current_advice = rand()%vadvice.size();
		}
		for(std::vector<actor*>::iterator a = actors.begin(); a != actors.end(); ++a)
		{
			actor* act = (*a);
			if (act->sspecies->name == "human" && !act->is_player && !act->is_hologram)
			{
				map_human_scent[act->x][(*a)->y] += 0.7f; //non-player humans get an easier time >:)
			}
			if(!act->dead)
			{
				act->energy += act->sspecies->walk_energy;
				if(act->running)
				{
					if(act == p_ptr) ran = true;
					int stamina_consumed = (act->stamina * (act->sspecies->run_energy - act->sspecies->walk_energy))/act->sspecies->stamina;
					act->energy += std::min(stamina_consumed,act->stamina);
					act->stamina -=  std::min(stamina_consumed,act->stamina);
					if (stamina_consumed == 0)
					{
						if(act->is_player)
						{
							add_message("You are too exhausted to continue running.");
						}
						act->running = false;
					}
				}
				else if(act->energy > 100)
				{
					act->stamina += act->sspecies->stamina/70;
					act->stamina = std::min(act->stamina,act->sspecies->stamina);
				}
				if (act->is_player)
				{
					if(act->energy > 100)
					{
						if(win_condition())
						{
							win();
							
						}
						if(door_closable() && !door_closable_told)
						{
							add_message("Press 'C' to tell the computer to close the door (you can't take off with aliens in the ship, though).");
							door_closable_told = true;
						}
						act->energy -= 100;
						player_turn(act);
						check_achievements();

						act->most_noticeable_sound = 0.0;
						sound_this_turn = "";
						dir_this_turn = "";
						act->sound_threshold = std::max(act->sound_threshold-act->sspecies->hearing_adapt,act->sspecies->hearing_thres);

						visible_actors.clear();
					}
					if(!debug && !(turn_count %5))
					{
						map_human_scent[act->x][act->y] += 1000.0;
						diffuse_scent_human();
					}
					for(std::vector<item*>::iterator dev = timer_devices.begin(); dev != timer_devices.end();)
					{
						if((*dev)->time_remaining > 0)
						{
							(*dev)->time_remaining -= 1;
							++dev;
							//next_timer_devices.push_back(*dev);
						}
						else
						{
							if((*dev)->device_type == LOW_EXPLOSIVE || (*dev)->device_type == HIGH_EXPLOSIVE)
							{
								explode_this_turn.push_back(*dev);
							}
							else
							{
								active_devices.push_back(*dev);
								(*dev)->current_action = (*dev)->next_action;
							}
							dev = timer_devices.erase(dev);
						}
					}
					for(std::vector<item*>::iterator dev = active_devices.begin(); dev != active_devices.end(); ++dev)
					{
						if((*dev)->device_type == SCENT_GENERATOR)
						{
							map_human_scent[(*dev)->x][(*dev)->y] += ((*dev)->power_remaining*1200)/100;
							if(rand()%7 < 2) (*dev)->power_remaining -= 1;
							(*dev)->power_remaining = std::max(0,(*dev)->power_remaining);
						}
						else if((*dev)->device_type == HOLOGRAM_PROJECTOR)
						{
							actor* pr = (*dev)->projection;
							if(pr->x != -500)
							{
								map_occupants[pr->x][pr->y] = NULL;
							}
							int x = rand()%9;
							int y = rand()%9;
							while(terrain_immovable(pr,(*dev)->x+x-4,(*dev)->y+y-4))
							{
								x = rand()%9;
								y = rand()%9;
							}
							map_occupants[(*dev)->x+x-4][(*dev)->y+y-4] = pr;
							pr->x = (*dev)->x+x-4;
							pr->y = (*dev)->y+y-4;
							

						}
						else if((*dev)->device_type == NOISE_GENERATOR)
						{
							if((*dev)->current_action == HUMAN_STIMULUS)
							{
							make_noise((*dev)->x,(*dev)->y,&fake_human_noise[rand()%2]);
							}
							else if((*dev)->current_action == LOUD_STIMULUS)
							{
								make_noise((*dev)->x,(*dev)->y,&generator_loud[rand()%2]);
							}
						}
						else if((*dev)->device_type == BRAIN_SLICE)
						{
							(*dev)->current_action = HUMAN_STIMULUS;
						}
					}
					for(std::vector<item*>::iterator dev = explode_this_turn.begin(); dev != explode_this_turn.end(); ++dev)
					{
						set_unconfigured(*dev);
						//remove(timer_devices.begin(),timer_devices.end(),*dev);
						activate_device(*dev);
					}
					explode_this_turn.erase(explode_this_turn.begin(),explode_this_turn.end());
					for(std::vector<explosion>::iterator ex = explosions_this_turn.begin(); ex != explosions_this_turn.end(); ex++)
					{
						do_explosion(*ex);
					}
					explosions_this_turn.erase(explosions_this_turn.begin(),explosions_this_turn.end());
				}
				else if (act->is_hologram)
				{
					if(act->energy > 100)
					{
						act->energy -= 100;
						if(on_map(act->x,act->y))
							hologram_turn(act);
					}
				}
				else
				{
					if(act->energy > 100)
					{
						act->energy -= 100;
						if(!debug)
						{
						ai_turn(act);
						}
						act->most_noticeable_sound = 0.0;
						act->sound_threshold = std::max(act->sound_threshold-act->sspecies->hearing_adapt,act->sspecies->hearing_thres);
					}
				}
			}
		}
		if(rand()%4000+150+turn_count >4000 && rand()%(45-6*(difficulty-5)) == 0)
		{
			std::pair<int,int> loc = random_occupiable_square_away_from_player();

			add_actor(zoo[rand()%ZOO_SIZE+1],false,loc.first,loc.second);
		}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movslq 0xc49f(%rip), %rax      # 0x21314
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 $0x32, %eax
jne 0x14eb7
callq 0x5070
cltq
movq 0xc48f(%rip), %rcx      # 0x21330
subq 0xc480(%rip), %rcx      # 0x21328
sarq $0x5, %rcx
xorl %edx, %edx
divq %rcx
movl %edx, 0xc465(%rip)      # 0x2131c
movq 0xb1522(%rip), %r12     # 0xc63e0
cmpq 0xb1523(%rip), %r12     # 0xc63e8
je 0x15580
leaq 0x18(%rsp), %r15
movl $0xf0, %r14d
leaq 0x3617(%rip), %r13      # 0x184f4
movq (%r12), %rbp
movq (%rbp), %rdi
addq %r14, %rdi
leaq 0x38c4(%rip), %rsi      # 0x187b3
callq 0x5090
testl %eax, %eax
jne 0x14f33
cmpb $0x0, 0x8(%rbp)
jne 0x14f33
cmpb $0x0, 0x9(%rbp)
jne 0x14f33
movslq 0x20(%rbp), %rax
movq (%r12), %rcx
movslq 0x24(%rcx), %rcx
imulq $0x258, %rax, %rax      # imm = 0x258
leaq 0x223b2(%rip), %rdx     # 0x372d0
addq %rdx, %rax
movss (%rax,%rcx,4), %xmm0
addss 0x310e(%rip), %xmm0     # 0x1803c
movss %xmm0, (%rax,%rcx,4)
cmpb $0x0, 0x1c(%rbp)
je 0x14f4b
addq $0x8, %r12
cmpq 0xb14a4(%rip), %r12     # 0xc63e8
jne 0x14edd
jmp 0x15580
movq (%rbp), %rcx
movl 0x2c(%rcx), %edx
movl 0x10(%rbp), %esi
addl %edx, %esi
movl %esi, 0x10(%rbp)
cmpb $0x1, 0x14(%rbp)
jne 0x14fd7
cmpq 0x59579(%rip), %rbp     # 0x6e4e0
jne 0x14f70
movb $0x1, 0xc3b2(%rip)      # 0x21322
movl 0x18(%rbp), %edi
movl 0x30(%rcx), %eax
subl %edx, %eax
imull %edi, %eax
cltd
idivl 0x34(%rcx)
cmpl %eax, %edi
movl %eax, %ecx
cmovll %edi, %ecx
addl %ecx, %esi
movl %esi, 0x10(%rbp)
subl %ecx, %edi
movl %edi, 0x18(%rbp)
testl %eax, %eax
jne 0x15008
cmpb $0x1, 0x8(%rbp)
jne 0x14fd1
movq %r15, 0x8(%rsp)
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x55f9(%rip), %rsi      # 0x1a5a7
leaq 0x561c(%rip), %rdx      # 0x1a5d1
callq 0x15b1a
movq %rbx, %rdi
callq 0x5f0e
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x14fd1
callq 0x5230
movb $0x0, 0x14(%rbp)
jmp 0x15008
cmpl $0x65, %esi
jl 0x15008
movslq 0x34(%rcx), %rax
imulq $-0x15f15f15, %rax, %rdx # imm = 0xEA0EA0EB
shrq $0x20, %rdx
addl %eax, %edx
movl %edx, %eax
shrl $0x1f, %eax
sarl $0x6, %edx
addl %eax, %edx
addl 0x18(%rbp), %edx
movl %edx, 0x18(%rbp)
movl 0x34(%rcx), %eax
cmpl %edx, %eax
cmovll %eax, %edx
movl %edx, 0x18(%rbp)
cmpb $0x1, 0x8(%rbp)
jne 0x15237
movl 0x10(%rbp), %r14d
cmpl $0x65, %r14d
jl 0x15112
callq 0xc55c
testb %al, %al
jne 0x1563c
callq 0xc522
testb %al, %al
je 0x15086
cmpb $0x0, 0xc2d4(%rip)      # 0x21311
jne 0x15086
leaq 0x38(%rsp), %r14
movq %r14, 0x28(%rsp)
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
leaq 0x557a(%rip), %rsi      # 0x1a5d2
leaq 0x55d9(%rip), %rdx      # 0x1a638
callq 0x15b1a
movq %rbx, %rdi
callq 0x5f0e
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x1507b
callq 0x5230
movb $0x1, 0xc28f(%rip)      # 0x21311
movl 0x10(%rbp), %r14d
addl $-0x64, %r14d
movl %r14d, 0x10(%rbp)
movq %rbp, %rdi
callq 0x13ddd
callq 0xc4c0
movl $0x0, 0x40(%rbp)
movq 0xb13b7(%rip), %rdx     # 0xc6460
leaq 0xb13a8(%rip), %rdi     # 0xc6458
xorl %esi, %esi
leaq 0x50aa(%rip), %rbx      # 0x1a163
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x5380
movq 0xb13b5(%rip), %rdx     # 0xc6480
leaq 0xb13a6(%rip), %rdi     # 0xc6478
xorl %esi, %esi
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x5380
movss 0x3c(%rbp), %xmm0
movq (%rbp), %rax
subss 0x1c(%rax), %xmm0
movss 0x18(%rax), %xmm1
maxss %xmm0, %xmm1
movss %xmm1, 0x3c(%rbp)
movq 0x593c6(%rip), %rax     # 0x6e4c8
cmpq %rax, 0x593c7(%rip)     # 0x6e4d0
je 0x15112
movq %rax, 0x593be(%rip)     # 0x6e4d0
cmpb $0x0, 0xc1f9(%rip)      # 0x21312
jne 0x15161
imull $0xcccccccd, 0xc1ef(%rip), %eax # imm = 0xCCCCCCCD
addl $0x19999999, %eax       # imm = 0x19999999
cmpl $0x33333332, %eax       # imm = 0x33333332
ja 0x15161
movslq 0x20(%rbp), %rax
movslq 0x24(%rbp), %rcx
imulq $0x258, %rax, %rax      # imm = 0x258
leaq 0x22189(%rip), %rdx     # 0x372d0
addq %rdx, %rax
movss (%rax,%rcx,4), %xmm0
addss 0x2f4d(%rip), %xmm0     # 0x180a4
movss %xmm0, (%rax,%rcx,4)
callq 0x14d4b
movq %r12, (%rsp)
movq 0x8531c(%rip), %rbp     # 0x9a488
movq 0x8531d(%rip), %rdx     # 0x9a490
cmpq %rdx, %rbp
je 0x15258
movq (%rbp), %rax
movl 0x7c(%rax), %ecx
testl %ecx, %ecx
jle 0x15192
decl %ecx
movl %ecx, 0x7c(%rax)
addq $0x8, %rbp
jmp 0x15173
cmpl $0x1, 0x70(%rax)
ja 0x151b5
movq 0x85291(%rip), %rsi     # 0x9a430
cmpq 0x85292(%rip), %rsi     # 0x9a438
je 0x151d2
movq %rax, (%rsi)
addq $0x8, 0x8527d(%rip)     # 0x9a430
jmp 0x15202
movq 0x8528c(%rip), %rsi     # 0x9a448
cmpq 0x8528d(%rip), %rsi     # 0x9a450
je 0x151e3
movq %rax, (%rsi)
addq $0x8, 0x85278(%rip)     # 0x9a448
jmp 0x151f2
leaq 0x8524f(%rip), %rdi     # 0x9a428
movq %rbp, %rdx
callq 0x1658c
jmp 0x15202
leaq 0x85256(%rip), %rdi     # 0x9a440
movq %rbp, %rdx
callq 0x1658c
movq (%rbp), %rax
movl 0x88(%rax), %ecx
movl %ecx, 0x84(%rax)
movq %rbp, %rsi
addq $0x8, %rsi
movq 0x85280(%rip), %rdx     # 0x9a490
cmpq %rdx, %rsi
je 0x15227
subq %rsi, %rdx
movq %rbp, %rdi
callq 0x53b0
movq 0x85269(%rip), %rdx     # 0x9a490
addq $-0x8, %rdx
movq %rdx, 0x8525e(%rip)     # 0x9a490
jmp 0x15173
movl 0x10(%rbp), %eax
cmpb $0x1, 0x9(%rbp)
jne 0x15538
cmpl $0x65, %eax
jl 0x14f39
addl $-0x64, %eax
movl %eax, 0x10(%rbp)
jmp 0x14f39
movq 0x851e1(%rip), %r12     # 0x9a440
cmpq 0x851e2(%rip), %r12     # 0x9a448
je 0x1548c
movq (%r12), %rax
movl 0x70(%rax), %ecx
addl $-0x2, %ecx
cmpl $0x3, %ecx
ja 0x15483
movslq (%r13,%rcx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movq (%rax), %rbp
movslq 0x20(%rbp), %rax
cmpq $-0x1f4, %rax           # imm = 0xFE0C
je 0x152b5
movslq 0x24(%rbp), %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x59246(%rip), %rdx     # 0x6e4f0
addq %rdx, %rax
movq $0x0, (%rax,%rcx,8)
callq 0x5070
movl %eax, %r14d
callq 0x5070
movslq %r14d, %rcx
imulq $0x38e38e39, %rcx, %rdx # imm = 0x38E38E39
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x21, %rdx
addl %esi, %edx
leal (%rdx,%rdx,8), %edx
cltq
imulq $0x38e38e39, %rax, %rsi # imm = 0x38E38E39
movq %rsi, %rdi
shrq $0x3f, %rdi
sarq $0x21, %rsi
addl %edi, %esi
leal (%rsi,%rsi,8), %esi
movq (%r12), %rdi
negl %edx
leal (%rcx,%rdx), %ebx
addl $-0x4, %ebx
movl 0x90(%rdi), %r15d
addl %ebx, %r15d
negl %esi
leal (%rax,%rsi), %r13d
addl $-0x4, %r13d
movl 0x94(%rdi), %r14d
addl %r13d, %r14d
movq %rbp, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0xafef
testb %al, %al
jne 0x152b5
movslq %r15d, %rax
movslq %r14d, %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x591ab(%rip), %rdx     # 0x6e4f0
addq %rdx, %rax
movq %rbp, (%rax,%rcx,8)
movq (%r12), %rax
addl 0x90(%rax), %ebx
movl %ebx, 0x20(%rbp)
addl 0x94(%rax), %r13d
movl %r13d, 0x24(%rbp)
leaq 0x3189(%rip), %r13      # 0x184f4
jmp 0x15483
movl 0x78(%rax), %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movslq 0x90(%rax), %rcx
movslq 0x94(%rax), %rax
imulq $0x258, %rcx, %rcx      # imm = 0x258
leaq 0x21f34(%rip), %rdx     # 0x372d0
addq %rdx, %rcx
addss (%rcx,%rax,4), %xmm0
movss %xmm0, (%rcx,%rax,4)
callq 0x5070
cltq
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movq (%r12), %rax
cmpl $0x2, %ecx
jge 0x15435
movl 0x78(%rax), %ecx
decl %ecx
movl %ecx, 0x78(%rax)
jmp 0x15438
movl $0x1, 0x84(%rax)
jmp 0x15483
movl 0x84(%rax), %ecx
cmpl $0x2, %ecx
je 0x15447
cmpl $0x1, %ecx
jne 0x15483
movl 0x90(%rax), %ebp
movl 0x94(%rax), %r14d
callq 0x5070
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
subl %ecx, %eax
cltq
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
leaq 0x58efd(%rip), %rax     # 0x6e330
jmp 0x15476
movl 0x78(%rax), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
movl %ecx, 0x78(%rax)
jmp 0x15483
movl 0x90(%rax), %ebp
movl 0x94(%rax), %r14d
callq 0x5070
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
subl %ecx, %eax
cltq
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
leaq 0x58f1a(%rip), %rax     # 0x6e390
addq %rax, %rdx
movl %ebp, %edi
movl %r14d, %esi
callq 0xb2bd
addq $0x8, %r12
jmp 0x1525f
movq 0x84f95(%rip), %r14     # 0x9a428
cmpq 0x84f96(%rip), %r14     # 0x9a430
leaq 0x18(%rsp), %r15
movq (%rsp), %r12
je 0x154e9
movq (%r14), %rdi
callq 0x135a3
movq (%r14), %rdi
movl 0x70(%rdi), %eax
movl 0x88(%rdi), %ecx
movl %ecx, 0x84(%rdi)
cmpl $0x1, %eax
ja 0x154c9
callq 0xd9fd
addq $0x8, %r14
cmpq 0x84f5c(%rip), %r14     # 0x9a430
jne 0x154a5
movq 0x84f4b(%rip), %rax     # 0x9a428
cmpq %rax, %r14
je 0x154e9
movq %rax, 0x84f47(%rip)     # 0x9a430
movq 0x84f20(%rip), %rbx     # 0x9a410
cmpq 0x84f21(%rip), %rbx     # 0x9a418
movl $0xf0, %r14d
je 0x14f39
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x10fa9
addq $0x10, %rbx
cmpq 0x84efe(%rip), %rbx     # 0x9a418
jne 0x15503
movq 0x84eed(%rip), %rax     # 0x9a410
cmpq %rax, %rbx
je 0x14f39
movq %rax, 0x84ee5(%rip)     # 0x9a418
jmp 0x14f39
cmpl $0x65, %eax
jl 0x14f39
addl $-0x64, %eax
movl %eax, 0x10(%rbp)
cmpb $0x0, 0xbdc4(%rip)      # 0x21312
jne 0x15558
movq %rbp, %rdi
callq 0x11e0b
movl $0x0, 0x40(%rbp)
movss 0x3c(%rbp), %xmm0
movq (%rbp), %rax
subss 0x1c(%rax), %xmm0
movss 0x18(%rax), %xmm1
maxss %xmm0, %xmm1
movss %xmm1, 0x3c(%rbp)
jmp 0x14f39
callq 0x5070
cltq
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x28, %rcx
addl %edx, %ecx
imull $0xfa0, %ecx, %ecx      # imm = 0xFA0
subl %ecx, %eax
movl 0xbd6b(%rip), %ecx      # 0x21314
addl %ecx, %eax
addl $0x96, %eax
cmpl $0xfa0, %eax            # imm = 0xFA0
jle 0x1562b
callq 0x5070
movl 0xbd4a(%rip), %ecx      # 0x2130c
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ecx
movl $0x4b, %esi
subl %ecx, %esi
cltd
idivl %esi
testl %edx, %edx
jne 0x1562b
callq 0xb05f
movq %rax, %rbx
movq %rax, %r14
shrq $0x20, %r14
callq 0x5070
cltq
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movq 0x58ddc(%rip), %rax     # 0x6e3f0
movslq %ecx, %rcx
movq 0x8(%rax,%rcx,8), %rdi
xorl %esi, %esi
movl %ebx, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0xb8a5
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x10e63
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
jne 0x1565d
jmp 0x15662
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15662
callq 0x5230
movq %rbx, %rdi
callq 0x53d0