// File: /workspace/github_c_makefile_star2_O0/vlenhart[P]q3bsp/q3bsp.cpp
// Function: Quake3BSP::SaveEntity(EntityReference const&, _IO_FILE*, VFormatOptions&) const
void Quake3BSP::SaveEntity(const EntityReference &entity,
						   FILE *f
						   ,VFormatOptions &options
						   ) const
{
   
   std::string classname;
   std::string targetname;
   float angle = 0;
   vec3_t origin;
   // targetname	
   // model
   // dmg
   // spawnflags
   //_color
   //message
   //music
 
  ArgList args;
  
  args.Set( entity.mBody.c_str(),false); // crunch it into arguments.
  // now ready to process it as a series of arguments!

  int argi=0;
  while (argi < args.size()) 
  {
	String&  key = args[argi];
	
	argi++;

	if (key == "classname") {
		classname = args[argi];
		argi++;
	}
	else if (key == "targetname") {
		targetname = args[argi];
		argi++;
	}
	else if (key == "origin") {
		sscanf(args[argi].c_str(),"%f %f %f",&origin[0],&origin[1],&origin[2]);
		options.MapVertex(origin);
		argi++;
	}
	else if (key == "angle") {
		sscanf(args[argi].c_str(),"%f",&angle);
		angle -=90;
		angle *= (float)Q_PI/180.0f;

		argi++;
	}
	else {
		argi += 1;
	}

  }	

  //
  // info_player_intermission
  if (classname == "target_position") {
	  fprintf(f,"DEF %s Viewpoint { position %g %g %g fieldOfView 1.0 jump TRUE orientation 0 1 0 %g\n\tdescription %c%s%c }\n",targetname.c_str(),origin[0],origin[1],origin[2],angle,'"',targetname.c_str(),'"');
  }	
  if (classname == "info_player_deathmatch") {
	  fprintf(f,"Viewpoint { position %g %g %g fieldOfView 1.0 jump TRUE orientation 0 1 0 %g\n\tdescription %c%s%c }\n",origin[0],origin[1],origin[2],angle,'"',classname.c_str(),'"');
  }	
  // worldspawn	
  //misc_model .. model


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3410
leaq -0x60(%rbp), %rdi
callq 0x3410
movl $0x0, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xaa40
jmp 0x11272
movq -0x10(%rbp), %rdi
callq 0x3130
movq %rax, -0xd8(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x3500
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x92b0
jmp 0x112b1
leaq -0x88(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
xorl %edx, %edx
callq 0xaac0
jmp 0x112c8
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xb9(%rbp), %rdi
callq 0x32e0
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0xe0(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xaf90
movl %eax, -0xdc(%rbp)
jmp 0x1130a
movl -0xe0(%rbp), %eax
movl -0xdc(%rbp), %ecx
cmpl %ecx, %eax
jge 0x115e7
movl -0xc0(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0xb000
movq %rax, -0xe8(%rbp)
jmp 0x11339
movq -0xe8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0xc0(%rbp), %eax
incl %eax
movl %eax, -0xc0(%rbp)
movq -0xc8(%rbp), %rdi
leaq 0x18d83(%rip), %rsi     # 0x2a0e6
callq 0x12ff0
movb %al, -0xe9(%rbp)
jmp 0x11370
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x1137f
jmp 0x11431
movl -0xc0(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0xb000
movq %rax, -0xf8(%rbp)
jmp 0x1139a
movq -0xf8(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x3050
jmp 0x113ac
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x115e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x117b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x11409
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xb9(%rbp), %rdi
callq 0x32e0
jmp 0x117a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x117a5
movq -0xc8(%rbp), %rdi
leaq 0x18cb1(%rip), %rsi     # 0x2a0f0
callq 0x12ff0
movb %al, -0xf9(%rbp)
jmp 0x1144c
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x11458
jmp 0x11499
movl -0xc0(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0xb000
movq %rax, -0x108(%rbp)
jmp 0x11473
movq -0x108(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x3050
jmp 0x11485
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x115e0
movq -0xc8(%rbp), %rdi
leaq 0x18c54(%rip), %rsi     # 0x2a0fb
callq 0x12ff0
movb %al, -0x109(%rbp)
jmp 0x114b4
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x114c0
jmp 0x11531
movl -0xc0(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0xb000
movq %rax, -0x118(%rbp)
jmp 0x114db
movq -0x118(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
leaq -0x6c(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq 0x18c09(%rip), %rsi     # 0x2a102
xorl %eax, %eax
leaq -0x70(%rbp), %rdx
movq %rdx, -0x120(%rbp)
callq 0x3280
movq -0x120(%rbp), %rsi
movq -0x20(%rbp), %rdi
callq 0x13020
jmp 0x1151d
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x115de
movq -0xc8(%rbp), %rdi
leaq 0x18bcc(%rip), %rsi     # 0x2a10b
callq 0x12ff0
movb %al, -0x121(%rbp)
jmp 0x1154c
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x11558
jmp 0x115cd
movl -0xc0(%rbp), %esi
leaq -0x88(%rbp), %rdi
callq 0xb000
movq %rax, -0x130(%rbp)
jmp 0x11573
movq -0x130(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
leaq 0x18b7f(%rip), %rsi     # 0x2a108
leaq -0x64(%rbp), %rdx
movb $0x0, %al
callq 0x3280
movss -0x64(%rbp), %xmm0
movss 0x18623(%rip), %xmm1    # 0x29bc4
subss %xmm1, %xmm0
movss %xmm0, -0x64(%rbp)
movss 0x1860e(%rip), %xmm0    # 0x29bc0
mulss -0x64(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x115dc
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x115de
jmp 0x115e0
jmp 0x115e2
jmp 0x112ea
leaq 0x18b23(%rip), %rsi     # 0x2a111
leaq -0x40(%rbp), %rdi
callq 0x12ff0
movb %al, -0x131(%rbp)
jmp 0x115ff
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x1160e
jmp 0x116be
movq -0x18(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3130
movq %rax, -0x160(%rbp)
movss -0x70(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x158(%rbp)
movss -0x6c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x150(%rbp)
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x148(%rbp)
movss -0x64(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x140(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3130
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rdx
movsd -0x158(%rbp), %xmm0
movsd -0x150(%rbp), %xmm1
movsd -0x148(%rbp), %xmm2
movsd -0x140(%rbp), %xmm3
movq %rax, %r8
leaq 0x18a73(%rip), %rsi     # 0x2a121
movl $0x22, %r9d
movl %r9d, %ecx
movb $0x4, %al
callq 0x3430
leaq 0x18ac7(%rip), %rsi     # 0x2a18c
leaq -0x40(%rbp), %rdi
callq 0x12ff0
movb %al, -0x169(%rbp)
jmp 0x116d6
movb -0x169(%rbp), %al
testb $0x1, %al
jne 0x116e5
jmp 0x1177e
movq -0x18(%rbp), %rax
movq %rax, -0x198(%rbp)
movss -0x70(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x190(%rbp)
movss -0x6c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x188(%rbp)
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x180(%rbp)
movss -0x64(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x178(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3130
movq -0x198(%rbp), %rdi
movsd -0x190(%rbp), %xmm0
movsd -0x188(%rbp), %xmm1
movsd -0x180(%rbp), %xmm2
movsd -0x178(%rbp), %xmm3
movq %rax, %rcx
leaq 0x189ba(%rip), %rsi     # 0x2a128
movl $0x22, %r8d
movl %r8d, %edx
movb $0x4, %al
callq 0x3430
leaq -0x88(%rbp), %rdi
callq 0xae90
leaq -0x60(%rbp), %rdi
callq 0x3180
leaq -0x40(%rbp), %rdi
callq 0x3180
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x88(%rbp), %rdi
callq 0xae90
leaq -0x60(%rbp), %rdi
callq 0x3180
leaq -0x40(%rbp), %rdi
callq 0x3180
movq -0x90(%rbp), %rdi
callq 0x34f0
nop