// File: /workspace/github_c_makefile_star2_O2/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 $0x1b8, %rsp            # imm = 0x1B8
movq %rdx, %rbx
movq %rsi, -0x30(%rbp)
leaq 0x2fc6(%rip), %rax      # 0x10bb2
movq %rax, -0x60(%rbp)
movq %rdi, -0x38(%rbp)
movq (%rdi), %rax
xorl %r15d, %r15d
pushq $-0x1
popq %r14
movzbl (%rax,%r15), %r12d
pushq $0x1
popq %r13
testl %r12d, %r12d
je 0xdc51
cmpl $0x2b, %r12d
je 0xdc1f
movb %r12b, -0x1e0(%rbp,%r15)
incq %r15
jmp 0xdbfe
xorl %r12d, %r12d
cmpb $0x0, 0x1(%rax,%r15)
je 0xdc51
leaq (%rax,%r15), %rsi
incq %rsi
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x94e4
movq (%r14), %rax
movq %rax, -0x60(%rbp)
movb $0x1, %r12b
pushq $0x2
popq %r13
xorl %r14d, %r14d
movb $0x0, -0x1e0(%rbp,%r15)
leaq -0x68(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x94e4
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rcx
testq %rcx, %rcx
je 0xdca0
movq 0x58(%rcx), %rax
subq 0x50(%rcx), %rax
movl $0xb8, %esi
cqto
idivq %rsi
movq %rax, %r13
cmpb $0x0, 0x9(%rcx)
je 0xdca6
pushq $-0x1
popq %rax
movl %eax, -0x40(%rbp)
xorl %r12d, %r12d
jmp 0xdcac
movl %r14d, -0x40(%rbp)
jmp 0xdcac
movl 0xc(%rcx), %eax
movl %eax, -0x40(%rbp)
leaq 0x3e5a(%rip), %rdi      # 0x11b0d
pushq $0x8
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq -0x30(%rbp), %r15
movq %r15, %rcx
callq 0x2440
leaq 0x3e46(%rip), %rdi      # 0x11b16
pushq $0xb
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x30(%rbx), %rdi
movq -0x38(%rbp), %rsi
callq 0xfbbc
leaq 0x38(%rbx), %rcx
cmpq %rcx, %rax
movq %rbx, -0x58(%rbp)
je 0xdd12
movq 0x28(%rax), %rdx
leaq 0x3da9(%rip), %rsi      # 0x11aac
movq %r15, %rdi
xorl %eax, %eax
callq 0x2330
jmp 0xe3eb
cmpb $0x1, 0x69(%rbx)
jne 0xdd51
movq -0x38(%rbp), %r14
movq (%r14), %rdx
leaq 0x3dfc(%rip), %rsi      # 0x11b22
movq %r15, %rdi
xorl %eax, %eax
callq 0x2330
movq 0x80(%r14), %rax
testq %rax, %rax
je 0xdd51
movq 0x30(%rax), %rdx
leaq 0x3de1(%rip), %rsi      # 0x11b28
movq %r15, %rdi
xorl %eax, %eax
callq 0x2330
movl 0x60(%rbx), %edx
leaq 0x3dda(%rip), %rsi      # 0x11b35
movq %r15, %rdi
xorl %eax, %eax
callq 0x2330
movl 0x60(%rbx), %edx
leaq 0x3ddc(%rip), %rsi      # 0x11b4b
leaq -0xe0(%rbp), %rdi
xorl %eax, %eax
callq 0x2080
movq -0x38(%rbp), %rax
movq (%rax), %rbx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x94e4
leaq -0xa0(%rbp), %rsi
movq %rbx, (%rsi)
movq -0x58(%rbp), %rbx
movq (%r14), %rax
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xfc18
incl 0x60(%rbx)
cmpb $0x1, 0x75(%rbx)
jne 0xde48
leaq 0x3d88(%rip), %rdi      # 0x11b50
pushq $0x14
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3d84(%rip), %rdi      # 0x11b65
pushq $0x1c
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3b49(%rip), %rdi      # 0x1193f
pushq $0x24
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3b59(%rip), %rdi      # 0x11964
pushq $0x1c
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3b61(%rip), %rdi      # 0x11981
pushq $0x11
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3fcb(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
jmp 0xdecd
cmpb $0x1, 0x76(%rbx)
jne 0xdecd
cmpb $0x0, 0xb0(%rbx)
je 0xde6a
leaq 0x3d74(%rip), %rdi      # 0x11bd2
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
movq -0x30(%rbp), %r15
jmp 0xde3b
leaq 0x3d11(%rip), %rdi      # 0x11b82
pushq $0x1c
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq -0x30(%rbp), %r15
movq %r15, %rcx
callq 0x2440
leaq 0x3d11(%rip), %rdi      # 0x11b9f
pushq $0x15
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3d12(%rip), %rdi      # 0x11bb5
pushq $0x1c
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x3f48(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
movb $0x1, 0xb0(%rbx)
leaq 0x3d11(%rip), %rdi      # 0x11be5
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2440
cmpb $0x1, 0x6a(%rbx)
jne 0xe058
leaq 0x3cfb(%rip), %rdi      # 0x11bee
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2440
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rcx
testq %rcx, %rcx
je 0xe094
movq 0x58(%rcx), %rax
subq 0x50(%rcx), %rax
movl $0xb8, %ecx
cqto
idivq %rcx
xorl %r14d, %r14d
testl %eax, %eax
movl $0x0, %ecx
movq %rax, %r13
cmovgl %eax, %ecx
movq %rcx, -0x48(%rbp)
xorl %r12d, %r12d
cmpq -0x48(%rbp), %r14
je 0xe0f0
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rax), %rax
imulq $0xb8, %r14, %rcx
leaq (%rax,%rcx), %r15
cmpb $0x1, 0xa9(%rax,%rcx)
jne 0xdfc6
cmpb $0x1, 0x77(%rbx)
jne 0xe003
cvtss2sd 0x20(%r15), %xmm0
movq -0x30(%rbp), %rdi
leaq 0x3c94(%rip), %rsi      # 0x11c1b
movb $0x1, %al
callq 0x2330
xorl %eax, %eax
movl %eax, %ebx
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0xe015
leaq (%rax,%rbx,8), %rsi
movzbl 0xaa(%r15), %r8d
movq -0x30(%rbp), %rdi
movq -0x58(%rbp), %rdx
xorl %ecx, %ecx
callq 0xeb62
leal 0x1(%rbx), %eax
jmp 0xdf90
cmpb $0x1, 0xa8(%r15)
movzbl 0xaa(%r15), %r8d
jne 0xe03f
movq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %rbx, %rdx
pushq $0x1
popq %rcx
callq 0xeb62
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
movl %r14d, 0xc(%rax)
movb $0x1, %r12b
movl %r14d, -0x40(%rbp)
jmp 0xe050
movq 0x8(%r15), %rsi
movzbl 0xaa(%r15), %r8d
movq -0x30(%rbp), %rdi
jmp 0xe046
leaq 0x3c2a(%rip), %rdi      # 0x11c46
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
movq -0x30(%rbp), %rbx
movq %rbx, %rcx
callq 0x2440
pushq $0x7d
popq %rdi
movq %rbx, %rsi
callq 0x22e0
movq -0x58(%rbp), %rbx
jmp 0xe050
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0xeb62
incq %r14
jmp 0xdf3e
cmpb $0x1, 0x6c(%rbx)
jne 0xe081
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
testq %rax, %rax
je 0xe0b6
movq 0x38(%rax), %rcx
cmpq %rcx, 0x40(%rax)
je 0xe0b6
movq (%rcx), %rax
movq %rax, -0x68(%rbp)
jmp 0xe0b6
testb $0x1, %r12b
je 0xe0c5
leaq -0x60(%rbp), %rsi
pushq $0x1
popq %rcx
movq -0x30(%rbp), %rdi
jmp 0xe0e5
cmpb $0x1, 0x6a(%rbx)
jne 0xe0b6
testb $0x1, %r12b
je 0xe0b6
leaq -0x60(%rbp), %rsi
pushq $0x1
popq %rcx
movq -0x30(%rbp), %rdi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0xeb62
leaq -0x68(%rbp), %rsi
movq -0x30(%rbp), %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
jmp 0xe0e8
leaq 0x3ba5(%rip), %rsi      # 0x11c71
leaq -0xa0(%rbp), %r14
movq %r14, %rdi
callq 0x94e4
pushq $0x1
popq %rcx
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0xeb62
cmpb $0x1, 0x6a(%rbx)
jne 0xe3d2
pushq $0x5d
popq %rdi
movq -0x30(%rbp), %r14
movq %r14, %rsi
callq 0x22e0
movq -0x38(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0xe398
leaq 0x3b55(%rip), %rdi      # 0x11c77
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x2440
xorl %eax, %eax
testl %r13d, %r13d
movl $0x0, %ecx
movq %rcx, -0x48(%rbp)
cmovlel %eax, %r13d
movq %r13, -0x78(%rbp)
imulq $0xb8, %r13, %rax
movq %rax, -0x80(%rbp)
leaq 0x3b27(%rip), %rbx      # 0x11c7f
leaq 0x3b26(%rip), %rax      # 0x11c85
xorl %r12d, %r12d
movq %r14, %r13
movq %rax, %r14
cmpq %r12, -0x80(%rbp)
je 0xe275
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rax), %r15
movq 0x70(%r15,%r12), %rax
movq 0xb0(%r15,%r12), %r13
orq 0x50(%r15,%r12), %rax
setne %sil
testq %r12, %r12
jne 0xe208
movb %sil, -0x39(%rbp)
movq %rbx, %r14
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x351e(%rip), %rsi      # 0x116d2
leaq -0x49(%rbp), %rdx
callq 0x5b0c
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
callq 0xc6ba
movq -0x70(%rbp), %rax
cmpq 0xb0(%r15,%r12), %rax
je 0xe1dc
movq %r14, %rbx
jmp 0xe1f1
cmpb $0x0, 0xa8(%r15,%r12)
movq %r14, %rbx
jne 0xe1f1
leaq 0x2505(%rip), %r13      # 0x106f6
leaq 0x3a8d(%rip), %r14      # 0x11c85
leaq -0xa0(%rbp), %rdi
callq 0x2120
movb -0x39(%rbp), %sil
movq -0x58(%rbp), %rax
testb $0x1, 0x76(%rax)
jne 0xe21b
leaq 0x34b1(%rip), %rax      # 0x116ca
jmp 0xe21d
xorl %eax, %eax
movq %r12, %rcx
orq %r13, %rcx
cmovneq %r13, %rax
leaq 0x34a4(%rip), %rdx      # 0x116d2
testq %rax, %rax
je 0xe236
movq %rax, %rdx
movq -0x48(%rbp), %rax
orb %sil, %al
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2330
movq 0x28(%r15,%r12), %rdx
movq 0x30(%r15,%r12), %rcx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2330
addq $0xb8, %r12
jmp 0xe168
leaq 0x3823(%rip), %rdi      # 0x11a9f
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2440
testb $0x1, -0x48(%rbp)
je 0xe3c7
leaq 0x39fa(%rip), %rdi      # 0x11c95
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2440
pushq $0x70
popq %r12
xorl %r15d, %r15d
movq -0x30(%rbp), %rbx
cmpq %r15, -0x78(%rbp)
je 0xe3b2
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rax), %r13
movq -0x28(%r13,%r12), %rax
movq -0x8(%r13,%r12), %r14
cmpq $0x0, (%r13,%r12)
jne 0xe2eb
cmpq $0x0, -0x20(%r13,%r12)
je 0xe385
movq %rax, -0x48(%rbp)
movq %rbx, %rdi
leaq 0x39b0(%rip), %rsi      # 0x11ca9
movl %r15d, %edx
xorl %eax, %eax
callq 0x2330
cmpq $0x0, -0x20(%r13,%r12)
je 0xe320
movq %rbx, %rdi
leaq 0x39a6(%rip), %rsi      # 0x11cbb
movq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x2330
cmpq $0x0, (%r13,%r12)
movq %rbx, %r13
je 0xe34d
testq %r14, %r14
leaq 0x3a7a(%rip), %rax      # 0x11daf
cmoveq %rax, %r14
movq %r13, %rdi
leaq 0x397d(%rip), %rsi      # 0x11cc0
movq %r14, %rdx
xorl %eax, %eax
callq 0x2330
movq %r13, %rdi
leaq 0x3976(%rip), %rsi      # 0x11ccd
movl %r15d, %edx
xorl %eax, %eax
callq 0x2330
leaq 0x3a98(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2440
incq %r15
addq $0xb8, %r12
jmp 0xe2b4
leaq 0x396c(%rip), %rdi      # 0x11cf8
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
movq -0x30(%rbp), %r13
jmp 0xe36e
testb $0x1, %r12b
movq %r14, %r13
je 0xe3c7
movq 0x98(%rbx), %rdi
movq %r13, %rsi
callq 0x2280
jmp 0xe3c7
leaq 0x36e6(%rip), %rdi      # 0x11a9f
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x2440
pushq $0x7d
popq %rdi
movq %r13, %rsi
callq 0x22e0
leaq 0x3a27(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq -0x30(%rbp), %r15
movq %r15, %rcx
callq 0x2440
movq -0x38(%rbp), %rbx
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
sarq %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r12
leaq 0x38f2(%rip), %rdi      # 0x11cfe
pushq $0x1b
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x38f5(%rip), %rdi      # 0x11d1a
pushq $0x1c
popq %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x2440
movq 0x80(%rbx), %rbx
testq %rbx, %rbx
je 0xe49b
leaq 0x38f1(%rip), %rsi      # 0x11d37
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x94e4
movq (%r14), %rax
cmpq (%rbx), %rax
je 0xe486
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rbx
leaq 0x38cd(%rip), %rsi      # 0x11d3c
leaq -0xa0(%rbp), %r14
movq %r14, %rdi
callq 0x94e4
movq (%r14), %rax
cmpq (%rbx), %rax
jne 0xe49b
leaq 0x38b7(%rip), %rdi      # 0x11d44
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2440
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rbx
testq %rbx, %rbx
je 0xe4de
leaq 0x38a0(%rip), %rsi      # 0x11d52
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x94e4
movq (%r14), %rax
cmpq (%rbx), %rax
jne 0xe4de
leaq 0x3887(%rip), %rdi      # 0x11d57
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2440
leaq 0x387d(%rip), %rdi      # 0x11d62
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x2440
leal -0x1(%r12), %r14d
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
movq -0x38(%rbp), %rax
movq 0x20(%rax), %r15
leaq 0x3870(%rip), %rbx      # 0x11d80
xorl %r13d, %r13d
cmpl %r13d, %r12d
je 0xe54b
movzwl (%r15), %edx
movzwl 0x2(%r15), %ecx
movzwl 0x4(%r15), %r8d
addq $0x6, %r15
cmpl %r13d, %r14d
movq %rbx, %rsi
leaq 0x383a(%rip), %rax      # 0x11d71
cmoveq %rax, %rsi
movq -0x30(%rbp), %rdi
xorl %eax, %eax
callq 0x2330
incl %r13d
jmp 0xe513
movq -0x38(%rbp), %rdi
addq $0x38, %rdi
movq -0x30(%rbp), %rbx
movq %rbx, %rsi
movl -0x40(%rbp), %edx
movq -0x58(%rbp), %rcx
callq 0xecd6
leaq 0x3505(%rip), %rdi      # 0x11a72
pushq $0x4
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2440
leaq 0x387a(%rip), %rdi      # 0x11e00
pushq $0x2
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2440
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2120
movq %rbx, %rdi
callq 0x23e0
nop