// File: /workspace/github_c_makefile_star2_O3/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 0x2dd43
movq 0x3a8f0(%rip), %r14     # 0x68600
leaq 0x28087(%rip), %rdi     # 0x55d9e
callq *0x48(%r14)
movl %eax, 0x368(%rbx)
leaq 0x28089(%rip), %rdi     # 0x55db1
callq *0x48(%r14)
movl %eax, 0x36c(%rbx)
leaq 0x2808a(%rip), %rdi     # 0x55dc3
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 0x3a88f(%rip), %r15     # 0x68600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
callq *0x58(%r15)
movq 0x3a6ea(%rip), %rax     # 0x68470
movq %rax, 0x218(%rbx)
movq 0x3ac2c(%rip), %rax     # 0x689c0
movq %rax, 0x228(%rbx)
movss 0x190(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x2ddbf
jp 0x2ddbf
movl $0x42c80000, 0x190(%rbx) # imm = 0x42C80000
movss 0x27e8d(%rip), %xmm0    # 0x55c4c
movq 0x3b0fa(%rip), %rax     # 0x68ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2ddd5
jnp 0x2dde1
addss %xmm0, %xmm0
movss %xmm0, 0x190(%rbx)
movss 0x194(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2ddf8
jp 0x2ddf8
movss %xmm0, 0x194(%rbx)
movss 0x198(%rbx), %xmm2
ucomiss %xmm1, %xmm2
jne 0x2de0f
jp 0x2de0f
movss %xmm0, 0x198(%rbx)
movss 0x2f8(%rbx), %xmm0
ucomiss %xmm1, %xmm0
jne 0x2de28
jp 0x2de28
movl $0x40400000, 0x2f8(%rbx) # imm = 0x40400000
movq 0x3a839(%rip), %rcx     # 0x68668
movl 0x20(%rcx), %eax
testl %eax, %eax
jne 0x2de42
movl $0x8, 0x20(%rcx)
movl $0x8, %eax
cmpl $0x0, 0x280(%rbx)
jne 0x2de55
movl $0x2, 0x280(%rbx)
leaq 0x1a8(%rbx), %rdi
movsd 0x4(%rbx), %xmm0
movsd %xmm0, 0x1a8(%rbx)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x1b0(%rbx)
movss 0x19c(%rbx), %xmm1
movaps 0x250bb(%rip), %xmm2    # 0x52f40
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
cvtsi2ss %eax, %xmm2
addss %xmm1, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x380(%rbx)
leaq 0x1b4(%rbx), %rdx
movq %r14, %rsi
callq 0x19760
movl 0x140(%rbx), %eax
testb $0x1, %al
je 0x2df25
movsd 0x1b4(%rbx), %xmm0
movsd %xmm0, 0x4(%rbx)
movss 0x1bc(%rbx), %xmm1
movss %xmm1, 0xc(%rbx)
movss 0x1a8(%rbx), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movhps 0x1ac(%rbx), %xmm1      # xmm1 = xmm1[0,1],mem[0,1]
movsd %xmm0, 0x1a8(%rbx)
movups %xmm1, 0x1b0(%rbx)
movl $0x1, 0x388(%rbx)
movl 0x254(%rbx), %ecx
testl %ecx, %ecx
je 0x2e05a
movl $0x1, 0x27c(%rbx)
movq 0x3a48a(%rip), %rdx     # 0x683d8
movq %rdx, 0x238(%rbx)
movl %ecx, 0x258(%rbx)
movsd 0x190(%rbx), %xmm0
shufps $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movlps %xmm0, 0x374(%rbx)
movss 0x198(%rbx), %xmm0
movss %xmm0, 0x37c(%rbx)
movss 0x2f8(%rbx), %xmm0
movss %xmm0, 0x384(%rbx)
movsd 0x1ac(%rbx), %xmm0
movss 0x1a8(%rbx), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movss 0x10(%rbx), %xmm2
movaps %xmm2, %xmm3
shufps $0xd4, %xmm0, %xmm3     # xmm3 = xmm3[0,1],xmm0[1,3]
shufps $0x28, %xmm3, %xmm1     # xmm1 = xmm1[0,2],xmm3[2,0]
movups %xmm1, 0x338(%rbx)
movsd 0x14(%rbx), %xmm0
movaps %xmm0, %xmm1
movhps 0x1b4(%rbx), %xmm1      # xmm1 = xmm1[0,1],mem[0,1]
movups %xmm1, 0x348(%rbx)
movss 0x1bc(%rbx), %xmm1
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movups %xmm1, 0x358(%rbx)
testb $0x10, %al
je 0x2dfeb
orb $0x10, 0x41(%rbx)
testb $0x40, %al
je 0x2dff3
orb $0x20, 0x41(%rbx)
cmpq $0x0, 0x168(%rbx)
jne 0x2e004
movq %rbx, 0x2d0(%rbx)
movq %rbx, %rdi
callq *0x90(%r15)
movq 0x3ad8b(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
addss 0x2526e(%rip), %xmm0    # 0x53290
movss %xmm0, 0x200(%rbx)
cmpl $0x0, 0x254(%rbx)
jne 0x2e046
cmpq $0x0, 0x158(%rbx)
jne 0x2e046
movq 0x3aaf4(%rip), %rax     # 0x68b38
jmp 0x2e04d
movq 0x3adc3(%rip), %rax     # 0x68e10
movq %rax, 0x210(%rbx)
popq %rbx
popq %r14
popq %r15
retq
cmpq $0x0, 0x158(%rbx)
je 0x2df5b
cmpq $0x0, 0x130(%rbx)
je 0x2df5b
leaq 0x27d58(%rip), %rdi     # 0x55dd5
callq *0x48(%r15)
movq 0x3aee0(%rip), %rax     # 0x68f68
movq %rax, 0x220(%rbx)
movl 0x140(%rbx), %eax
jmp 0x2df5b