// File: /workspace/github_c_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r14
movl 0xab39(%rip), %edx      # 0x19268
leal 0x1(%rdx), %eax
movl %eax, 0xab30(%rip)      # 0x19268
leaq 0x319e(%rip), %rsi      # 0x118dd
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2330
leaq 0x31a5(%rip), %rdi      # 0x118f5
pushq $0x22
popq %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x342a(%rip), %rdi      # 0x11b93
pushq $0xb
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x319a(%rip), %rdi      # 0x11918
pushq $0x26
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x31ac(%rip), %rdi      # 0x1193f
pushq $0x24
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x31bc(%rip), %rdi      # 0x11964
pushq $0x1c
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x31c4(%rip), %rdi      # 0x11981
pushq $0x11
popq %r15
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x31bd(%rip), %rdi      # 0x11993
movq %r15, %rsi
movl %r13d, %r15d
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x3612(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x31a2(%rip), %rdi      # 0x119a5
pushq $0xb
popq %rsi
movq %r12, %rdx
movq %rbx, -0x30(%rbp)
movq %rbx, %rcx
callq 0x2440
movq %r14, -0x38(%rbp)
movq (%r14), %rax
testl %r13d, %r13d
je 0xe83e
leaq -0x140(%rbp), %rcx
movzbl (%rax), %edx
testl %edx, %edx
je 0xe863
cmpl $0x2b, %edx
je 0xe863
incq %rax
movb %dl, (%rcx)
incq %rcx
jmp 0xe828
incq %rax
movzbl -0x1(%rax), %ecx
testl %ecx, %ecx
je 0xe878
cmpl $0x2b, %ecx
jne 0xe83e
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
testb %dl, %dl
je 0xe86c
movb %dl, -0x140(%rbp,%rcx)
incq %rcx
jmp 0xe850
leaq 0x3147(%rip), %rsi      # 0x119b1
jmp 0xe886
addq %rbp, %rcx
addq $-0x140, %rcx           # imm = 0xFEC0
jmp 0xe87f
leaq -0x140(%rbp), %rcx
leaq 0x3142(%rip), %rsi      # 0x119c8
movb $0x0, (%rcx)
xorl %r14d, %r14d
leaq -0x140(%rbp), %rcx
pushq $0x22
popq %rdx
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movl %edx, %r8d
xorl %eax, %eax
callq 0x2330
leaq 0x3552(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
movq -0x38(%rbp), %r13
leaq 0x38(%r13), %rdi
movzbl %r15b, %edx
movq %rbx, %rsi
callq 0xe9ea
movq 0x28(%r13), %rax
subq 0x20(%r13), %rax
sarq %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
leaq 0x30ee(%rip), %rdi      # 0x119df
pushq $0x20
popq %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2440
leal -0x1(%r15), %r12d
testl %r15d, %r15d
cmovlel %r14d, %r15d
movq 0x20(%r13), %rbx
leaq 0x30fe(%rip), %r14      # 0x11a13
xorl %r13d, %r13d
cmpl %r13d, %r15d
je 0xe94e
movzwl (%rbx), %edx
movzwl 0x2(%rbx), %ecx
movzwl 0x4(%rbx), %r8d
addq $0x6, %rbx
cmpl %r13d, %r12d
movq %r14, %rsi
leaq 0x30c6(%rip), %rax      # 0x11a00
cmoveq %rax, %rsi
movq -0x30(%rbp), %rdi
xorl %eax, %eax
callq 0x2330
incl %r13d
jmp 0xe918
leaq 0x30d1(%rip), %rdi      # 0x11a26
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
movq -0x30(%rbp), %rcx
callq 0x2440
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rbx
xorl %r13d, %r13d
cmpl %r13d, %r15d
je 0xe9a5
movzwl (%rbx), %edx
movzwl 0x2(%rbx), %ecx
movzwl 0x4(%rbx), %r8d
addq $0x6, %rbx
cmpl %r13d, %r12d
movq %r14, %rsi
leaq 0x306f(%rip), %rax      # 0x11a00
cmoveq %rax, %rsi
movq -0x30(%rbp), %rdi
xorl %eax, %eax
callq 0x2330
incl %r13d
jmp 0xe96f
leaq 0x30c6(%rip), %rdi      # 0x11a72
pushq $0x4
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq -0x30(%rbp), %rbx
movq %rbx, %rcx
callq 0x2440
leaq 0x3437(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2440
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop