// File: /workspace/github_cpp_makefile_star2_O3/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 0x1af08
leaq 0xb0(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0xa4a2
leaq 0x1a8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
addq %rsi, %rdx
leaq 0x198(%rsp), %rdi
callq 0xa4a2
movl 0x100(%rsp), %edx
leaq 0x1f8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0xe02c
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x1d688
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x6310
movsd 0x108(%rsp), %xmm0
leaq 0x1f8(%rsp), %rdi
callq 0xf100
movsd 0x128(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1d70a
leaq 0x1e8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1d8(%rsp), %rdi
callq 0xa4a2
movsd 0x128(%rsp), %xmm0
leaq 0x1f8(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
movl $0x1, %edx
callq 0x11636
movq 0x1d8(%rsp), %rdi
jmp 0x1d75d
leaq 0x1c8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1b8(%rsp), %rdi
callq 0xa4a2
leaq 0x1f8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
movsd 0xdbb2(%rip), %xmm0     # 0x2b300
xorl %edx, %edx
callq 0x11636
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1d76d
movq (%r14), %rsi
incq %rsi
callq 0x6310
cmpb $0x1, 0x171(%rsp)
jne 0x1d78c
leaq 0x1f8(%rsp), %rdi
movsd 0xb881(%rip), %xmm0     # 0x29008
callq 0x15ea4
movq 0x158(%rsp), %rdi
movq 0x160(%rsp), %rsi
leaq 0xe063(%rip), %rdx      # 0x2b806
callq 0x27f1f
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1d7ed
movl $0x8, %edi
callq 0x6300
leaq 0x199aa(%rip), %rcx     # 0x37170
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb82b(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfb82
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdi
leaq 0xe015(%rip), %rdx      # 0x2b811
callq 0x27f1f
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1d846
movl $0x8, %edi
callq 0x6300
leaq 0x199f9(%rip), %rcx     # 0x37218
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb7d2(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfb82
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdi
leaq 0xdfc7(%rip), %rdx      # 0x2b81c
callq 0x18915
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1d89f
movl $0x8, %edi
callq 0x6300
leaq 0x19940(%rip), %rcx     # 0x371b8
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb779(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfb82
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdi
leaq 0xdf78(%rip), %rdx      # 0x2b826
callq 0x18915
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1d8f8
movl $0x8, %edi
callq 0x6300
leaq 0x19917(%rip), %rcx     # 0x371e8
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb720(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfb82
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdi
leaq 0xdf29(%rip), %rdx      # 0x2b830
callq 0x18915
movq 0x160(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1d956
movl $0x10, %edi
callq 0x6300
movq %rax, %r14
movsd 0xb6da(%rip), %xmm0     # 0x29008
movq %rax, %rdi
callq 0xd034
leaq 0x1f8(%rsp), %rdi
movsd 0xb6c2(%rip), %xmm0     # 0x29008
movq %r14, %rsi
callq 0xfb82
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdi
leaq 0xdec4(%rip), %rdx      # 0x2b829
callq 0x18af7
cmpq 0x160(%rsp), %rax
jne 0x1d9a4
movl $0x8, %edi
callq 0x6300
leaq 0x198c3(%rip), %rcx     # 0x37248
addq $0x10, %rcx
movq %rcx, (%rax)
leaq 0x1f8(%rsp), %rdi
movsd 0xb66c(%rip), %xmm0     # 0x29008
movq %rax, %rsi
callq 0xfb82
leaq 0x98(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x1ad1c
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x130(%rsp), %ecx
movl 0x110(%rsp), %eax
leal 0x1(%rax), %r15d
testl %ecx, %ecx
cmovnel %ecx, %r15d
jne 0x1da59
testl %eax, %eax
jne 0x1da9e
leaq 0xe0(%rsp), %rdi
leaq 0xda5f(%rip), %rsi      # 0x2b467
callq 0x6100
testl %eax, %eax
jne 0x1ddbb
leaq 0x8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x10e64
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x1a548(%rip), %rdi     # 0x37f80
callq 0x6370
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1de19
movq 0x18(%rsp), %rsi
jmp 0x1de11
movq 0x1a580(%rip), %rdi     # 0x37fe0
leaq 0xdfd6(%rip), %rsi      # 0x2ba3d
movl $0x2, %edx
callq 0x6370
leaq 0x1f8(%rsp), %rdi
callq 0xf4aa
movq 0x1a55b(%rip), %rdi     # 0x37fe0
callq 0x64d0
movq %rax, %rdi
callq 0x6190
movl 0x110(%rsp), %eax
jmp 0x1d9f1
movsd 0xb562(%rip), %xmm0     # 0x29008
subsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x1, %ebx
leaq 0x98(%rsp), %r14
movsd 0x70(%rsp), %xmm0
mulsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movsd %xmm0, 0x70(%rsp)
movl $0x2710, %esi           # imm = 0x2710
callq 0x1ad20
testb %al, %al
je 0x1de20
movl %ebx, %eax
xorl %edx, %edx
divl %r15d
testl %edx, %edx
jne 0x1dda4
cmpb $0x1, 0x172(%rsp)
jne 0x1dd40
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 0xa4a2
movq %rbp, %rdi
leaq 0xdf38(%rip), %rsi      # 0x2ba6f
callq 0x6630
movl $0x1, %eax
cmpl $0xa, %ebx
jb 0x1db8a
movl $0x4, %eax
movl %ebx, %ecx
cmpl $0x63, %ecx
jbe 0x1db83
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x1db88
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x1db8a
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 0x1db4d
addl $-0x3, %eax
jmp 0x1db8a
addl $-0x2, %eax
jmp 0x1db8a
decl %eax
movl %eax, %esi
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x6380
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %esi
movl %ebx, %edx
callq 0x271dd
movq 0x50(%rsp), %rcx
movl $0xf, %edi
cmpq %r12, %rcx
je 0x1dbc6
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %r8
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x1dbf7
movl $0xf, %edi
leaq 0x40(%rsp), %r9
cmpq %r9, %rsi
je 0x1dbf2
movq 0x40(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x1dc03
leaq 0x50(%rsp), %rdi
callq 0x6110
jmp 0x1dc11
leaq 0x30(%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 0x1dc36
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1dc3e
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 0xde0f(%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 0x1dc9a
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x1dca2
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 0x1154e
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1dcf1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1dd0d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1dd29
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6310
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1dd40
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6310
movl %ebx, %esi
movq 0x1a297(%rip), %rdi     # 0x37fe0
callq 0x6230
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xe13a(%rip), %rsi      # 0x2be9a
callq 0x6370
leaq 0x1f8(%rsp), %rdi
callq 0xf4aa
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(%rbx), %eax
cmpl 0x110(%rsp), %ebx
movl %eax, %ebx
jne 0x1dabf
jmp 0x1d9f9
leaq 0x188(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x178(%rsp), %rdi
callq 0xa4a2
leaq 0x1f8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x1154e
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x1de19
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x6310
xorl %edi, %edi
callq 0x63a0
leaq 0xdc19(%rip), %rdi      # 0x2ba40
leaq 0xdc1a(%rip), %rsi      # 0x2ba48
leaq 0xdc23(%rip), %rcx      # 0x2ba58
movl $0xd4, %edx
callq 0x6210
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1de69
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1de69
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1de8a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1de8a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1deab
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1deab
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
jne 0x1ded0
jmp 0x1df75
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1df75
movq 0x60(%rsp), %rsi
jmp 0x1df68
jmp 0x1df72
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r14, %rdi
je 0x1df75
movq 0x188(%rsp), %rsi
jmp 0x1df68
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1df75
movq 0x18(%rsp), %rsi
jmp 0x1df68
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0x1df6b
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
jmp 0x1df72
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1df75
movq 0x1c8(%rsp), %rsi
jmp 0x1df68
movq %rax, %rbx
movq 0x1d8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1df75
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1df75
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x208ea
jmp 0x1dfa9
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r14, %rdi
je 0x1dfa9
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1dfa9
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1dfcb
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x6310
jmp 0x1dfcb
movq %rax, %rbx
leaq 0x158(%rsp), %r14
movq %r14, %rdi
callq 0x8860
movq -0x20(%r14), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x1dffc
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0xf0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e01d
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x6310
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e03e
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x6310
movq %rbx, %rdi
callq 0x65b0