// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: SP_func_door
void SP_func_door (edict_t *ent)
{
	vec3_t	abs_movedir;

	if (ent->sounds != 1)
	{
		ent->moveinfo.sound_start = gi.soundindex  ("doors/dr1_strt.wav");
		ent->moveinfo.sound_middle = gi.soundindex  ("doors/dr1_mid.wav");
		ent->moveinfo.sound_end = gi.soundindex  ("doors/dr1_end.wav");
	}

	G_SetMovedir (ent->s.angles, ent->movedir);
	ent->movetype = MOVETYPE_PUSH;
	ent->solid = SOLID_BSP;
	gi.setmodel (ent, ent->model);

	ent->blocked = door_blocked;
	ent->use = door_use;
	
	if (!ent->speed)
		ent->speed = 100;
	if (deathmatch->value)
		ent->speed *= 2;

	if (!ent->accel)
		ent->accel = ent->speed;
	if (!ent->decel)
		ent->decel = ent->speed;

	if (!ent->wait)
		ent->wait = 3;
	if (!st.lip)
		st.lip = 8;
	if (!ent->dmg)
		ent->dmg = 2;

	// calculate second position
	VectorCopy (ent->s.origin, ent->pos1);
	abs_movedir[0] = fabs(ent->movedir[0]);
	abs_movedir[1] = fabs(ent->movedir[1]);
	abs_movedir[2] = fabs(ent->movedir[2]);
	ent->moveinfo.distance = abs_movedir[0] * ent->size[0] + abs_movedir[1] * ent->size[1] + abs_movedir[2] * ent->size[2] - st.lip;
	VectorMA (ent->pos1, ent->moveinfo.distance, ent->movedir, ent->pos2);

	// if it starts open, switch the positions
	if (ent->spawnflags & DOOR_START_OPEN)
	{
		VectorCopy (ent->pos2, ent->s.origin);
		VectorCopy (ent->pos1, ent->pos2);
		VectorCopy (ent->s.origin, ent->pos1);
	}

	ent->moveinfo.state = STATE_BOTTOM;

	if (ent->health)
	{
		ent->takedamage = DAMAGE_YES;
		ent->die = door_killed;
		ent->max_health = ent->health;
	}
	else if (ent->targetname && ent->message)
	{
		gi.soundindex ("misc/talk.wav");
		ent->touch = door_touch;
	}
	
	ent->moveinfo.speed = ent->speed;
	ent->moveinfo.accel = ent->accel;
	ent->moveinfo.decel = ent->decel;
	ent->moveinfo.wait = ent->wait;
	VectorCopy (ent->pos1, ent->moveinfo.start_origin);
	VectorCopy (ent->s.angles, ent->moveinfo.start_angles);
	VectorCopy (ent->pos2, ent->moveinfo.end_origin);
	VectorCopy (ent->s.angles, ent->moveinfo.end_angles);

	if (ent->spawnflags & 16)
		ent->s.effects |= EF_ANIM_ALL;
	if (ent->spawnflags & 64)
		ent->s.effects |= EF_ANIM_ALLFAST;

	// to simplify logic elsewhere, make non-teamed doors into a team of one
	if (!ent->team)
		ent->teammaster = ent;

	gi.linkentity (ent);

	ent->nextthink = level.time + FRAMETIME;
	if (ent->health || ent->targetname)
		ent->think = Think_CalcMoveSpeed;
	else
		ent->think = Think_SpawnDoorTrigger;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x1, 0x28c(%rdi)
je 0x2e185
movq 0x3b4ae(%rip), %r14     # 0x69600
leaq 0x28b4d(%rip), %rdi     # 0x56ca6
callq *0x48(%r14)
movl %eax, 0x368(%rbx)
leaq 0x28b4f(%rip), %rdi     # 0x56cb9
callq *0x48(%r14)
movl %eax, 0x36c(%rbx)
leaq 0x28b50(%rip), %rdi     # 0x56ccb
callq *0x48(%r14)
movl %eax, 0x370(%rbx)
leaq 0x10(%rbx), %rdi
leaq 0x19c(%rbx), %r14
movq %r14, %rsi
callq 0x19630
movl $0x2, 0x118(%rbx)
movl $0x3, 0x108(%rbx)
movq 0x3b44d(%rip), %r15     # 0x69600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
callq *0x58(%r15)
movq 0x3b2a8(%rip), %rax     # 0x69470
movq %rax, 0x218(%rbx)
movq 0x3b7ea(%rip), %rax     # 0x699c0
movq %rax, 0x228(%rbx)
movss 0x190(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x2e1f9
jp 0x2e1f9
movl $0x42c80000, 0x190(%rbx) # imm = 0x42C80000
movq 0x3bcc0(%rip), %rax     # 0x69ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x2e20f
jnp 0x2e223
movss 0x190(%rbx), %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0x190(%rbx)
movss 0x194(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x2e245
jp 0x2e245
movss 0x190(%rbx), %xmm1
movss %xmm1, 0x194(%rbx)
movss 0x198(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x2e264
jp 0x2e264
movss 0x190(%rbx), %xmm0
movss %xmm0, 0x198(%rbx)
movss 0x2f8(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2e280
jp 0x2e280
movl $0x40400000, 0x2f8(%rbx) # imm = 0x40400000
movq 0x3b3e1(%rip), %rax     # 0x69668
cmpl $0x0, 0x20(%rax)
jne 0x2e294
movl $0x8, 0x20(%rax)
cmpl $0x0, 0x280(%rbx)
jne 0x2e2a7
movl $0x2, 0x280(%rbx)
movss 0x4(%rbx), %xmm0
leaq 0x1a8(%rbx), %rdi
movss %xmm0, 0x1a8(%rbx)
movq 0x8(%rbx), %rcx
movq %rcx, 0x1ac(%rbx)
movss 0x19c(%rbx), %xmm1
movaps 0x25c6b(%rip), %xmm2    # 0x53f40
andps %xmm2, %xmm1
movss 0x1a0(%rbx), %xmm3
andps %xmm2, %xmm3
movss 0x1a4(%rbx), %xmm0
andps %xmm2, %xmm0
mulss 0x100(%rbx), %xmm3
mulss 0xfc(%rbx), %xmm1
mulss 0x104(%rbx), %xmm0
addss %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtsi2ssl 0x20(%rax), %xmm2
addss %xmm1, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x380(%rbx)
leaq 0x1b4(%rbx), %rdx
movq %r14, %rsi
callq 0x19770
testb $0x1, 0x140(%rbx)
je 0x2e397
movss 0x1b4(%rbx), %xmm0
movss %xmm0, 0x4(%rbx)
movss 0x1b8(%rbx), %xmm1
movss %xmm1, 0x8(%rbx)
movss 0x1bc(%rbx), %xmm2
movss %xmm2, 0xc(%rbx)
movq 0x1a8(%rbx), %rax
movq %rax, 0x1b4(%rbx)
movss 0x1b0(%rbx), %xmm3
movss %xmm3, 0x1bc(%rbx)
movss %xmm0, 0x1a8(%rbx)
movss %xmm1, 0x1ac(%rbx)
movss %xmm2, 0x1b0(%rbx)
movl $0x1, 0x388(%rbx)
movl 0x254(%rbx), %eax
testl %eax, %eax
je 0x2e505
movl $0x1, 0x27c(%rbx)
movq 0x3b018(%rip), %rcx     # 0x693d8
movq %rcx, 0x238(%rbx)
movl %eax, 0x258(%rbx)
movss 0x190(%rbx), %xmm0
movss %xmm0, 0x378(%rbx)
movss 0x194(%rbx), %xmm0
movss %xmm0, 0x374(%rbx)
movss 0x198(%rbx), %xmm0
movss %xmm0, 0x37c(%rbx)
movss 0x2f8(%rbx), %xmm0
movss %xmm0, 0x384(%rbx)
movss 0x1a8(%rbx), %xmm0
movss %xmm0, 0x338(%rbx)
movq 0x1ac(%rbx), %rax
movq %rax, 0x33c(%rbx)
movss 0x10(%rbx), %xmm0
movss 0x14(%rbx), %xmm1
movss %xmm0, 0x344(%rbx)
movss %xmm1, 0x348(%rbx)
movss 0x18(%rbx), %xmm2
movss %xmm2, 0x34c(%rbx)
movss 0x1b4(%rbx), %xmm3
movss %xmm3, 0x350(%rbx)
movq 0x1b8(%rbx), %rax
movq %rax, 0x354(%rbx)
movss %xmm0, 0x35c(%rbx)
movss %xmm1, 0x360(%rbx)
movss %xmm2, 0x364(%rbx)
movl 0x140(%rbx), %eax
testb $0x10, %al
je 0x2e496
orb $0x10, 0x41(%rbx)
testb $0x40, %al
je 0x2e49e
orb $0x20, 0x41(%rbx)
cmpq $0x0, 0x168(%rbx)
jne 0x2e4af
movq %rbx, 0x2d0(%rbx)
movq %rbx, %rdi
callq *0x90(%r15)
movq 0x3b8e0(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x25dc3(%rip), %xmm0    # 0x54290
movss %xmm0, 0x200(%rbx)
cmpl $0x0, 0x254(%rbx)
jne 0x2e4f1
cmpq $0x0, 0x158(%rbx)
jne 0x2e4f1
movq 0x3b649(%rip), %rax     # 0x69b38
jmp 0x2e4f8
movq 0x3b918(%rip), %rax     # 0x69e10
movq %rax, 0x210(%rbx)
popq %rbx
popq %r14
popq %r15
retq
cmpq $0x0, 0x158(%rbx)
je 0x2e3cd
cmpq $0x0, 0x130(%rbx)
je 0x2e3cd
leaq 0x287b5(%rip), %rdi     # 0x56cdd
callq *0x48(%r15)
movq 0x3ba35(%rip), %rax     # 0x69f68
movq %rax, 0x220(%rbx)
jmp 0x2e3cd