// File: /workspace/github_cpp_makefile_star2_O1/Chrom3D[P]Chrom3D/src/Chrom3D.cpp
// Function: main
int main(int argc, char** argv) {
  Args args = parseArguments(argc,argv);
  string fileName = args.fileName;
  
  Model model(args.modelName, args.seed);
  model.setNucleusRadius(args.radius);

  if(args.occupancy > 0) {
    model.readGtrack(fileName, true, args.occupancy);
  }
  else {
    model.readGtrack(fileName, false);
  }

  //if(args.centerConstraint) {
  //  model.addCenterConstraints();
  //}
  
  if(args.nucleusConstraint) {
    model.addNucleusConstraints();
  }

  
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "crankshaft") ==  args.excludeMoves.end()) {
    model.addRandomizer(new CrankShaftRandomizer());
  }
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "microcrank") ==  args.excludeMoves.end()) {
    model.addRandomizer(new MicroCrankShaftRandomizer());
  }
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "armwiggle") ==  args.excludeMoves.end()) {
    model.addRandomizer(new ArmWiggleRandomizer());
  }
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "armrotate") ==  args.excludeMoves.end()) {
    model.addRandomizer(new ArmRotateRandomizer());
  }
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "translate") ==  args.excludeMoves.end()) {
    model.addRandomizer(new TranslateRandomizer(1.0));
  }
  if( find(args.excludeMoves.begin(), args.excludeMoves.end(), "rotate") ==  args.excludeMoves.end()) {
    model.addRandomizer(new RotationRandomizer());
  }
  
  //model.buildHashMap();

  MCMC mcmc(model);
  bool success;
  uint Niter=args.nIter;
  double maxTemp = args.maxtemp;
  double coolRate = args.coolrate; // Number between 0 and 1, giving the rate of cooling at each step
  double temp=maxTemp;

  uint verbosity = (args.verbose == 0) ? args.nIter+1 : args.verbose;

   
  if(args.verbose != 0) {
    //cerr << "0 " << model.getLossScore(INTERACTION_INTRA) << " " << model.getLossScore(INTERACTION_INTER) << " " << model.getLossScore(PERIPHERY) << " " << model.getLossScore(CENTER) << " " << model.getLossScore(BOUNDARY) << " " << model.getLossScore(NUCLEUS) << " " << model.getLossScore(INTERACTION_DIST) << " " << model.getLossScore() << endl;
cerr << "0 " << model.getLossScore() << endl;
  }
  
  
  for(uint i=1; i!=args.nIter+1; i++) {
    temp *= (1-coolRate);
    success = mcmc.doMetropolisHastingsStep(temp); //simulated annealing when T < 1. When T = 1 that is Metropolis Hastings
    assert(success);
    if (i % verbosity == 0) {
      if(args.printStructures) {
	model.writeCMM(args.modelName + "_iter_" + to_string(i) + ".cmm");
      }
      //cerr << i << " " << model.getLossScore(INTERACTION_INTRA) << " " << model.getLossScore(INTERACTION_INTER) << " " << model.getLossScore(PERIPHERY) << " " << model.getLossScore(CENTER) << " " << model.getLossScore(INTERACTION_DIST) << " " << model.getLossScore() << endl;
      cerr << i << " " << model.getLossScore() << endl;
    }
  }

  if(args.outFile != "/dev/null") {
    model.writeCMM(args.outFile);
  }
  else {
    cout << model.getCMM();
  }

  /*
  if(args.pdbStructures)
  {
    boost::filesystem::path dir(args.modelName);
    boost::filesystem::create_directory(dir);
    model.writePDB(args.modelName);
  }
  */

  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd28, %rsp            # imm = 0xD28
movq %rsi, %rdx
movl %edi, %esi
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x1b2a8
leaq 0xb0(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0xa53a
leaq 0x1a8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
addq %rsi, %rdx
leaq 0x198(%rsp), %rdi
callq 0xa53a
movl 0x100(%rsp), %edx
leaq 0x1f8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0xe0cc
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x1da28
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x6310
movsd 0x108(%rsp), %xmm0
leaq 0x1f8(%rsp), %rdi
callq 0xf170
movsd 0x128(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1daaa
leaq 0x1e8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1d8(%rsp), %rdi
callq 0xa53a
movsd 0x128(%rsp), %xmm0
leaq 0x1f8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
movl $0x1, %edx
callq 0x11722
movq 0x1d8(%rsp), %rdi
jmp 0x1dafd
leaq 0x1c8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1b8(%rsp), %rdi
callq 0xa53a
leaq 0x1f8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
movsd 0xd812(%rip), %xmm0     # 0x2b300
xorl %edx, %edx
callq 0x11722
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1db0d
movq (%r14), %rsi
incq %rsi
callq 0x6310
cmpb $0x1, 0x171(%rsp)
jne 0x1db2c
leaq 0x1f8(%rsp), %rdi
movsd 0xb4e1(%rip), %xmm0     # 0x29008
callq 0x16230
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdcc3(%rip), %rdx      # 0x2b806
callq 0x28369
cmpq 0x160(%rsp), %rax
jne 0x1db82
movl $0x8, %edi
callq 0x6300
leaq 0x195e5(%rip), %rcx     # 0x37148
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb48e(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfbea
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdc78(%rip), %rdx      # 0x2b811
callq 0x28369
cmpq 0x160(%rsp), %rax
jne 0x1dbd8
movl $0x8, %edi
callq 0x6300
leaq 0x19637(%rip), %rcx     # 0x371f0
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb438(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfbea
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdc2d(%rip), %rdx      # 0x2b81c
callq 0x18c53
cmpq 0x160(%rsp), %rax
jne 0x1dc2e
movl $0x8, %edi
callq 0x6300
leaq 0x19581(%rip), %rcx     # 0x37190
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb3e2(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfbea
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdbe1(%rip), %rdx      # 0x2b826
callq 0x18c53
cmpq 0x160(%rsp), %rax
jne 0x1dc84
movl $0x8, %edi
callq 0x6300
leaq 0x1955b(%rip), %rcx     # 0x371c0
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb38c(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfbea
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdb95(%rip), %rdx      # 0x2b830
callq 0x18c53
cmpq 0x160(%rsp), %rax
jne 0x1dcdf
movl $0x10, %edi
callq 0x6300
movq %rax, %r14
movsd 0xb349(%rip), %xmm0     # 0x29008
movq %rax, %rdi
callq 0xd0b4
leaq 0x1f8(%rsp), %rdi
movsd 0xb331(%rip), %xmm0     # 0x29008
movq %r14, %rsi
callq 0xfbea
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xdb33(%rip), %rdx      # 0x2b829
callq 0x18e25
cmpq 0x160(%rsp), %rax
jne 0x1dd35
movl $0x8, %edi
callq 0x6300
leaq 0x1950a(%rip), %rcx     # 0x37220
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb2db(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfbea
leaq 0x98(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x1b0b8
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movl 0x130(%rsp), %eax
movl 0x110(%rsp), %r15d
incl %r15d
testl %eax, %eax
cmovnel %eax, %r15d
jne 0x1ddf0
cmpl $0x0, 0x110(%rsp)
jne 0x1de2e
leaq 0xe0(%rsp), %rdi
leaq 0xd6c8(%rip), %rsi      # 0x2b467
callq 0x6100
testl %eax, %eax
jne 0x1e156
leaq 0x8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x10f5e
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x1a1b1(%rip), %rdi     # 0x37f80
callq 0x6370
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e1b4
movq 0x18(%rsp), %rsi
jmp 0x1e1ac
movq 0x1a1e9(%rip), %rdi     # 0x37fe0
leaq 0xdc3f(%rip), %rsi      # 0x2ba3d
movl $0x2, %edx
callq 0x6370
leaq 0x1f8(%rsp), %rdi
callq 0xf504
movq 0x1a1c4(%rip), %rdi     # 0x37fe0
callq 0x64d0
movq %rax, %rdi
callq 0x6190
jmp 0x1dd82
movsd 0xb1d2(%rip), %xmm0     # 0x29008
subsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movl $0x1, %r14d
leaq 0x98(%rsp), %rbx
movsd 0x70(%rsp), %xmm0
mulsd 0x48(%rsp), %xmm0
movq %rbx, %rdi
movsd %xmm0, 0x70(%rsp)
movl $0x2710, %esi           # imm = 0x2710
callq 0x1b0bc
testb %al, %al
je 0x1e1bb
movl %r14d, %eax
xorl %edx, %edx
divl %r15d
testl %edx, %edx
jne 0x1e13c
cmpb $0x1, 0x172(%rsp)
jne 0x1e0d7
leaq 0x60(%rsp), %r12
movq %r12, 0x50(%rsp)
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0xa53a
movq %rbp, %rdi
leaq 0xdba6(%rip), %rsi      # 0x2ba6f
callq 0x6630
movl $0x1, %eax
cmpl $0xa, %r14d
jb 0x1df1e
movl $0x4, %eax
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0x1df17
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x1df1c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x1df1e
movl %ecx, %edx
movl $0xd1b71759, %esi       # imm = 0xD1B71759
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x1dee1
addl $-0x3, %eax
jmp 0x1df1e
addl $-0x2, %eax
jmp 0x1df1e
decl %eax
movl %eax, %esi
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
xorl %edx, %edx
callq 0x6380
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %esi
movl %r14d, %edx
callq 0x275fd
movq 0x50(%rsp), %rcx
movl $0xf, %esi
cmpq %r12, %rcx
je 0x1df5b
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %r8
movq 0x30(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x1df89
movl $0xf, %esi
leaq 0x38(%rsp), %rdi
cmpq %rdi, 0x28(%rsp)
je 0x1df84
movq 0x38(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x1df9a
movq 0x28(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x6110
jmp 0x1dfa8
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6350
leaq 0x18(%rsp), %rsi
movq %rsi, 0x8(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x1dfcd
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1dfd5
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x8(%rsp), %rdi
leaq 0xda78(%rip), %rsi      # 0x2ba76
callq 0x6630
leaq 0x88(%rsp), %rsi
movq %rsi, 0x78(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1e031
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x1e039
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x80(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x1f8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1163a
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1e088
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1e0a4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1e0c0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e0d7
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6310
movl %r14d, %esi
movq 0x19eff(%rip), %rdi     # 0x37fe0
callq 0x6230
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xdda2(%rip), %rsi      # 0x2be9a
callq 0x6370
leaq 0x1f8(%rsp), %rdi
callq 0xf504
movq %r12, %rdi
callq 0x64d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x62f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x6030
movq %rax, %rdi
callq 0x6240
leal 0x1(%r14), %eax
cmpl 0x110(%rsp), %r14d
movl %eax, %r14d
jne 0x1de50
jmp 0x1dd90
leaq 0x188(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x178(%rsp), %rdi
callq 0xa53a
leaq 0x1f8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x1163a
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e1b4
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x6310
xorl %edi, %edi
callq 0x63a0
leaq 0xd87e(%rip), %rdi      # 0x2ba40
leaq 0xd87f(%rip), %rsi      # 0x2ba48
leaq 0xd888(%rip), %rcx      # 0x2ba58
movl $0xd4, %edx
callq 0x6210
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1e204
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e204
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1e225
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e225
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1e246
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e246
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
jne 0x1e26b
jmp 0x1e310
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e310
movq 0x60(%rsp), %rsi
jmp 0x1e303
jmp 0x1e30d
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e310
movq 0x188(%rsp), %rsi
jmp 0x1e303
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e310
movq 0x18(%rsp), %rsi
jmp 0x1e303
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0x1e306
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
jmp 0x1e30d
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e310
movq 0x1c8(%rsp), %rsi
jmp 0x1e303
movq %rax, %rbx
movq 0x1d8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e310
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e310
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x20d7e
jmp 0x1e344
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e344
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e344
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1e366
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1e366
movq %rax, %rbx
leaq 0x158(%rsp), %r14
movq %r14, %rdi
callq 0x889e
movq -0x20(%r14), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x1e397
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e3b8
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e3d9
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x6310
movq %rbx, %rdi
callq 0x65b0
nop