// File: /workspace/github_c_makefile_star2_O1/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 0x19630
movl $0x2, 0x118(%rbx)
movl $0x3, 0x108(%rbx)
movq 0x3ac20(%rip), %rax     # 0x69600
movq 0x120(%rbx), %rsi
movq %rbx, %rdi
movq %rax, %r15
callq *0x58(%rax)
movl 0x28c(%rbx), %eax
decl %eax
cmpl $0x1, %eax
ja 0x2ea1f
leaq 0x28306(%rip), %rdi     # 0x56d0a
callq *0x48(%r15)
movl %eax, 0x368(%rbx)
leaq 0x28308(%rip), %rdi     # 0x56d1d
callq *0x48(%r15)
movl %eax, 0x370(%rbx)
movss 0x4(%rbx), %xmm0
leaq 0x1a8(%rbx), %rdi
movss %xmm0, 0x1a8(%rbx)
movq 0x8(%rbx), %rax
movq %rax, 0x1ac(%rbx)
movss 0x19c(%rbx), %xmm1
movaps 0x254f3(%rip), %xmm2    # 0x53f40
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 0x3abdf(%rip), %rax     # 0x69668
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
movl 0x140(%rbx), %eax
testb $0x1, %al
je 0x2eb17
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), %rcx
movq %rcx, 0x1b4(%rbx)
movss 0x1b0(%rbx), %xmm3
movss %xmm3, 0x1bc(%rbx)
movss %xmm0, 0x1a8(%rbx)
movss %xmm1, 0x1ac(%rbx)
movss %xmm2, 0x1b0(%rbx)
movss 0x1a8(%rbx), %xmm0
movss %xmm0, 0x338(%rbx)
movq 0x1ac(%rbx), %rcx
movq %rcx, 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), %rcx
movq %rcx, 0x354(%rbx)
movss %xmm0, 0x35c(%rbx)
movss %xmm1, 0x360(%rbx)
movss %xmm2, 0x364(%rbx)
movl $0x1, 0x388(%rbx)
movss 0x190(%rbx), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x2ebb8
jp 0x2ebb8
movl $0x41c80000, 0x190(%rbx) # imm = 0x41C80000
movss 0x190(%rbx), %xmm1
movss 0x2f8(%rbx), %xmm2
movss %xmm1, 0x378(%rbx)
movss %xmm1, 0x37c(%rbx)
movss %xmm1, 0x374(%rbx)
ucomiss %xmm0, %xmm2
jne 0x2ebf1
jp 0x2ebf1
movl $0xbf800000, 0x2f8(%rbx) # imm = 0xBF800000
movss 0x2f8(%rbx), %xmm0
movss %xmm0, 0x384(%rbx)
movq 0x3adb8(%rip), %rcx     # 0x699c0
movq %rcx, 0x228(%rbx)
ucomiss 0x27fea(%rip), %xmm0    # 0x56c00
jne 0x2ec23
jp 0x2ec23
orl $0x20, %eax
movl %eax, 0x140(%rbx)
leaq 0x28050(%rip), %rax     # 0x56c7a
movq %rax, 0x138(%rbx)
movq %rbx, %rdi
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
jmpq *0x90(%rax)