// File: /workspace/github_c_makefile_star2_O1/vlenhart[P]q3bsp/vformat.cpp
// Function: VertexSection::SaveVRML2(_IO_FILE*, VFormatOptions&)
void VertexSection::SaveVRML2(FILE *fph,VFormatOptions &options)
{

  static int itemcount=1;

  bool hasLightMap = true;
  int numStages=2;
  int lightMapStage = 0; // place lightmap coord into this texture stage 
  bool vertexColor = true;

  //lightMapStage=1;

  // name of lightmap texture 
  StringRef lightMap;


  // parse mName into base texture + light map

  const char *foo = mName;
  char scratch[256];

  char *dest = scratch;
  while ( *foo && *foo != '+' ) *dest++ = *foo++;
  if (*foo == '+' && foo[1]) {
	  lightMap = foo+1;
	  hasLightMap = true;
  }	
  else  { 
	  hasLightMap = false;
	  numStages = 1;
	  lightMapStage = -1;
  }	
  *dest = 0;

  StringRef name(scratch);

  if (mShader) {
	  numStages =mShader->GetNumStages();
	  if (mShader->mNoLightMap) {
		  hasLightMap = false;
		  lightMapStage = -1;
	  }	else {
		  lightMapStage=mShader->mLightMapStage;
	  }	
	 //if (rgbGen == Identity)
	 //	 vertexColor = false;
  }	else {

  }	

  //fprintf(fph,"DEF item%d Shape {\n",itemcount++);
  fprintf(fph,"Shape {\n");
  fprintf(fph,"appearance ");


  // appearance node already defined ?
  AppearanceDefMap::iterator found;
  found = options.appearanceDefMap.find(mName);
  if ( found != options.appearanceDefMap.end()) { // simply use it 
	  //found.r
	  fprintf(fph,"USE %s\n",(const char *)(*found).second);
  } 
  else 
  {  // need to define new Appearance node 
	  if (options.verbose) {
		fprintf(fph," #%s\n",(const char *) mName);
		if (mShader) {
			  fprintf(fph," #shader %s\n",(const char *) mShader->GetName());
		}		
	  }	
	  
	  fprintf(fph,"DEF A%d Appearance {\n",options.appearanceCount);
	  char buf[60];
	  sprintf(buf,"_A%d",options.appearanceCount);

	  // insert new node into map 
	  options.textureDefMap.insert(AppearanceDefMap::value_type(StringRef(mName),StringRef(buf)));
	  
	  options.appearanceCount++;
		  
		  if (options.useLighting) {
			  fprintf(fph,"material Material {\n");
			  fprintf(fph,"  ambientIntensity 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");
		  }
		  else {  
		  if (options.useMat) {
			  if (!options.matDefined) {
				fprintf(fph,"material DEF MAT Material {\n");
				//fprintf(fph,"  diffuseColor 0 0 0\n");
				fprintf(fph,"  diffuseColor 1 1 1\n");
				//fprintf(fph,"  emissiveColor 0.5 0.5 0.5\n"); // overall brightness 
				fprintf(fph,"  emissiveColor 0.2 0.2 0.2\n"); // overall brightness 
				fprintf(fph,"}\n");
				options.matDefined = true;
			  } else 	
				fprintf(fph,"material USE MAT \n");

		  }
		  }
		  
		  
		  fprintf(fph,"texture ");
		  
		  bool tex1 = options.tex1;
		
		  
		  if (options.useMultiTexturing) {
			  fprintf(fph,"MultiTexture {\nmaterialColor TRUE texture [\n");
			  tex1 = true;
		
		  if (mShader) {
		    hasLightMap = false;
			numStages =mShader->GetNumStages();
			for (int i=0; i<numStages; i++) {
				
				//if (i>0 && numStages >2) // we can do only 2 stages 
				//	i=numStages-1;

				const ShaderStage& stage = mShader->GetStage(i);

				if (stage.isAnimMap) {
					if (options.useEffects) {
						fprintf(fph,"DEF MAP AnimMap {\nfrequency %f textures [\n",stage.animMapFrequency);
						for (unsigned int i=0; i<stage.animMap.size(); i++)
							WriteImageTexture(fph,stage.animMap[i],options,false,stage.clamp);

						//fprintf(fph,"] ROUTE TIMER.fraction_changed TO MAP.set_fraction \n");
					    fprintf(fph,"]ROUTE TIMER.time_changed TO MAP.set_time\n");

						fprintf(fph,"}");
					}else
						WriteImageTexture(fph,stage.animMap[0],options,false,stage.clamp);


				} else 
				if (stage.isLightMap) {
					WriteImageTexture(fph,lightMap,options,true,stage.clamp);
					hasLightMap = true;
					mShader->mLightMapStage=lightMapStage=i;
				} else 
					WriteImageTexture(fph,stage.map,options,false,stage.clamp);
			}
		  }	
		  else 
		  { // no shader
			//WriteImageTexture(fph,name,options,false);
			if (options.useMultiTexturing) {
				if (hasLightMap) {
					WriteImageTexture(fph,lightMap,options,true,false);
				}
			}
			WriteImageTexture(fph,name,options,false);

		  }	
		  } 
		  else {
			  // not useMultiTexturing
			  if (tex1) {
					if (mShader) 
					    mShader ->GetBaseTexture(name);

					WriteImageTexture(fph,name,options,false);

			  } else {	
				if (hasLightMap) {
					WriteImageTexture(fph,lightMap,options,true,false);
				}
				else WriteImageTexture(fph,"nomap",options,true,false);
			  }	

		  }	
		  if (options.useMultiTexturing) {
			  fprintf(fph,"]");
			  // add makes it to bright
			  // with modulate currently to dark
			  //if (numStages>1) 
			  if (mShader) {
				fprintf(fph,"mode [ ");
				bool hasTcMod = false;

				for (int i=0; i<numStages; i++) {
				
					//if (i>0 && numStages >2) // we can do only 2 stages 
					//	i=numStages-1;
					const ShaderStage& stage = mShader->GetStage(i);
					const char *mode = stage.textureBlendMode;
					
					if (stage.tcmod.length()>0) hasTcMod = true;
					if (stage.tcmodOk.length()>0) hasTcMod = true;

					if (i==0 && stage.textureBlendMode == String("ADD") && !stage.isLightMap)
						mode = "MODULATE";

					if (!mode) {
						if (i==0 && !options.useMat) 
							mode = "REPLACE";
					}	

					fprintf(fph,"\"%s\" ", mode ? mode : "ADD");
					fprintf(fph,"# blend %s %s \n",(const char *) stage.blendFuncSrc,(const char *) stage.blendFuncDst);

				}
				fprintf(fph,"]\n");

				// tcmod 
				if (hasTcMod) {
				fprintf(fph,"textureTransform [ ");

				for (int i=0; i<numStages; i++) {
				
					//if (i>0 && numStages >2) // we can do only 2 stages 
					//	i=numStages-1;
					const ShaderStage& stage = mShader->GetStage(i);
					const char *mode = stage.tcmod.c_str();
					const char *modeOk = stage.tcmodOk.c_str();

					if (stage.tcmod.length()>0 || stage.tcmodOk.length()>0 ) {
					   fprintf(fph,"DEF TC%d TcMod {\n",i);

					   if (stage.tcmodOk.length()>0)
						   fprintf(fph,"\t%s\n", modeOk);

					   if (stage.tcmod.length()>0) 
						   fprintf(fph,"\tmode \"%s\" \n",mode ? mode : "" );

					   //fprintf(fph,"ROUTE TIMER.fraction_changed TO TC%d.set_fraction \n",i);
					   fprintf(fph,"ROUTE TIMER.time_changed TO TC%d.set_time\n",i);
					   fprintf(fph,"}\n");
					}
					else  fprintf(fph,"NULL\n");

				}
				fprintf(fph,"]\n");
				}

			  } 
			  else {
				  if (hasLightMap)
					  fprintf(fph, "%s", options.blendMode);
				  else ; // MODULATE 
			  }					
			  fprintf(fph,"}");
		  }	// multi texture 
		  
		  fprintf(fph,"}\n");
  }	

  int tcount = mIndices.size()/3;

  // write the indexed face set 
  if ( 1 )
  {
    fprintf(fph,"geometry  IndexedFaceSet {\n");

    fprintf(fph,"\tccw FALSE creaseAngle 3.14\n");

	if (mShader && (mShader->mCull == StringRef("none") ||  mShader->mCull == StringRef("disable")))  {
	    fprintf(fph,"\tsolid FALSE\n");
	}
	if (mShader && (mShader->mCull == StringRef("back")))  {
	    fprintf(fph,"\tccw TRUE\n");
	}
    fprintf(fph,"\tcoordIndex [\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,"\t%d,%d,%d,-1]\n",i1,i2,i3);
      else
        fprintf(fph,"\t%d,%d,%d,-1,\n",i1,i2,i3);

    }
  }

  if ( 0 ) // if texCoord index == ccordIndex no need to export
  {
    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,"\t%d,%d,%d,-1]\n",i1,i2,i3);
      else
        fprintf(fph,"\t%d,%d,%d,-1,\n",i1,i2,i3);
    }
  }

  mPoints.SaveVRML2(fph,lightMapStage,options);

  fprintf(fph,"  }\n");
  fprintf(fph,"}\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdx, -0x58(%rbp)
movq %rsi, %r12
movq %rdi, %r15
leaq 0x3a71(%rip), %rax      # 0x12bb2
movq %rax, -0x60(%rbp)
movq (%rdi), %rax
xorl %r14d, %r14d
movq %rdi, -0x38(%rbp)
movzbl (%rax,%r14), %r13d
testl %r13d, %r13d
je 0xf1a8
cmpl $0x2b, %r13d
je 0xf16c
movb %r13b, -0x1d0(%rbp,%r14)
incq %r14
jmp 0xf14f
cmpb $0x0, 0x1(%rax,%r14)
je 0xf1ba
movl $0x0, -0x2c(%rbp)
leaq (%rax,%r14), %r15
incq %r15
callq 0x697e
movq %rax, %rdi
movq %r15, %rsi
movq -0x38(%rbp), %r15
callq 0x6a12
movq %rax, -0x60(%rbp)
movb $0x1, %r13b
movl $0x2, %eax
movq %rax, -0x48(%rbp)
jmp 0xf1cd
movl $0x1, %eax
movq %rax, -0x48(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0xf1cd
movl $0x1, %eax
movq %rax, -0x48(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movb $0x0, -0x1d0(%rbp,%r14)
callq 0x697e
leaq -0x1d0(%rbp), %rsi
movq %rax, %rdi
callq 0x6a12
movq %rax, -0x68(%rbp)
movq 0x80(%r15), %rax
testq %rax, %rax
je 0xf226
movq 0x58(%rax), %rcx
subq 0x50(%rax), %rcx
shrq $0x3, %rcx
imull $0xe9bd37a7, %ecx, %ecx # imm = 0xE9BD37A7
movq %rcx, -0x48(%rbp)
cmpb $0x0, 0x9(%rax)
movq -0x58(%rbp), %rbx
je 0xf22c
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
jmp 0xf232
movq -0x58(%rbp), %rbx
jmp 0xf232
movl 0xc(%rax), %eax
movl %eax, -0x2c(%rbp)
leaq 0x48e4(%rip), %rdi      # 0x13b1d
movl $0x8, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x48d4(%rip), %rdi      # 0x13b26
movl $0xb, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
movq 0x40(%rbx), %rdx
leaq 0x38(%rbx), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0xf292
movq (%r15), %rsi
movq %rax, %rcx
xorl %edi, %edi
cmpq 0x20(%rdx), %rsi
setb %dil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0xf27a
movq %rax, %rdx
cmpq %rax, %rcx
je 0xf2a8
movq 0x20(%rcx), %rdx
cmpq (%r15), %rdx
cmovbq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0xf2ca
movq 0x28(%rdx), %rdx
leaq 0x4804(%rip), %rsi      # 0x13abc
movq %r12, %rbx
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
jmp 0xfa2c
cmpb $0x1, 0x69(%rbx)
jne 0xf305
movq (%r15), %rdx
leaq 0x4858(%rip), %rsi      # 0x13b32
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
movq 0x80(%r15), %rax
testq %rax, %rax
je 0xf305
movq 0x30(%rax), %rdx
leaq 0x483d(%rip), %rsi      # 0x13b38
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
movl 0x60(%rbx), %edx
leaq 0x4836(%rip), %rsi      # 0x13b45
movq %r12, %rdi
xorl %eax, %eax
callq 0x2300
movl 0x60(%rbx), %edx
leaq 0x4838(%rip), %rsi      # 0x13b5b
movq %r15, %rbx
leaq -0xd0(%rbp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2080
movq (%rbx), %r14
callq 0x697e
movq %rax, %rdi
movq %r15, %rsi
callq 0x6a12
leaq -0x88(%rbp), %rsi
movq %r14, (%rsi)
movq -0x58(%rbp), %r14
movq %rax, 0x8(%rsi)
movq %r14, %rdi
callq 0x11278
incl 0x60(%r14)
cmpb $0x1, 0x75(%r14)
jne 0xf415
leaq 0x47e6(%rip), %rdi      # 0x13b60
movl $0x14, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x47e2(%rip), %rdi      # 0x13b75
movl $0x1c, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x45a3(%rip), %rdi      # 0x1394f
movl $0x24, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x45af(%rip), %rdi      # 0x13974
movl $0x1c, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x45b3(%rip), %rdi      # 0x13991
movl $0x11, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
leaq 0x4a19(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x2410
movq %r12, %rbx
movq -0x38(%rbp), %r15
jmp 0xf4b8
cmpb $0x1, 0x76(%r14)
movq %r12, %rbx
movq -0x38(%rbp), %r15
jne 0xf4b8
cmpb $0x0, 0xb0(%r14)
je 0xf44c
leaq 0x47aa(%rip), %rdi      # 0x13be2
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
jmp 0xf4b8
leaq 0x473f(%rip), %rdi      # 0x13b92
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4743(%rip), %rdi      # 0x13baf
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4740(%rip), %rdi      # 0x13bc5
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4972(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movb $0x1, 0xb0(%r14)
leaq 0x4736(%rip), %rdi      # 0x13bf5
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
cmpb $0x1, 0x6a(%r14)
jne 0xf677
leaq 0x471b(%rip), %rdi      # 0x13bfe
movl $0x2c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq 0x80(%r15), %rax
testq %rax, %rax
je 0xf6a9
movq 0x58(%rax), %rcx
subq 0x50(%rax), %rcx
sarq $0x3, %rcx
movabsq $-0x2c8590b21642c859, %rax # imm = 0xD37A6F4DE9BD37A7
imulq %rcx, %rax
testl %eax, %eax
movq %rax, -0x48(%rbp)
jle 0xfbd3
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x50(%rbp)
xorl %ecx, %ecx
xorl %r13d, %r13d
movq 0x80(%r15), %rax
movq 0x50(%rax), %rax
movq %rcx, -0x40(%rbp)
imulq $0xb8, %rcx, %rcx
leaq (%rax,%rcx), %r12
cmpb $0x1, 0xa9(%rax,%rcx)
jne 0xf603
cmpb $0x1, 0x77(%r14)
jne 0xf641
xorps %xmm0, %xmm0
cvtss2sd 0x20(%r12), %xmm0
movq %rbx, %rdi
leaq 0x46ab(%rip), %rsi      # 0x13c2b
movb $0x1, %al
callq 0x2300
movq 0x8(%r12), %rax
cmpq %rax, 0x10(%r12)
movq %r14, %r15
je 0xf5d4
movl $0x1, %r14d
xorl %ecx, %ecx
leaq (%rax,%rcx,8), %rsi
movzbl 0xaa(%r12), %r8d
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x10297
movl %r14d, %ecx
movq 0x8(%r12), %rax
movq 0x10(%r12), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0xf59e
movl $0x2a, %esi
movl $0x1, %edx
leaq 0x4671(%rip), %rdi      # 0x13c56
movq %rbx, %rcx
callq 0x2410
movl $0x7d, %edi
movq %rbx, %rsi
callq 0x22e0
movq %r15, %r14
movq -0x38(%rbp), %r15
jmp 0xf661
cmpb $0x1, 0xa8(%r12)
movzbl 0xaa(%r12), %r8d
movq %rbx, %rdi
jne 0xf654
leaq -0x60(%rbp), %rsi
movq %r14, %rdx
movl $0x1, %ecx
callq 0x10297
movq 0x80(%r15), %rax
movq -0x40(%rbp), %rcx
movl %ecx, 0xc(%rax)
movb $0x1, %r13b
movl %ecx, -0x2c(%rbp)
jmp 0xf665
movq 0x8(%r12), %rsi
movzbl 0xaa(%r12), %r8d
movq %rbx, %rdi
jmp 0xf657
movq %r12, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x10297
movq -0x40(%rbp), %rcx
incq %rcx
cmpq -0x50(%rbp), %rcx
jne 0xf539
jmp 0xf70c
cmpb $0x1, 0x6c(%r14)
jne 0xf69d
movq 0x80(%r15), %rax
testq %rax, %rax
je 0xf6cd
movq 0x38(%rax), %rcx
cmpq %rcx, 0x40(%rax)
je 0xf6cd
movq (%rcx), %rax
movq %rax, -0x68(%rbp)
jmp 0xf6cd
testb $0x1, %r13b
je 0xf6db
leaq -0x60(%rbp), %rsi
jmp 0xf6f9
cmpb $0x1, 0x6a(%r14)
jne 0xf6cd
testb $0x1, %r13b
je 0xf6cd
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x10297
leaq -0x68(%rbp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
jmp 0xf704
callq 0x697e
leaq 0x459a(%rip), %rsi      # 0x13c81
movq %rax, %rdi
callq 0x6a12
leaq -0x88(%rbp), %rsi
movq %rax, (%rsi)
movq %rbx, %rdi
movq %r14, %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x10297
cmpb $0x1, 0x6a(%r14)
jne 0xfa13
movl $0x5d, %edi
movq %rbx, %rsi
callq 0x22e0
cmpq $0x0, 0x80(%r15)
je 0xf9f1
leaq 0x454e(%rip), %rdi      # 0x13c87
movl $0x7, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq -0x48(%rbp), %rax
testl %eax, %eax
jle 0xf9d6
movl %eax, %eax
movq %rax, -0x48(%rbp)
imulq $0xb8, %rax, %rax
movq %rax, -0x40(%rbp)
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rax), %r12
movq 0x70(%r12,%r13), %rax
movq 0xb0(%r12,%r13), %rcx
orq 0x50(%r12,%r13), %rax
movzbl %r15b, %r15d
movl $0x1, %eax
cmovnel %eax, %r15d
testq %r13, %r13
je 0xf7aa
xorl %r14d, %r14d
jmp 0xf808
movq %rcx, %rbx
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
leaq 0x3f1c(%rip), %rsi      # 0x136e2
leaq 0x3f18(%rip), %rdx      # 0x136e5
callq 0x6d42
callq 0x697e
movq -0x88(%rbp), %rsi
movq %rax, %rdi
callq 0x6a12
cmpq 0xb0(%r12,%r13), %rax
je 0xf7f5
xorl %r14d, %r14d
jmp 0xf801
movb 0xa8(%r12,%r13), %r14b
xorb $0x1, %r14b
movq %rbx, %rcx
movq -0x50(%rbp), %rbx
testq %r13, %r13
jne 0xf833
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xf833
movq -0x78(%rbp), %rsi
incq %rsi
movq %rcx, %rbx
callq 0x2230
movq %rbx, %rcx
movq -0x50(%rbp), %rbx
leaq 0x2ebc(%rip), %rax      # 0x126f6
testb %r14b, %r14b
jne 0xf842
movq %rcx, %rax
movq -0x58(%rbp), %rcx
testb $0x1, 0x76(%rcx)
jne 0xf855
leaq 0x3e87(%rip), %rcx      # 0x136da
jmp 0xf857
xorl %ecx, %ecx
movq %r13, %rdx
orq %rax, %rdx
cmovneq %rax, %rcx
leaq 0x3e7a(%rip), %rdx      # 0x136e2
testq %rcx, %rcx
je 0xf870
movq %rcx, %rdx
movq %rbx, %rdi
leaq 0x4415(%rip), %rsi      # 0x13c8f
xorl %eax, %eax
callq 0x2300
movq 0x28(%r12,%r13), %rdx
movq 0x30(%r12,%r13), %rcx
movq %rbx, %rdi
leaq 0x4400(%rip), %rsi      # 0x13c95
xorl %eax, %eax
callq 0x2300
addq $0xb8, %r13
cmpq %r13, -0x40(%rbp)
jne 0xf772
leaq 0x41fb(%rip), %rdi      # 0x13aaf
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
testb $0x1, %r15b
movq -0x38(%rbp), %r15
je 0xfa06
leaq 0x43ca(%rip), %rdi      # 0x13ca5
movl $0x13, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movl $0x70, %r14d
xorl %r12d, %r12d
movq 0x80(%r15), %rax
movq 0x50(%rax), %r15
movq -0x28(%r15,%r14), %rax
movq -0x8(%r15,%r14), %r13
cmpq $0x0, (%r15,%r14)
jne 0xf91e
cmpq $0x0, -0x20(%r15,%r14)
je 0xf9c3
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
leaq 0x438d(%rip), %rsi      # 0x13cb9
movl %r12d, %edx
xorl %eax, %eax
callq 0x2300
cmpq $0x0, -0x20(%r15,%r14)
je 0xf953
movq %rbx, %rdi
leaq 0x4383(%rip), %rsi      # 0x13ccb
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x2300
cmpq $0x0, (%r15,%r14)
je 0xf97c
testq %r13, %r13
leaq 0x445b(%rip), %rax      # 0x13dbf
cmoveq %rax, %r13
movq %rbx, %rdi
leaq 0x435e(%rip), %rsi      # 0x13cd0
movq %r13, %rdx
xorl %eax, %eax
callq 0x2300
movq %rbx, %rdi
leaq 0x4357(%rip), %rsi      # 0x13cdd
movl %r12d, %edx
xorl %eax, %eax
callq 0x2300
movl $0x2, %esi
movl $0x1, %edx
leaq 0x446f(%rip), %rdi      # 0x13e10
movq %rbx, %rcx
callq 0x2410
movq -0x38(%rbp), %r15
incq %r12
addq $0xb8, %r14
cmpq %r12, -0x48(%rbp)
jne 0xf8f6
jmp 0xf9d6
movl $0x5, %esi
movl $0x1, %edx
leaq 0x4334(%rip), %rdi      # 0x13d08
jmp 0xf9a1
leaq 0x40d2(%rip), %rdi      # 0x13aaf
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
jmp 0xfa06
testb $0x1, %r13b
je 0xfa06
movq 0x98(%r14), %rdi
movq %rbx, %rsi
callq 0x2280
movl $0x7d, %edi
movq %rbx, %rsi
callq 0x22e0
leaq 0x43f6(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq 0x28(%r15), %rax
subq 0x20(%r15), %rax
sarq %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
movq %rdx, %r13
shrq %r13
leaq 0x42bd(%rip), %rdi      # 0x13d0e
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x42c0(%rip), %rdi      # 0x13d2a
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq 0x80(%r15), %r14
testq %r14, %r14
je 0xfada
callq 0x697e
leaq 0x42b3(%rip), %rsi      # 0x13d47
movq %rax, %rdi
callq 0x6a12
cmpq (%r14), %rax
je 0xfac1
movq 0x80(%r15), %r14
callq 0x697e
leaq 0x4298(%rip), %rsi      # 0x13d4c
movq %rax, %rdi
callq 0x6a12
cmpq (%r14), %rax
jne 0xfada
leaq 0x428c(%rip), %rdi      # 0x13d54
movl $0xd, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
movq 0x80(%r15), %r14
testq %r14, %r14
je 0xfb18
callq 0x697e
leaq 0x4270(%rip), %rsi      # 0x13d62
movq %rax, %rdi
callq 0x6a12
cmpq (%r14), %rax
jne 0xfb18
leaq 0x4261(%rip), %rdi      # 0x13d67
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4253(%rip), %rdi      # 0x13d72
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
testl %r13d, %r13d
jle 0xfb78
movq -0x38(%rbp), %rax
movq 0x20(%rax), %r14
leaq 0x423c(%rip), %r15      # 0x13d81
leaq 0x4244(%rip), %r12      # 0x13d90
movzwl (%r14), %edx
movzwl 0x2(%r14), %ecx
movzwl 0x4(%r14), %r8d
cmpl $0x1, %r13d
movq %r12, %rsi
cmoveq %r15, %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2300
addq $0x6, %r14
decl %r13d
jne 0xfb4c
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movq %rbx, %rsi
movl -0x2c(%rbp), %edx
movq -0x58(%rbp), %rcx
callq 0x1047e
leaq 0x3eec(%rip), %rdi      # 0x13a82
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
leaq 0x4261(%rip), %rdi      # 0x13e10
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2410
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0xf70c
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xfbfa
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0