// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_runes.c
// Function: RunesRangeFromSpot
float RunesRangeFromSpot (edict_t *spot)
{
  edict_t *rune;
  float	bestrunedistance;
  vec3_t v;
  float	runedistance;
  
  
  bestrunedistance = 9999999;
  

  //-bat - This should use a function!

  rune = G_Find (spot, FOFS(classname), "damage_rune");
  if (rune)
  {
	  VectorSubtract (spot->s.origin, rune->s.origin, v);
	  runedistance = VectorLength (v);
	  
	  if (runedistance < bestrunedistance)
		  bestrunedistance = runedistance;
  }

  rune = G_Find (spot, FOFS(classname), "haste_rune");
  if (rune)
  {
	  VectorSubtract (spot->s.origin, rune->s.origin, v);
	  runedistance = VectorLength (v);
	  
	  if (runedistance < bestrunedistance)
		  bestrunedistance = runedistance;
  }

  rune = G_Find (spot, FOFS(classname), "resist_rune");
  if (rune)
  {
	  VectorSubtract (spot->s.origin, rune->s.origin, v);
	  runedistance = VectorLength (v);
	  
	  if (runedistance < bestrunedistance)
		  bestrunedistance = runedistance;
  }

  rune = G_Find (spot, FOFS(classname), "regen_rune");
  if (rune)
  {
	  VectorSubtract (spot->s.origin, rune->s.origin, v);
	  runedistance = VectorLength (v);
	  
	  if (runedistance < bestrunedistance)
		  bestrunedistance = runedistance;
  }

  
  rune = G_Find (spot, FOFS(classname), "vampire_rune");   //added by Vampire
  if (rune)                                                  
  {
	  VectorSubtract (spot->s.origin, rune->s.origin, v);
	  runedistance = VectorLength (v);
	  
	  if (runedistance < bestrunedistance)
		  bestrunedistance = runedistance;
  }



  return bestrunedistance;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq 0x3160c(%rip), %rdx     # 0x4f310
movl $0x138, %esi            # imm = 0x138
callq 0x195e0
testq %rax, %rax
je 0x1dd4e
movsd 0x4(%rbx), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rbx), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
movss 0x31548(%rip), %xmm1    # 0x4f28c
ucomiss %xmm0, %xmm1
jbe 0x1dd56
movaps %xmm0, %xmm1
jmp 0x1dd56
movss 0x31536(%rip), %xmm1    # 0x4f28c
movss %xmm1, 0xc(%rsp)
leaq 0x315b9(%rip), %rdx     # 0x4f31c
movq %rbx, %rdi
movl $0x138, %esi            # imm = 0x138
callq 0x195e0
testq %rax, %rax
je 0x1ddaf
movsd 0x4(%rbx), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rbx), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1ddaf
movss %xmm0, 0xc(%rsp)
leaq 0x31571(%rip), %rdx     # 0x4f327
movq %rbx, %rdi
movl $0x138, %esi            # imm = 0x138
callq 0x195e0
testq %rax, %rax
je 0x1de02
movsd 0x4(%rbx), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rbx), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1de02
movss %xmm0, 0xc(%rsp)
leaq 0x3152a(%rip), %rdx     # 0x4f333
movq %rbx, %rdi
movl $0x138, %esi            # imm = 0x138
callq 0x195e0
testq %rax, %rax
je 0x1de55
movsd 0x4(%rbx), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rbx), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1de55
movss %xmm0, 0xc(%rsp)
leaq 0x314e2(%rip), %rdx     # 0x4f33e
movq %rbx, %rdi
movl $0x138, %esi            # imm = 0x138
callq 0x195e0
testq %rax, %rax
je 0x1dea7
movsd 0x4(%rbx), %xmm0
movsd 0x4(%rax), %xmm1
subps %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movlps %xmm0, (%rdi)
movss 0xc(%rbx), %xmm0
subss 0xc(%rax), %xmm0
movss %xmm0, 0x8(%rdi)
callq 0x19460
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1dead
movaps %xmm0, %xmm1
jmp 0x1dead
movss 0xc(%rsp), %xmm1
movaps %xmm1, %xmm0
addq $0x20, %rsp
popq %rbx
retq