// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movl 0xddb5(%rip), %eax      # 0x1e314
pushq $0x64
popq %rcx
cltd
idivl %ecx
cmpl $0x32, %edx
jne 0x1058e
callq 0x5080
cltq
movq 0xddb8(%rip), %rcx      # 0x1e330
subq 0xdda9(%rip), %rcx      # 0x1e328
sarq $0x5, %rcx
xorl %edx, %edx
divq %rcx
movl %edx, 0xdd8e(%rip)      # 0x1e31c
movq 0xb2e4b(%rip), %rbx     # 0xc33e0
leaq 0x3ef8(%rip), %r12      # 0x14494
cmpq 0xb2e45(%rip), %rbx     # 0xc33e8
je 0x10b19
movq (%rbx), %r15
movq (%r15), %rdi
movl $0xf0, %eax
addq %rax, %rdi
leaq 0x414e(%rip), %rsi      # 0x1470c
callq 0x1143f
testb %al, %al
je 0x10603
cmpb $0x0, 0x8(%r15)
jne 0x10603
cmpb $0x0, 0x9(%r15)
jne 0x10603
movslq 0x20(%r15), %rax
movq (%rbx), %rcx
movslq 0x24(%rcx), %rcx
imulq $0x258, %rax, %rax      # imm = 0x258
leaq 0x23ce2(%rip), %rdx     # 0x342d0
addq %rdx, %rax
movss (%rax,%rcx,4), %xmm0
addss 0x3a3e(%rip), %xmm0     # 0x1403c
movss %xmm0, (%rax,%rcx,4)
cmpb $0x0, 0x1c(%r15)
jne 0x10b10
movq (%r15), %rcx
movl 0x2c(%rcx), %edx
movl 0x10(%r15), %esi
addl %edx, %esi
movl %esi, 0x10(%r15)
cmpb $0x1, 0x14(%r15)
jne 0x10693
cmpq 0x5aeb4(%rip), %r15     # 0x6b4e0
jne 0x10635
movb $0x1, 0xdced(%rip)      # 0x1e322
movl 0x18(%r15), %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(%r15)
subl %ecx, %edi
movl %edi, 0x18(%r15)
testl %eax, %eax
jne 0x106b5
cmpb $0x1, 0x8(%r15)
jne 0x1068c
leaq 0x38(%rsp), %r14
movq %r14, %rdi
leaq 0x5e8e(%rip), %rsi      # 0x16500
leaq 0x7(%rsp), %rdx
callq 0x5110
movq %r14, %rdi
callq 0x5c6e
movq %r14, %rdi
callq 0x5418
movb $0x0, 0x14(%r15)
jmp 0x106b5
cmpl $0x65, %esi
jl 0x106b5
movl 0x34(%rcx), %eax
cltd
pushq $0x46
popq %rsi
idivl %esi
addl 0x18(%r15), %eax
movl %eax, 0x18(%r15)
movl 0x34(%rcx), %ecx
cmpl %eax, %ecx
cmovll %ecx, %eax
movl %eax, 0x18(%r15)
cmpb $0x1, 0x8(%r15)
jne 0x10855
movq %rbx, 0x10(%rsp)
movl 0x10(%r15), %ebx
cmpl $0x65, %ebx
jl 0x10797
callq 0xa2ac
testb %al, %al
jne 0x10b97
callq 0xa272
testb %al, %al
je 0x10725
cmpb $0x0, 0xdc22(%rip)      # 0x1e311
jne 0x10725
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5e2b(%rip), %rsi      # 0x1652b
leaq 0x7(%rsp), %rdx
callq 0x5110
movq %rbx, %rdi
callq 0x5c6e
movq %rbx, %rdi
callq 0x5418
movb $0x1, 0xdbf0(%rip)      # 0x1e311
movl 0x10(%r15), %ebx
addl $-0x64, %ebx
movl %ebx, 0x10(%r15)
movq %r15, %rdi
callq 0xf6d4
callq 0xa210
andl $0x0, 0x40(%r15)
leaq 0xb2d13(%rip), %rdi     # 0xc3458
leaq 0x5970(%rip), %rbx      # 0x160bc
movq %rbx, %rsi
callq 0x53f0
leaq 0xb2d1d(%rip), %rdi     # 0xc3478
movq %rbx, %rsi
callq 0x53f0
movss 0x3c(%r15), %xmm0
movq (%r15), %rax
subss 0x1c(%rax), %xmm0
movss 0x18(%rax), %xmm1
maxss %xmm0, %xmm1
movss %xmm1, 0x3c(%r15)
movq 0x5ad41(%rip), %rax     # 0x6b4c8
cmpq %rax, 0x5ad42(%rip)     # 0x6b4d0
je 0x10797
movq %rax, 0x5ad39(%rip)     # 0x6b4d0
cmpb $0x0, 0xdb74(%rip)      # 0x1e312
jne 0x107e0
movl 0xdb6e(%rip), %eax      # 0x1e314
cltd
pushq $0x5
popq %rcx
idivl %ecx
testl %edx, %edx
jne 0x107e0
movslq 0x20(%r15), %rax
movslq 0x24(%r15), %rcx
imulq $0x258, %rax, %rax      # imm = 0x258
leaq 0x23b0a(%rip), %rdx     # 0x342d0
addq %rdx, %rax
movss (%rax,%rcx,4), %xmm0
addss 0x38ca(%rip), %xmm0     # 0x140a0
movss %xmm0, (%rax,%rcx,4)
callq 0x10429
movq 0x86ca1(%rip), %r15     # 0x97488
movq 0x86ca2(%rip), %rax     # 0x97490
cmpq %rax, %r15
je 0x10879
movq (%r15), %rcx
movl 0x7c(%rcx), %edx
testl %edx, %edx
jle 0x1080c
decl %edx
movl %edx, 0x7c(%rcx)
addq $0x8, %r15
jmp 0x107ee
cmpl $0x1, 0x70(%rcx)
ja 0x10823
leaq 0x86c0f(%rip), %rdi     # 0x97428
movq %r15, %rsi
callq 0x110cc
jmp 0x10841
leaq 0x86c16(%rip), %rdi     # 0x97440
movq %r15, %rsi
callq 0x110cc
movq (%r15), %rax
movl 0x88(%rax), %ecx
movl %ecx, 0x84(%rax)
leaq 0x86c40(%rip), %rdi     # 0x97488
movq %r15, %rsi
callq 0x114ba
movq %rax, %r15
jmp 0x107e7
movl 0x10(%r15), %eax
cmpb $0x1, 0x9(%r15)
jne 0x10ad1
cmpl $0x65, %eax
jl 0x10b10
addl $-0x64, %eax
movl %eax, 0x10(%r15)
jmp 0x10b10
movq 0x86bc0(%rip), %rbx     # 0x97440
cmpq 0x86bc1(%rip), %rbx     # 0x97448
je 0x10a56
movq (%rbx), %rax
movl 0x70(%rax), %ecx
addl $-0x2, %ecx
cmpl $0x3, %ecx
ja 0x10a4d
movslq (%r12,%rcx,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movq %rbx, %r15
movq (%rax), %rsi
movslq 0x20(%rsi), %rax
cmpq $-0x1f4, %rax           # imm = 0xFE0C
je 0x108d4
movslq 0x24(%rsi), %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x5ac24(%rip), %rdx     # 0x6b4f0
addq %rdx, %rax
andq $0x0, (%rax,%rcx,8)
pushq $0x9
popq %rbx
movq %r15, 0x8(%rsp)
movq %rsi, %r15
callq 0x5080
movl %eax, %ebp
callq 0x5080
movl %eax, %ecx
movl %ebp, %eax
cltd
idivl %ebx
movl %edx, %r14d
movl %ecx, %eax
cltd
idivl %ebx
movl %edx, %r13d
movq 0x8(%rsp), %rax
movq (%rax), %rax
addl $-0x4, %r14d
movl 0x90(%rax), %r12d
addl %r14d, %r12d
addl $-0x4, %r13d
movl 0x94(%rax), %ebp
addl %r13d, %ebp
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x9049
testb %al, %al
jne 0x108df
movslq %r12d, %rax
movslq %ebp, %rcx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
leaq 0x5abab(%rip), %rdx     # 0x6b4f0
addq %rdx, %rax
movq %r15, (%rax,%rcx,8)
movq 0x8(%rsp), %rbx
movq (%rbx), %rax
addl 0x90(%rax), %r14d
movl %r14d, 0x20(%r15)
addl 0x94(%rax), %r13d
movl %r13d, 0x24(%r15)
leaq 0x3b23(%rip), %r12      # 0x14494
jmp 0x10a4d
imull $0xc, 0x78(%rax), %ecx
cvtsi2ss %ecx, %xmm0
movslq 0x90(%rax), %rcx
movslq 0x94(%rax), %rax
imulq $0x258, %rcx, %rcx      # imm = 0x258
leaq 0x23936(%rip), %rdx     # 0x342d0
addq %rdx, %rcx
addss (%rcx,%rax,4), %xmm0
movss %xmm0, (%rcx,%rax,4)
callq 0x5080
cltd
pushq $0x7
popq %rcx
idivl %ecx
movq (%rbx), %rax
cmpl $0x2, %edx
jge 0x10a08
movl 0x78(%rax), %ecx
decl %ecx
movl %ecx, 0x78(%rax)
jmp 0x10a0b
movl $0x1, 0x84(%rax)
jmp 0x10a4d
movl 0x84(%rax), %ecx
cmpl $0x2, %ecx
je 0x10a1a
cmpl $0x1, %ecx
jne 0x10a4d
movl 0x90(%rax), %ebp
movl 0x94(%rax), %r14d
callq 0x5080
cltd
pushq $0x2
popq %rcx
idivl %ecx
movslq %edx, %rax
imulq $0x30, %rax, %rdx
leaq 0x5a92a(%rip), %rax     # 0x6b330
jmp 0x10a40
movl 0x78(%rax), %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
movl %ecx, 0x78(%rax)
jmp 0x10a4d
movl 0x90(%rax), %ebp
movl 0x94(%rax), %r14d
callq 0x5080
cltd
pushq $0x2
popq %rcx
idivl %ecx
movslq %edx, %rax
imulq $0x30, %rax, %rdx
leaq 0x5a950(%rip), %rax     # 0x6b390
addq %rax, %rdx
movl %ebp, %edi
movl %r14d, %esi
callq 0x92a3
addq $0x8, %rbx
jmp 0x10880
movq 0x869cb(%rip), %rbx     # 0x97428
movq 0x869cc(%rip), %rdx     # 0x97430
cmpq %rdx, %rbx
je 0x10a7f
movq (%rbx), %rdi
callq 0xf15e
movq (%rbx), %rdi
callq 0xb100
addq $0x8, %rbx
jmp 0x10a5d
movq 0x869a2(%rip), %rsi     # 0x97428
leaq 0x8699b(%rip), %rdi     # 0x97428
callq 0x114f4
movq 0x86977(%rip), %rbx     # 0x97410
movq 0x86978(%rip), %rdx     # 0x97418
cmpq %rdx, %rbx
je 0x10ab7
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0xd54a
addq $0x10, %rbx
jmp 0x10a99
movq 0x86952(%rip), %rsi     # 0x97410
leaq 0x8694b(%rip), %rdi     # 0x97410
callq 0x114fa
movq 0x10(%rsp), %rbx
jmp 0x10b10
cmpl $0x65, %eax
jl 0x10b10
addl $-0x64, %eax
movl %eax, 0x10(%r15)
cmpb $0x0, 0xd82e(%rip)      # 0x1e312
jne 0x10aee
movq %r15, %rdi
callq 0xdfa0
andl $0x0, 0x40(%r15)
movss 0x3c(%r15), %xmm0
movq (%r15), %rax
subss 0x1c(%rax), %xmm0
movss 0x18(%rax), %xmm1
maxss %xmm0, %xmm1
movss %xmm1, 0x3c(%r15)
addq $0x8, %rbx
jmp 0x1059c
callq 0x5080
movl $0xfa0, %ecx            # imm = 0xFA0
cltd
idivl %ecx
movl 0xd7e8(%rip), %eax      # 0x1e314
addl %edx, %eax
addl $0x96, %eax
cmpl %ecx, %eax
jle 0x10b86
callq 0x5080
imull $-0x6, 0xd7c9(%rip), %ecx # 0x1e30c
addl $0x4b, %ecx
cltd
idivl %ecx
testl %edx, %edx
jne 0x10b86
callq 0x90b9
movq %rax, %r15
movq %rax, %r14
shrq $0x20, %r14
callq 0x5080
cltd
pushq $0x7
popq %rcx
idivl %ecx
movq 0x5a882(%rip), %rax     # 0x6b3f0
movslq %edx, %rcx
movq 0x8(%rax,%rcx,8), %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x979c
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xd42a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x10bb0
jmp 0x10bb7
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5418
jmp 0x10bba
movq %rax, %rbx
movq %rbx, %rdi
callq 0x53c0