// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: SP_func_water
void SP_func_water (edict_t *self)
{
	vec3_t	abs_movedir;

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

	switch (self->sounds)
	{
		default:
			break;

		case 1: // water
			self->moveinfo.sound_start = gi.soundindex  ("world/mov_watr.wav");
			self->moveinfo.sound_end = gi.soundindex  ("world/stp_watr.wav");
			break;

		case 2: // lava
			self->moveinfo.sound_start = gi.soundindex  ("world/mov_watr.wav");
			self->moveinfo.sound_end = gi.soundindex  ("world/stp_watr.wav");
			break;
	}

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

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

	VectorCopy (self->pos1, self->moveinfo.start_origin);
	VectorCopy (self->s.angles, self->moveinfo.start_angles);
	VectorCopy (self->pos2, self->moveinfo.end_origin);
	VectorCopy (self->s.angles, self->moveinfo.end_angles);

	self->moveinfo.state = STATE_BOTTOM;

	if (!self->speed)
		self->speed = 25;
	self->moveinfo.accel = self->moveinfo.decel = self->moveinfo.speed = self->speed;

	if (!self->wait)
		self->wait = -1;
	self->moveinfo.wait = self->wait;

	self->use = door_use;

	if (self->wait == -1)
		self->spawnflags |= DOOR_TOGGLE;

	self->classname = "func_door";

	gi.linkentity (self);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
addq $0x10, %rdi
leaq 0x19c(%rbx), %r14
movq %r14, %rsi
callq 0x197f0
movl $0x2, 0x118(%rbx)
movl $0x3, 0x108(%rbx)
movq 0x3a727(%rip), %rax     # 0x66600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
movq %rax, %r15
callq *0x58(%rax)
movl 0x28c(%rbx), %eax
decl %eax
cmpl $0x1, %eax
ja 0x2bf18
leaq 0x25ee5(%rip), %rdi     # 0x51de2
callq *0x48(%r15)
movl %eax, 0x368(%rbx)
leaq 0x25ee7(%rip), %rdi     # 0x51df5
callq *0x48(%r15)
movl %eax, 0x370(%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 0x22ff8(%rip), %xmm2    # 0x4ef40
andps %xmm2, %xmm1
movss 0x1a0(%rbx), %xmm3
andps %xmm2, %xmm3
movss 0x1a4(%rbx), %xmm0
mulss 0x100(%rbx), %xmm3
mulss 0xfc(%rbx), %xmm1
andps %xmm2, %xmm0
addss %xmm3, %xmm1
mulss 0x104(%rbx), %xmm0
movq 0x3a6e4(%rip), %rax     # 0x66668
cvtsi2ssl 0x20(%rax), %xmm2
addss %xmm1, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x380(%rbx)
leaq 0x1b4(%rbx), %rdx
movq %r14, %rsi
callq 0x19940
movl 0x140(%rbx), %eax
movss 0x1a8(%rbx), %xmm1
movsd 0x1ac(%rbx), %xmm0
movss 0x1b4(%rbx), %xmm3
testb $0x1, %al
jne 0x2bfda
movaps %xmm0, %xmm2
movsd 0x1b8(%rbx), %xmm0
movaps %xmm3, %xmm4
jmp 0x2c011
movss %xmm3, 0x4(%rbx)
movsd 0x1b8(%rbx), %xmm2
movsd %xmm2, 0x8(%rbx)
movss %xmm1, 0x1b4(%rbx)
movlps %xmm0, 0x1b8(%rbx)
movss %xmm3, 0x1a8(%rbx)
movsd %xmm2, 0x1ac(%rbx)
movaps %xmm1, %xmm4
movaps %xmm3, %xmm1
movss %xmm1, 0x338(%rbx)
movsd 0x10(%rbx), %xmm1
movlhps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
movups %xmm2, 0x33c(%rbx)
movss 0x18(%rbx), %xmm2
movss %xmm2, 0x34c(%rbx)
movss %xmm4, 0x350(%rbx)
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movups %xmm0, 0x354(%rbx)
movss %xmm2, 0x364(%rbx)
movl $0x1, 0x388(%rbx)
movss 0x190(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x2c07d
jp 0x2c07d
movl $0x41c80000, 0x190(%rbx) # imm = 0x41C80000
movss 0x25bb3(%rip), %xmm1    # 0x51c30
movss %xmm1, 0x378(%rbx)
movss %xmm1, 0x37c(%rbx)
movss %xmm1, 0x374(%rbx)
movss 0x2f8(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x2c0a4
jnp 0x2c0c7
movss %xmm1, 0x384(%rbx)
movq 0x3a90d(%rip), %rcx     # 0x669c0
movq %rcx, 0x228(%rbx)
ucomiss 0x25b73(%rip), %xmm1    # 0x51c34
jne 0x2c0ef
jnp 0x2c0e6
jmp 0x2c0ef
movl $0xbf800000, %ecx       # imm = 0xBF800000
movl %ecx, 0x2f8(%rbx)
movl %ecx, 0x384(%rbx)
movq 0x3a8e1(%rip), %rcx     # 0x669c0
movq %rcx, 0x228(%rbx)
orl $0x20, %eax
movl %eax, 0x140(%rbx)
leaq 0x25c5c(%rip), %rax     # 0x51d52
movq %rax, 0x138(%rbx)
movq %rbx, %rdi
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
jmpq *0x90(%rax)