// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rdi, %r14
movl 0x946f(%rip), %edx      # 0x19248
leal 0x1(%rdx), %eax
movl %eax, 0x9466(%rip)      # 0x19248
leaq 0x3b04(%rip), %rsi      # 0x138ed
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
leaq 0x3b0b(%rip), %rdi      # 0x13905
movl $0x22, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3d90(%rip), %rdi      # 0x13ba3
movl $0xb, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3afc(%rip), %rdi      # 0x13928
movl $0x26, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3b0a(%rip), %rdi      # 0x1394f
movl $0x24, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3b16(%rip), %rdi      # 0x13974
movl $0x1c, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3b1a(%rip), %rdi      # 0x13991
movl $0x11, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3b13(%rip), %rdi      # 0x139a3
movl $0x11, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3f67(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3af3(%rip), %rdi      # 0x139b5
movl $0xb, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
movq (%r14), %rax
testl %r15d, %r15d
je 0xfef9
leaq -0x130(%rbp), %rcx
movzbl (%rax), %edx
testl %edx, %edx
je 0xff37
cmpl $0x2b, %edx
je 0xff37
incq %rax
movb %dl, (%rcx)
incq %rcx
jmp 0xfee3
incq %rax
movzbl -0x1(%rax), %ecx
testl %ecx, %ecx
je 0xff40
cmpl $0x2b, %ecx
jne 0xfef9
movb (%rax), %cl
leaq 0x3ac6(%rip), %rsi      # 0x139d8
testb %cl, %cl
je 0xff50
xorl %edx, %edx
movb %cl, -0x130(%rbp,%rdx)
movb 0x1(%rax,%rdx), %cl
incq %rdx
testb %cl, %cl
jne 0xff18
leaq (%rdx,%rbp), %rcx
addq $-0x130, %rcx           # imm = 0xFED0
jmp 0xff57
leaq 0x3a83(%rip), %rsi      # 0x139c1
jmp 0xff57
leaq -0x130(%rbp), %rcx
leaq 0x3a8a(%rip), %rsi      # 0x139d8
jmp 0xff57
leaq -0x130(%rbp), %rcx
movb $0x0, (%rcx)
leaq -0x130(%rbp), %rcx
movq %r12, %rdi
movl $0x22, %edx
movl $0x22, %r8d
xorl %eax, %eax
callq 0x2300
leaq 0x3e93(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x38(%r14), %rdi
movzbl %r15b, %edx
movq %r12, %rsi
callq 0x100c2
movq 0x28(%r14), %rax
movq %r14, -0x30(%rbp)
subq 0x20(%r14), %rax
sarq %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
movq %rdx, %r15
shrq %r15
leaq 0x3a27(%rip), %rdi      # 0x139ef
movl $0x20, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x3a42(%rip), %r13      # 0x13a23
testl %r15d, %r15d
jle 0x10022
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r14
movl %r15d, %ebx
movzwl (%r14), %edx
movzwl 0x2(%r14), %ecx
movzwl 0x4(%r14), %r8d
cmpl $0x1, %ebx
movq %r13, %rsi
leaq 0x3a04(%rip), %rax      # 0x13a10
cmoveq %rax, %rsi
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
addq $0x6, %r14
decl %ebx
jne 0xfff1
leaq 0x3a0d(%rip), %rdi      # 0x13a36
movl $0x16, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
testl %r15d, %r15d
movq %r12, %rbx
leaq 0x39c8(%rip), %r12      # 0x13a10
jle 0x1007e
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 0x10052
leaq 0x39fd(%rip), %rdi      # 0x13a82
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x3d72(%rip), %rdi      # 0x13e10
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