// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/p_hud.c
// Function: BeginIntermission
void BeginIntermission (edict_t *targ)
{
	int		i, n;
	edict_t	*ent, *client;

	if (level.intermissiontime)
		return;		// already activated

	MvpDisp = 1;

    // LM_JORM -- Proclaim a victory!
    Victory();
    // END LM_JORM

	game.autosaved = false;

	// respawn any dead clients
	//bat
	//Too Many overflows!!!!!
	//for (i=0 ; i<maxclients->value ; i++)
	//{
	//	client = g_edicts + 1 + i;
	//	if (!client->inuse)
	//		continue;
	//	if (client->health <= 0)
	//	respawn(client);
	//}

	level.intermissiontime = level.time;
	level.changemap = targ->map;


	if (strstr(level.changemap, "*"))
	{
		if (coop->value)
		{
			for (i=0 ; i<maxclients->value ; i++)
			{
				client = g_edicts + 1 + i;
				if (!client->inuse)
					continue;
				// strip players of all keys between units
				for (n = 0; n < MAX_ITEMS; n++)
				{
					if (itemlist[n].flags & IT_KEY)
						client->client->pers.inventory[n] = 0;
				}
			}
		}
	}
	else
	{
		if (!deathmatch->value)
		{
			level.exitintermission = 1;		// go immediately to the next level
			return;
		}
	}

	level.exitintermission = 0;

	// find an intermission spot
	ent = G_Find (NULL, FOFS(classname), "info_player_intermission");
	if (!ent)
	{	// the map creator forgot to put in an intermission point...
		ent = G_Find (NULL, FOFS(classname), "info_player_start");
		if (!ent)
			ent = G_Find (NULL, FOFS(classname), "info_player_deathmatch");
	}
	else
	{	// chose one of four spots
		i = rand() & 3;
		while (i--)
		{
			ent = G_Find (ent, FOFS(classname), "info_player_intermission");
			if (!ent)	// wrap around the list
				ent = G_Find (ent, FOFS(classname), "info_player_intermission");
		}
	}

	VectorCopy (ent->s.origin, level.intermission_origin);
	VectorCopy (ent->s.angles, level.intermission_angle);


	// move all clients to the intermission point
	for (i=0 ; i<maxclients->value ; i++)
	{
		client = g_edicts + 1 + i;
		if (!client->inuse)
			continue;
		MoveClientToIntermission (client);
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x20869(%rip), %r15     # 0x68da0
movss 0xc8(%r15), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x487bf
jp 0x487bf
movq %rdi, %rbx
movq 0x2024c(%rip), %rax     # 0x687a8
movl $0x1, (%rax)
xorl %eax, %eax
callq 0x19530
movq 0x207d0(%rip), %rax     # 0x68d40
movl $0x0, 0x620(%rax)
movss 0x4(%r15), %xmm0
movss %xmm0, 0xc8(%r15)
movq 0x270(%rbx), %rdi
movq %rdi, 0xd0(%r15)
movl $0x2a, %esi
callq 0x18730
testq %rax, %rax
je 0x4864b
movq 0x209af(%rip), %rax     # 0x68f60
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x485c7
jnp 0x48668
movq 0x1ff62(%rip), %rax     # 0x68530
movq (%rax), %rax
movss 0x20(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x48668
movq 0x1ff72(%rip), %rcx     # 0x68558
movl $0x4a8, %eax            # imm = 0x4A8
addq (%rcx), %rax
xorl %ecx, %ecx
movq 0x20849(%rip), %rdx     # 0x68e40
addq $0x68, %rdx
imulq $0x4a8, %rcx, %rsi      # imm = 0x4A8
cmpl $0x0, 0x60(%rax,%rsi)
je 0x4863a
addq %rax, %rsi
movq %rdx, %rdi
xorl %r8d, %r8d
testb $0x10, (%rdi)
je 0x48627
movq 0x58(%rsi), %r9
movl $0x0, 0x318(%r9,%r8,4)
incq %r8
addq $0x88, %rdi
cmpq $0x100, %r8             # imm = 0x100
jne 0x48612
incq %rcx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
ucomiss %xmm1, %xmm0
ja 0x485fb
jmp 0x48668
movq 0x2086e(%rip), %rax     # 0x68ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x48668
jnp 0x487b4
movl $0x0, 0xd8(%r15)
leaq 0xfb0b(%rip), %rdx      # 0x58185
xorl %edi, %edi
movl $0x138, %esi            # imm = 0x138
callq 0x19430
testq %rax, %rax
je 0x486d1
movq %rax, %rbx
callq 0x19a10
movl %eax, %ebp
andl $0x3, %ebp
je 0x48702
leaq 0xfae4(%rip), %r14      # 0x58185
movq %rbx, %rdi
movl $0x138, %esi            # imm = 0x138
movq %r14, %rdx
callq 0x19430
movq %rax, %rbx
testq %rax, %rax
jne 0x486cb
xorl %edi, %edi
movl $0x138, %esi            # imm = 0x138
movq %r14, %rdx
callq 0x19430
movq %rax, %rbx
decl %ebp
jne 0x486a1
jmp 0x48702
leaq 0xae81(%rip), %rdx      # 0x53559
xorl %edi, %edi
movl $0x138, %esi            # imm = 0x138
callq 0x19430
movq %rax, %rbx
testq %rax, %rax
jne 0x48702
leaq 0xae4f(%rip), %rdx      # 0x53542
xorl %edi, %edi
movl $0x138, %esi            # imm = 0x138
callq 0x19430
movq %rax, %rbx
movss 0x4(%rbx), %xmm0
movss %xmm0, 0xdc(%r15)
movss 0x8(%rbx), %xmm0
movss %xmm0, 0xe0(%r15)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0xe4(%r15)
movss 0x10(%rbx), %xmm0
movss %xmm0, 0xe8(%r15)
movss 0x14(%rbx), %xmm0
movss %xmm0, 0xec(%r15)
movss 0x18(%rbx), %xmm0
movss %xmm0, 0xf0(%r15)
movq 0x1fdd3(%rip), %rbx     # 0x68530
movq (%rbx), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x487bf
movq 0x1fde4(%rip), %r14     # 0x68558
movq (%r14), %rdi
movl $0x4a8, %r15d           # imm = 0x4A8
movl $0x1, %ebp
cmpl $0x0, 0x60(%rdi,%r15)
je 0x48798
addq %r15, %rdi
callq 0x190e0
movq (%r14), %rdi
movq (%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movss 0x20(%rax), %xmm1
addq $0x4a8, %r15            # imm = 0x4A8
incl %ebp
ucomiss %xmm0, %xmm1
ja 0x48782
jmp 0x487bf
movl $0x1, 0xd8(%r15)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq