// File: essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: ai_turn(actor*)
void ai_turn(actor* a)
{
	if(dinf(a->x,a->y,p_ptr->x,p_ptr->y) == 1)
	{
		a->ai_x = p_ptr->x; a->ai_y = p_ptr->y;
		melee_attack(a,p_ptr);
		return;
	}
	bool uncertain = true;

	if(rand()%10==0) {a->runaway_x = -500; a->runaway_y = -500;}
	bool not_scared = (a->runaway_x == -500 && a->runaway_y == -500);

	if(a->sspecies->psychic_range)
	{
		std::vector<std::pair<int,int>> psychables;
		
		for (unsigned int i=0;i<devices.size();i++)
		{
			if(devices[i]->device_type == BRAIN_SLICE && devices[i]->current_action == HUMAN_STIMULUS)
			{
				float d2 = sqrt((float)d22(a->x,a->y,devices[i]->x,devices[i]->y));
				if(d2<=(float)a->sspecies->psychic_range && randfloat() < squaref(1.0f + ((float)a->sspecies->psychic_range/6 - d2) /
					(float)(a->sspecies->psychic_range - a->sspecies->psychic_range/6)))
				{
					psychables.push_back(std::make_pair(devices[i]->x,devices[i]->y));
				}
			}
		}
		float d2 = sqrt((float)d22(a->x,a->y,p_ptr->x,p_ptr->y));
		if(d2<=(float)a->sspecies->psychic_range && randfloat() < squaref(1.0f + ((float)a->sspecies->psychic_range/6 - d2) /
			(float)(a->sspecies->psychic_range - a->sspecies->psychic_range/6)))
		{
			psychables.push_back(std::make_pair(p_ptr->x,p_ptr->y));
		}
		if (psychables.size())
		{
			std::pair<int,int> pt = psychables[rand()%psychables.size()];
			set_ai_target(a,overshoot(a->x,a->y,pt.first,pt.second));
			//a->ai_x = p_ptr->x; a->ai_y = p_ptr->y;
			uncertain = false;
			a->certain = true;
		}
	}
	if(uncertain/* && d22(a->x,a->y,p_ptr->x,p_ptr->y) <= squarei(a->sspecies->vis_range)*/)
	{
		std::vector<actor*> visible;
		if(d22(a->x,a->y,p_ptr->x,p_ptr->y) <= squarei(a->sspecies->vis_range))
		{
			if(symmetrical_los(a->x,a->y,p_ptr->x,p_ptr->y,is_opaque))
			{
				visible.push_back(p_ptr);
			}
		}
		for(unsigned int i = 0; i<holograms.size();i++)
		{
			if(d22(a->x,a->y,holograms[i]->x,holograms[i]->y) <= squarei(a->sspecies->vis_range))
			{
				if(symmetrical_los(a->x,a->y,holograms[i]->x,holograms[i]->y,is_opaque))
				{
					visible.push_back(holograms[i]);
				}
			}
		}
		if(visible.size())
		{
			actor* vis_target = visible[rand()%visible.size()];

			//if(symmetrical_los(a->x,a->y,vis_target->x,vis_target->y,is_opaque)) //already checked this once
			{
				set_ai_target(a,overshoot(a->x,a->y,vis_target->x,vis_target->y));
				if((vis_target->running ? vis_target->sspecies->run_energy : vis_target->sspecies->walk_energy) >= a->sspecies->walk_energy
					&& a->stamina > a->sspecies->stamina/4)
				{
					a->running = true;
				}
				uncertain = false;
				a->certain = true;
			}
		}
	}
	//if(uncertain && a->sspecies->hearing && rand()%10 < 3)
	//{
	//	a->ai_x = p_ptr->x; a->ai_y = p_ptr->y;
	//	uncertain = false;
	//}
	if(a->x==a->ai_x && a->y ==a->ai_y)
	{
		a->running = false;
		a->certain = false;
		if(a->sspecies->smell_clarity)
		{
			scent_walk(a); return;
		}
		random_walk(a); return;
	}
	if(!uncertain && rand()%4==0)
	{
	make_noise(a->x,a->y,&screech);
	}
	int dx = (a->x) - (a->ai_x);
	int dy = (a->y) - (a->ai_y);
	int best = d1(a->x,a->y,a->ai_x,a->ai_y)+2;
	int bestscare = d1(a->x,a->y,a->runaway_x,a->runaway_y);
	int bestdx = 0; int bestdy = 0;
	for(int d=0;d<8;d++)
	{
		std::pair<int,int> dir = directions[d];
		int ddx = dir.first; int ddy = dir.second;
		if (!terrain_immovable(a,a->x+ddx,a->y+ddy))
		{
			int dist = d1(a->x+ddx,a->y+ddy,a->ai_x,a->ai_y);
			int scaredist = d1(a->x+ddx,a->y+ddy,a->runaway_x,a->runaway_y);
			if (dist < best && (not_scared || scaredist <= bestscare))
			{best = dist; bestdx = ddx; bestdy = ddy;}
			else if (dist == best)
			{
				int ddist = dinf(a->x+ddx,a->y+ddy,a->ai_x,a->ai_y);
				int ddist2 = dinf(a->x+bestdx,a->y+bestdy,a->ai_x,a->ai_y);
				int ddistscare = dinf(a->x+ddx,a->y+ddy,a->runaway_x,a->runaway_y);
				int ddistscare2 = dinf(a->x+ddx,a->y+ddy,a->runaway_x,a->runaway_y);
				if (ddist < ddist2 && (not_scared || ddistscare >= ddistscare2))
				{best = dist; bestdx = ddx; bestdy = ddy;}
			}
		}
	}
	move_actor(a,bestdx,bestdy);
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
movq 0x6e984(%rip), %rax     # 0x88550
movl 0x20(%rax), %edx
movq 0x6e97a(%rip), %rax     # 0x88550
movl 0x24(%rax), %ecx
callq 0x218e0
cmpl $0x1, %eax
jne 0x19c26
movq 0x6e966(%rip), %rax     # 0x88550
movl 0x20(%rax), %ecx
movq 0x1c0(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x6e951(%rip), %rax     # 0x88550
movl 0x24(%rax), %ecx
movq 0x1c0(%rsp), %rax
movl %ecx, 0x2c(%rax)
movq 0x1c0(%rsp), %rdi
movq 0x6e934(%rip), %rsi     # 0x88550
callq 0x18de0
jmp 0x1a9db
movb $0x1, 0x1bf(%rsp)
callq 0x50b0
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x19c5e
movq 0x1c0(%rsp), %rax
movl $0xfffffe0c, 0x30(%rax) # imm = 0xFFFFFE0C
movq 0x1c0(%rsp), %rax
movl $0xfffffe0c, 0x34(%rax) # imm = 0xFFFFFE0C
movq 0x1c0(%rsp), %rcx
xorl %eax, %eax
cmpl $0xfffffe0c, 0x30(%rcx) # imm = 0xFFFFFE0C
movb %al, 0xf3(%rsp)
jne 0x19c91
movq 0x1c0(%rsp), %rax
cmpl $0xfffffe0c, 0x34(%rax) # imm = 0xFFFFFE0C
sete %al
movb %al, 0xf3(%rsp)
movb 0xf3(%rsp), %al
andb $0x1, %al
movb %al, 0x1be(%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, 0x20(%rax)
je 0x1a185
leaq 0x1a0(%rsp), %rdi
callq 0x20d50
movl $0x0, 0x19c(%rsp)
movl 0x19c(%rsp), %eax
movq %rax, 0xe8(%rsp)
leaq 0xc67b4(%rip), %rdi     # 0xe0498
callq 0x20b10
movq %rax, %rcx
movq 0xe8(%rsp), %rax
cmpq %rcx, %rax
jae 0x19f6d
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0xc678b(%rip), %rdi     # 0xe0498
callq 0x21440
movq (%rax), %rax
cmpl $0x5, 0x70(%rax)
jne 0x19f55
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0xc6769(%rip), %rdi     # 0xe0498
callq 0x21440
movq (%rax), %rax
cmpl $0x1, 0x84(%rax)
jne 0x19f55
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %ecx
movl %ecx, 0xd8(%rsp)
movl 0x24(%rax), %eax
movl %eax, 0xdc(%rsp)
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0xc6728(%rip), %rdi     # 0xe0498
movq %rdi, 0xd0(%rsp)
callq 0x21440
movq 0xd0(%rsp), %rdi
movq (%rax), %rax
movl 0x90(%rax), %eax
movl %eax, 0xe0(%rsp)
movl 0x19c(%rsp), %eax
movl %eax, %esi
callq 0x21440
movl 0xd8(%rsp), %edi
movl 0xdc(%rsp), %esi
movl 0xe0(%rsp), %edx
movq (%rax), %rax
movl 0x94(%rax), %ecx
callq 0x6610
cvtsi2ss %eax, %xmm0
callq 0x20a90
movss %xmm0, 0xe4(%rsp)
jmp 0x19dda
movss 0xe4(%rsp), %xmm0
movss %xmm0, 0x198(%rsp)
movss 0x198(%rsp), %xmm1
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
cvtsi2ssl 0x20(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x19f53
callq 0x6650
movss %xmm0, 0xc8(%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movslq 0x20(%rax), %rcx
movl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss 0x1322f(%rip), %xmm1    # 0x2d068
divss %xmm1, %xmm0
movss 0x198(%rsp), %xmm1
subss %xmm1, %xmm0
imulq $0x2aaaaaab, %rcx, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss 0x131a4(%rip), %xmm1    # 0x2d014
addss %xmm1, %xmm0
callq 0x21930
movss %xmm0, 0xcc(%rsp)
jmp 0x19e84
movss 0xcc(%rsp), %xmm0
movss 0xc8(%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x19f53
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0xc65e9(%rip), %rdi     # 0xe0498
movq %rdi, 0xb0(%rsp)
callq 0x21440
movq 0xb0(%rsp), %rdi
movq (%rax), %rax
addq $0x90, %rax
movq %rax, 0xb8(%rsp)
movl 0x19c(%rsp), %eax
movl %eax, %esi
callq 0x21440
movq 0xb8(%rsp), %rdi
movq (%rax), %rsi
addq $0x94, %rsi
callq 0x207c0
movq %rax, 0xc0(%rsp)
jmp 0x19f04
movq 0xc0(%rsp), %rax
movq %rax, 0x184(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x184(%rsp), %rsi
callq 0x20dc0
jmp 0x19f2b
jmp 0x19f53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x1fcd0
jmp 0x1a9e3
jmp 0x19f55
jmp 0x19f57
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x19cce
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movl 0x24(%rax), %esi
movq 0x6e5ce(%rip), %rax     # 0x88550
movl 0x20(%rax), %edx
movl 0x24(%rax), %ecx
callq 0x6610
cvtsi2ss %eax, %xmm0
callq 0x20a90
movss %xmm0, 0xac(%rsp)
jmp 0x19fa1
movss 0xac(%rsp), %xmm0
movss %xmm0, 0x180(%rsp)
movss 0x180(%rsp), %xmm1
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
cvtsi2ssl 0x20(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x1a0ac
callq 0x6650
movss %xmm0, 0xa4(%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movslq 0x20(%rax), %rcx
movl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss 0x13068(%rip), %xmm1    # 0x2d068
divss %xmm1, %xmm0
movss 0x180(%rsp), %xmm1
subss %xmm1, %xmm0
imulq $0x2aaaaaab, %rcx, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss 0x12fdd(%rip), %xmm1    # 0x2d014
addss %xmm1, %xmm0
callq 0x21930
movss %xmm0, 0xa8(%rsp)
jmp 0x1a04b
movss 0xa8(%rsp), %xmm0
movss 0xa4(%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1a0ac
movq 0x6e4e7(%rip), %rsi     # 0x88550
movq %rsi, %rdi
addq $0x20, %rdi
addq $0x24, %rsi
callq 0x207c0
movq %rax, 0x98(%rsp)
jmp 0x1a083
movq 0x98(%rsp), %rax
movq %rax, 0x178(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x20dc0
jmp 0x1a0aa
jmp 0x1a0ac
leaq 0x1a0(%rsp), %rdi
callq 0x20ef0
cmpq $0x0, %rax
je 0x1a178
callq 0x50b0
cltq
movq %rax, 0x80(%rsp)
leaq 0x1a0(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x20ef0
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movq 0x80(%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x20f10
movq (%rax), %rax
movq %rax, 0x170(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x88(%rsp)
movl 0x20(%rax), %edi
movl 0x24(%rax), %esi
movl 0x170(%rsp), %edx
movl 0x174(%rsp), %ecx
callq 0x19b10
movq %rax, 0x90(%rsp)
jmp 0x1a13f
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x168(%rsp), %rsi
callq 0x19b70
movb $0x0, 0x1bf(%rsp)
movq 0x1c0(%rsp), %rax
movb $0x1, 0x1d(%rax)
leaq 0x1a0(%rsp), %rdi
callq 0x1fcd0
testb $0x1, 0x1bf(%rsp)
je 0x1a52b
leaq 0x150(%rsp), %rdi
callq 0x20700
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movl 0x24(%rax), %esi
movq 0x6e39b(%rip), %rax     # 0x88550
movl 0x20(%rax), %edx
movl 0x24(%rax), %ecx
callq 0x6610
movl %eax, 0x70(%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movl 0x10(%rax), %edi
callq 0x21730
movl %eax, 0x74(%rsp)
jmp 0x1a1dd
movl 0x70(%rsp), %eax
movl 0x74(%rsp), %ecx
cmpl %ecx, %eax
jg 0x1a260
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movl 0x24(%rax), %esi
movq 0x6e352(%rip), %rax     # 0x88550
movl 0x20(%rax), %edx
movl 0x24(%rax), %ecx
leaq -0x6d5b(%rip), %r8      # 0x134b0
callq 0x16520
movb %al, 0x6f(%rsp)
jmp 0x1a216
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x1a220
jmp 0x1a25e
leaq 0x6e329(%rip), %rsi     # 0x88550
leaq 0x150(%rsp), %rdi
callq 0x20ce0
jmp 0x1a236
jmp 0x1a25e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x20710
jmp 0x1a9e3
jmp 0x1a260
movl $0x0, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
movq %rax, 0x60(%rsp)
leaq 0xc6202(%rip), %rdi     # 0xe0480
callq 0x21950
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jae 0x1a3e3
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %ecx
movl %ecx, 0x4c(%rsp)
movl 0x24(%rax), %eax
movl %eax, 0x50(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, %esi
leaq 0xc61c6(%rip), %rdi     # 0xe0480
movq %rdi, 0x40(%rsp)
callq 0x21970
movq 0x40(%rsp), %rdi
movq (%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x54(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, %esi
callq 0x21970
movl 0x4c(%rsp), %edi
movl 0x50(%rsp), %esi
movl 0x54(%rsp), %edx
movq (%rax), %rax
movl 0x24(%rax), %ecx
callq 0x6610
movl %eax, 0x58(%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movl 0x10(%rax), %edi
callq 0x21730
movl %eax, 0x5c(%rsp)
jmp 0x1a315
movl 0x58(%rsp), %eax
movl 0x5c(%rsp), %ecx
cmpl %ecx, %eax
jg 0x1a3cb
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0x24(%rax), %eax
movl %eax, 0x34(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, %esi
leaq 0xc6135(%rip), %rdi     # 0xe0480
movq %rdi, 0x28(%rsp)
callq 0x21970
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movl 0x20(%rax), %eax
movl %eax, 0x38(%rsp)
movl 0x14c(%rsp), %eax
movl %eax, %esi
callq 0x21970
movl 0x30(%rsp), %edi
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %edx
movq (%rax), %rax
movl 0x24(%rax), %ecx
leaq -0x6edb(%rip), %r8      # 0x134b0
callq 0x16520
movb %al, 0x3f(%rsp)
jmp 0x1a396
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x1a3a0
jmp 0x1a3c9
movl 0x14c(%rsp), %eax
movl %eax, %esi
leaq 0xc60d0(%rip), %rdi     # 0xe0480
callq 0x21970
movq %rax, %rsi
leaq 0x150(%rsp), %rdi
callq 0x20ce0
jmp 0x1a3c7
jmp 0x1a3c9
jmp 0x1a3cb
jmp 0x1a3cd
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x1a26b
leaq 0x150(%rsp), %rdi
callq 0x21950
cmpq $0x0, %rax
je 0x1a51e
callq 0x50b0
cltq
movq %rax, 0x10(%rsp)
leaq 0x150(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21950
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movq 0x10(%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x21970
movq (%rax), %rax
movq %rax, 0x140(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x20(%rax), %edi
movl 0x24(%rax), %esi
movq 0x140(%rsp), %rax
movl 0x20(%rax), %edx
movl 0x24(%rax), %ecx
callq 0x19b10
movq %rax, 0x20(%rsp)
jmp 0x1a46a
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rsi
callq 0x19b70
movq 0x140(%rsp), %rax
testb $0x1, 0x14(%rax)
je 0x1a4ab
movq 0x140(%rsp), %rax
movq (%rax), %rax
movl 0x30(%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x1a4bd
movq 0x140(%rsp), %rax
movq (%rax), %rax
movl 0x2c(%rax), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movq 0x1c0(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x2c(%rcx), %eax
jl 0x1a50a
movq 0x1c0(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, (%rsp)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movl 0x34(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl (%rsp), %eax
cmpl %ecx, %eax
jle 0x1a50a
movq 0x1c0(%rsp), %rax
movb $0x1, 0x14(%rax)
movb $0x0, 0x1bf(%rsp)
movq 0x1c0(%rsp), %rax
movb $0x1, 0x1d(%rax)
leaq 0x150(%rsp), %rdi
callq 0x20710
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x1a5b3
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x2c(%rcx), %eax
jne 0x1a5b3
movq 0x1c0(%rsp), %rax
movb $0x0, 0x14(%rax)
movq 0x1c0(%rsp), %rax
movb $0x0, 0x1d(%rax)
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movss 0x14(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1a58f
jp 0x1a58f
jmp 0x1a5a1
movq 0x1c0(%rsp), %rdi
callq 0x197e0
jmp 0x1a9db
movq 0x1c0(%rsp), %rdi
callq 0x199f0
jmp 0x1a9db
testb $0x1, 0x1bf(%rsp)
jne 0x1a5f1
callq 0x50b0
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1a5f1
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
leaq 0x6dd54(%rip), %rdx     # 0x88340
callq 0xf520
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %eax
movq 0x1c0(%rsp), %rcx
subl 0x28(%rcx), %eax
movl %eax, 0x134(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %eax
movq 0x1c0(%rsp), %rcx
subl 0x2c(%rcx), %eax
movl %eax, 0x130(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
movq 0x1c0(%rsp), %rax
movl 0x28(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x2c(%rax), %ecx
callq 0x21990
addl $0x2, %eax
movl %eax, 0x12c(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
movq 0x1c0(%rsp), %rax
movl 0x30(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x34(%rax), %ecx
callq 0x21990
movl %eax, 0x128(%rsp)
movl $0x0, 0x124(%rsp)
movl $0x0, 0x120(%rsp)
movl $0x0, 0x11c(%rsp)
cmpl $0x8, 0x11c(%rsp)
jge 0x1a9c0
movslq 0x11c(%rsp), %rcx
leaq 0x13124(%rip), %rax     # 0x2d800
movq (%rax,%rcx,8), %rax
movq %rax, 0x114(%rsp)
movl 0x114(%rsp), %eax
movl %eax, 0x110(%rsp)
movl 0x118(%rsp), %eax
movl %eax, 0x10c(%rsp)
movq 0x1c0(%rsp), %rdi
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %esi
addl 0x110(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %edx
addl 0x10c(%rsp), %edx
callq 0xef90
testb $0x1, %al
jne 0x1a9a8
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x110(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x10c(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x28(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x2c(%rax), %ecx
callq 0x21990
movl %eax, 0x108(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x110(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x10c(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x30(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x34(%rax), %ecx
callq 0x21990
movl %eax, 0x104(%rsp)
movl 0x108(%rsp), %eax
cmpl 0x12c(%rsp), %eax
jge 0x1a822
testb $0x1, 0x1be(%rsp)
jne 0x1a7f3
movl 0x104(%rsp), %eax
cmpl 0x128(%rsp), %eax
jg 0x1a822
movl 0x108(%rsp), %eax
movl %eax, 0x12c(%rsp)
movl 0x110(%rsp), %eax
movl %eax, 0x124(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, 0x120(%rsp)
jmp 0x1a9a6
movl 0x108(%rsp), %eax
cmpl 0x12c(%rsp), %eax
jne 0x1a9a4
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x110(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x10c(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x28(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x2c(%rax), %ecx
callq 0x218e0
movl %eax, 0x100(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x124(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x120(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x28(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x2c(%rax), %ecx
callq 0x218e0
movl %eax, 0xfc(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x110(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x10c(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x30(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x34(%rax), %ecx
callq 0x218e0
movl %eax, 0xf8(%rsp)
movq 0x1c0(%rsp), %rax
movl 0x20(%rax), %edi
addl 0x110(%rsp), %edi
movq 0x1c0(%rsp), %rax
movl 0x24(%rax), %esi
addl 0x10c(%rsp), %esi
movq 0x1c0(%rsp), %rax
movl 0x30(%rax), %edx
movq 0x1c0(%rsp), %rax
movl 0x34(%rax), %ecx
callq 0x218e0
movl %eax, 0xf4(%rsp)
movl 0x100(%rsp), %eax
cmpl 0xfc(%rsp), %eax
jge 0x1a9a2
testb $0x1, 0x1be(%rsp)
jne 0x1a978
movl 0xf8(%rsp), %eax
cmpl 0xf4(%rsp), %eax
jl 0x1a9a2
movl 0x108(%rsp), %eax
movl %eax, 0x12c(%rsp)
movl 0x110(%rsp), %eax
movl %eax, 0x124(%rsp)
movl 0x10c(%rsp), %eax
movl %eax, 0x120(%rsp)
jmp 0x1a9a4
jmp 0x1a9a6
jmp 0x1a9a8
jmp 0x1a9aa
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x1a6bf
movq 0x1c0(%rsp), %rdi
movl 0x124(%rsp), %esi
movl 0x120(%rsp), %edx
callq 0x17850
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x190(%rsp), %rdi
callq 0x5480