// File: /workspace/github_c_makefile_star2_O3/vlenhart[P]q3bsp/vformat.cpp
// Function: VertexSection::SaveVRML(_IO_FILE*, bool)
void VertexSection::SaveVRML(FILE *fph,bool tex1)
{
  // save it into a VRML file!
  static int itemcount=1;

  fprintf(fph,"DEF item%d Separator {\n",itemcount++);
  fprintf(fph,"Translation { translation 0 0 0 }\n");
  fprintf(fph,"Material {\n");
  fprintf(fph,"  ambientColor 0.1791 0.06536 0.06536\n");
  fprintf(fph,"  diffuseColor 0.5373 0.1961 0.1961\n");
  fprintf(fph,"  specularColor 0.9 0.9 0.9\n");
  fprintf(fph,"  shininess 0.25\n");
  fprintf(fph,"  transparency 0\n");
  fprintf(fph,"}\n");
  fprintf(fph,"Texture2 {\n");


  const char *foo = mName;
  char scratch[256];

  if ( !tex1 )
  {
    while ( *foo && *foo != '+' ) foo++;
    char *dest = scratch;
    if ( *foo == '+' )
    {
      foo++;
      while ( *foo ) *dest++ = *foo++;
    }
    *dest = 0;
  }
  else
  {
    char *dest = scratch;
    while ( *foo && *foo != '+' ) *dest++ = *foo++;
    *dest = 0;
  }

  if ( tex1 )
    fprintf(fph,"  filename %c%s.tga%c\n",0x22,scratch,0x22);
  else
    fprintf(fph,"  filename %c%s.bmp%c\n",0x22,scratch,0x22);

  fprintf(fph,"}\n");

  mPoints.SaveVRML(fph,tex1);

  int tcount = mIndices.size()/3;

  if ( 1 )
  {
    fprintf(fph,"  IndexedFaceSet {\ncoordIndex [\n");
    UShortVector::iterator j= mIndices.begin();
    for (int i=0; i<tcount; i++)
    {
      int i1 = *j;
      j++;
      int i2 = *j;
      j++;
      int i3 = *j;
      j++;
      if ( i == (tcount-1) )
        fprintf(fph,"  %d, %d, %d, -1]\n",i1,i2,i3);
      else
        fprintf(fph,"  %d, %d, %d, -1,\n",i1,i2,i3);
    }
  }

  if ( 1 )
  {
    fprintf(fph,"  textureCoordIndex [\n");
    UShortVector::iterator j= mIndices.begin();
    for (int i=0; i<tcount; i++)
    {
      int i1 = *j;
      j++;
      int i2 = *j;
      j++;
      int i3 = *j;
      j++;
      if ( i == (tcount-1) )
        fprintf(fph,"  %d, %d, %d, -1]\n",i1,i2,i3);
      else
        fprintf(fph,"  %d, %d, %d, -1,\n",i1,i2,i3);
    }
  }
  fprintf(fph,"  }\n");
  fprintf(fph,"}\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movl 0x9537(%rip), %edx      # 0x19230
leal 0x1(%rdx), %eax
movl %eax, 0x952e(%rip)      # 0x19230
leaq 0x3bc0(%rip), %rsi      # 0x138c9
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2300
leaq 0x3bc7(%rip), %rdi      # 0x138e1
movl $0x22, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3e4c(%rip), %rdi      # 0x13b7f
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3bb8(%rip), %rdi      # 0x13904
movl $0x26, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3bc6(%rip), %rdi      # 0x1392b
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3bd2(%rip), %rdi      # 0x13950
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3bd6(%rip), %rdi      # 0x1396d
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3bcf(%rip), %rdi      # 0x1397f
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4023(%rip), %rdi      # 0x13dec
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3baf(%rip), %rdi      # 0x13991
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq (%r14), %rax
testl %r15d, %r15d
je 0xfe19
leaq -0x130(%rbp), %rcx
movzbl (%rax), %edx
testl %edx, %edx
je 0xfe57
cmpl $0x2b, %edx
je 0xfe57
incq %rax
movb %dl, (%rcx)
incq %rcx
jmp 0xfe03
incq %rax
movzbl -0x1(%rax), %ecx
testl %ecx, %ecx
je 0xfe60
cmpl $0x2b, %ecx
jne 0xfe19
movb (%rax), %cl
leaq 0x3b82(%rip), %rsi      # 0x139b4
testb %cl, %cl
je 0xfe70
xorl %edx, %edx
movb %cl, -0x130(%rbp,%rdx)
movb 0x1(%rax,%rdx), %cl
incq %rdx
testb %cl, %cl
jne 0xfe38
leaq (%rdx,%rbp), %rcx
addq $-0x130, %rcx           # imm = 0xFED0
jmp 0xfe77
leaq 0x3b3f(%rip), %rsi      # 0x1399d
jmp 0xfe77
leaq -0x130(%rbp), %rcx
leaq 0x3b46(%rip), %rsi      # 0x139b4
jmp 0xfe77
leaq -0x130(%rbp), %rcx
movb $0x0, (%rcx)
leaq -0x130(%rbp), %rcx
movq %rbx, %rdi
movl $0x22, %edx
movl $0x22, %r8d
xorl %eax, %eax
callq 0x2300
leaq 0x3f4f(%rip), %rdi      # 0x13dec
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x38(%r14), %rdi
movzbl %r15b, %edx
movq %rbx, %rsi
callq 0x10000
movq 0x28(%r14), %rax
subq 0x20(%r14), %rax
sarq %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
movq %rdx, %r15
shrq %r15
leaq 0x3ae7(%rip), %rdi      # 0x139cb
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
testl %r15d, %r15d
jle 0xffa3
movq %r14, -0x30(%rbp)
movq 0x20(%r14), %r14
leaq 0x3af1(%rip), %r13      # 0x139ff
movq %rbx, %r12
movl %r15d, %ebx
movzwl (%r14), %edx
movzwl 0x2(%r14), %ecx
movzwl 0x4(%r14), %r8d
cmpl $0x1, %ebx
movq %r13, %rsi
leaq 0x3abd(%rip), %rax      # 0x139ec
cmoveq %rax, %rsi
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
addq $0x6, %r14
decl %ebx
jne 0xff14
leaq 0x3ac6(%rip), %rdi      # 0x13a12
movl $0x16, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
testl %r15d, %r15d
movq %r12, %rbx
leaq 0x3a81(%rip), %r12      # 0x139ec
jle 0xffbc
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r14
movzwl (%r14), %edx
movzwl 0x2(%r14), %ecx
movzwl 0x4(%r14), %r8d
cmpl $0x1, %r15d
movq %r13, %rsi
cmoveq %r12, %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2300
addq $0x6, %r14
decl %r15d
jne 0xff75
jmp 0xffbc
leaq 0x3a68(%rip), %rdi      # 0x13a12
movl $0x16, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3a9b(%rip), %rdi      # 0x13a5e
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3e10(%rip), %rdi      # 0x13dec
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq