// File: Luthaf[P]zeopp/networkstorage.cc
// Function: connect_molecules(std::vector<MOLECULE, std::allocator<MOLECULE>>*, ATOM_NETWORK*, std::vector<MOLECULE, std::allocator<MOLECULE>>*, std::vector<CONNECTION, std::allocator<CONNECTION>>*, double*, int, bool, bool, bool, double)
ATOM_NETWORK connect_molecules(vector<MOLECULE> *molecules, ATOM_NETWORK *cell, vector<MOLECULE> *assembled_molecules, vector<CONNECTION> *two_way_connections, double *mean_edge_length, int dimensionality, bool a_periodicity, bool b_periodicity, bool c_periodicity, double unit_edge_length) {
  bool verbose = false;
  ATOM_NETWORK unit_cell_any_matrix;
  //1) keep track of which molecules have been fixed in place already, and which connections were made
  vector<bool> placed;
  int num_mols = molecules->size();
  for(int i=0; i<num_mols; i++) placed.push_back(false);
  vector<bool> connected;
  int num_cons = two_way_connections->size();
  for(int i=0; i<num_cons; i++) connected.push_back(false);
  //2) fix each molecule in place
  for(int i=0; i<num_mols; i++) assembled_molecules->push_back(molecules->at(i)); //this vector starts out the same as the molecules vector, but the molecules are then each shifted into their relative positions to form the assembled_molecules
  int num_placed = 0;
  bool placed_ok = true;
  double sum_edge_lengths = 0;
  if(verbose) printf("DEBUG: about to place molecules\n");
  while(num_placed<num_mols && placed_ok) {
    int new_num_placed = place_molecule(molecules, two_way_connections, cell, &placed, &connected, assembled_molecules, num_placed, &sum_edge_lengths);
    if(verbose) printf("DEBUG: after calling place_molecule, %d molecules have been placed\n", new_num_placed);
    if(new_num_placed==num_placed+1) {
      num_placed = new_num_placed;
    } else placed_ok = false;
  }
  if(num_placed>1) (*mean_edge_length) = ((double)(sum_edge_lengths))/((double)(num_placed-1));
  if(num_placed!=num_mols) {
//    printf("ERROR: only %d of %d molecules were fixed in place during connection-based assembly method - this method should have been automatically bypassed if a disconnected net was provided\n", num_placed, num_mols);
//    exit(EXIT_FAILURE);
if(verbose) printf("NOTICE: only %d of %d molecules were fixed in place during connection-based assembly method - returning empty framework\n", num_placed, num_mols);
    return unit_cell_any_matrix;
  } else {
    if(verbose) printf("DEBUG: all %d of %d molecules were fixed in place successfully!\n", num_placed, num_mols);
  }

  //3) new new idea - look for loops in the two-way connections, and calculate their shifts, using this information to determine the net?
  vector<bool> edge_traversed;
  for(int i=0; i<num_cons; i++) edge_traversed.push_back(false);
  vector<int> vertices_visited;
  vector<int> loops_a, loops_b, loops_c;
  vector<XYZ> loops_xyz;
  vector<int> unit_cell_vector_IDs;
  vector<XYZ> unit_cell_vectors;
  vector<int> vertex_visit_a, vertex_visit_b, vertex_visit_c;
  vector<XYZ> vertex_visit_xyz;
  vector<bool> vertex_visited;
  int num_v = cell->vertices.size();
  for(int i=0; i<num_v; i++) {vertex_visited.push_back(false); vertex_visit_a.push_back(0); vertex_visit_b.push_back(0); vertex_visit_c.push_back(0); vertex_visit_xyz.push_back(origin);}
  bool found_all_uc_vectors = recursive_find_loops(0, 0, 0, 0, origin, two_way_connections, assembled_molecules, &edge_traversed, &vertex_visit_a, &vertex_visit_b, &vertex_visit_c, &vertex_visit_xyz, &vertex_visited, &loops_a, &loops_b, &loops_c, &loops_xyz, &unit_cell_vector_IDs, &unit_cell_vectors, dimensionality);
if(verbose) {
  int num_loops = loops_xyz.size();
  for(int i=0; i<num_loops; i++) {
    XYZ l = loops_xyz.at(i);
    printf("DEBUG: unique loop was found with periodicity (%d %d %d) and Cartesian shift %.3f %.3f %.3f\n", loops_a.at(i), loops_b.at(i), loops_c.at(i), l.x, l.y, l.z);
  }
}
  if(found_all_uc_vectors) {
if(verbose) printf("DEBUG: found all uc vectors from loop analysis\n");
  } else {
    printf("ERROR: did not find all uc vectors from loop analysis\n");
    exit(EXIT_FAILURE);
  }

  //if we are dealing with a 2D net (a layer), then we need to introduce a periodic connection running in that direction
  if(dimensionality==2) {
if(verbose) printf("DEBUG: imposing a three dimensional structure on this two-dimensional framework in order to define a unit cell\n");
    int num_override = 0;
    if(!a_periodicity) {
      XYZ vec((*mean_edge_length)*cell->a/unit_edge_length,0,0);
      unit_cell_vectors.push_back(vec);
      unit_cell_vector_IDs.push_back(0);
      num_override++;
    }
    if(!b_periodicity) {
      XYZ vec(0,(*mean_edge_length)*cell->b/unit_edge_length,0);
      unit_cell_vectors.push_back(vec);
      unit_cell_vector_IDs.push_back(1);
      num_override++;
    }
    if(!c_periodicity) {
      XYZ vec(0,0,(*mean_edge_length)*cell->c/unit_edge_length);
      unit_cell_vectors.push_back(vec);
      unit_cell_vector_IDs.push_back(2);
      num_override++;
    }
    if(num_override!=1) {
      printf("ERROR: was expecting to override exactly 1 cell side length value, but %d were overwritten - this is a bug\n", num_override);
      exit(EXIT_FAILURE);
    }
  }
  vector<XYZ> sorted_unit_cell_vectors;
  for(int i=0; i<3; i++) {
    bool pushed = false;
    for(int j=0; j<3 && !pushed; j++) {
      if(unit_cell_vector_IDs.at(j)==i) {
        sorted_unit_cell_vectors.push_back(unit_cell_vectors.at(j));
        pushed = true;
      }
    }
  }
  create_unit_cell_from_vectors(&sorted_unit_cell_vectors, &unit_cell_any_matrix);

  //6) put atoms into the cell, converting to fractional coords
  put_atoms_in_atom_network(&unit_cell_any_matrix, assembled_molecules);
  //7) that ATOM_NETWORK was constructed with matrices based on periodic connections, that may not conform to the standard axes relations - build a new cell with a normal matrix, based on this one, and copy the atom fractional coords into this system
  ATOM_NETWORK unit_cell;
  unit_cell_any_matrix.copy(&unit_cell);
  unit_cell.make(unit_cell_any_matrix.a, unit_cell_any_matrix.b, unit_cell_any_matrix.c, unit_cell_any_matrix.alpha, unit_cell_any_matrix.beta, unit_cell_any_matrix.gamma);
  return unit_cell;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x888, %rsp            # imm = 0x888
movq %rcx, -0x7a0(%rbp)
movq %rdx, -0x798(%rbp)
movq %rsi, %r10
movq -0x7a0(%rbp), %rsi
movq %rdi, %r11
movq -0x798(%rbp), %rdi
movq %r11, -0x790(%rbp)
movq %r11, %rax
movq %rax, -0x788(%rbp)
movb 0x28(%rbp), %al
movb 0x20(%rbp), %cl
movb 0x18(%rbp), %dl
movl 0x10(%rbp), %ebx
movq %r11, -0x10(%rbp)
movq %r10, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
andb $0x1, %dl
movb %dl, -0x39(%rbp)
andb $0x1, %cl
movb %cl, -0x3a(%rbp)
andb $0x1, %al
movb %al, -0x3b(%rbp)
movsd %xmm0, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x95350
leaq -0x4d8(%rbp), %rdi
callq 0xf670
movq -0x18(%rbp), %rdi
callq 0xaf3f0
movl %eax, -0x4dc(%rbp)
movl $0x0, -0x4e0(%rbp)
movl -0x4e0(%rbp), %eax
cmpl -0x4dc(%rbp), %eax
jge 0xa4686
leaq -0x4d8(%rbp), %rdi
xorl %esi, %esi
callq 0xf700
jmp 0xa465c
jmp 0xa465e
movl -0x4e0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4e0(%rbp)
jmp 0xa463e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0xa5273
leaq -0x518(%rbp), %rdi
callq 0xf670
movq -0x30(%rbp), %rdi
callq 0xaf420
movl %eax, -0x51c(%rbp)
movl $0x0, -0x520(%rbp)
movl -0x520(%rbp), %eax
cmpl -0x51c(%rbp), %eax
jge 0xa46f3
leaq -0x518(%rbp), %rdi
xorl %esi, %esi
callq 0xf700
jmp 0xa46c9
jmp 0xa46cb
movl -0x520(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x520(%rbp)
jmp 0xa46ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0xa5267
movl $0x0, -0x524(%rbp)
movl -0x524(%rbp), %eax
cmpl -0x4dc(%rbp), %eax
jge 0xa4757
movq -0x28(%rbp), %rax
movq %rax, -0x7b0(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x524(%rbp), %rsi
callq 0xaf120
movq %rax, -0x7a8(%rbp)
jmp 0xa472f
movq -0x7a8(%rbp), %rsi
movq -0x7b0(%rbp), %rdi
callq 0xaf710
jmp 0xa4744
jmp 0xa4746
movl -0x524(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x524(%rbp)
jmp 0xa46fd
movl $0x0, -0x528(%rbp)
movb $0x1, -0x529(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x538(%rbp)
testb $0x1, -0x49(%rbp)
je 0xa478b
leaq 0x1549a0(%rip), %rdi    # 0x1f9120
xorl %eax, %eax
callq 0x5070
jmp 0xa4789
jmp 0xa478b
jmp 0xa478d
movl -0x528(%rbp), %ecx
xorl %eax, %eax
cmpl -0x4dc(%rbp), %ecx
movb %al, -0x7b1(%rbp)
jge 0xa47af
movb -0x529(%rbp), %al
movb %al, -0x7b1(%rbp)
movb -0x7b1(%rbp), %al
testb $0x1, %al
jne 0xa47be
jmp 0xa4856
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %r9
movl -0x528(%rbp), %ecx
movq %rsp, %rax
leaq -0x538(%rbp), %r8
movq %r8, 0x8(%rax)
movl %ecx, (%rax)
leaq -0x4d8(%rbp), %rcx
leaq -0x518(%rbp), %r8
callq 0x9fa00
movl %eax, -0x7b8(%rbp)
jmp 0xa47ff
movl -0x7b8(%rbp), %eax
movl %eax, -0x53c(%rbp)
testb $0x1, -0x49(%rbp)
je 0xa4829
movl -0x53c(%rbp), %esi
leaq 0x15487a(%rip), %rdi    # 0x1f9098
xorl %eax, %eax
callq 0x5070
jmp 0xa4827
jmp 0xa4829
movl -0x53c(%rbp), %eax
movl -0x528(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xa484a
movl -0x53c(%rbp), %eax
movl %eax, -0x528(%rbp)
jmp 0xa4851
movb $0x0, -0x529(%rbp)
jmp 0xa478d
cmpl $0x1, -0x528(%rbp)
jle 0xa4880
movsd -0x538(%rbp), %xmm0
movl -0x528(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movl -0x528(%rbp), %eax
cmpl -0x4dc(%rbp), %eax
je 0xa48d4
testb $0x1, -0x49(%rbp)
je 0xa48b2
movl -0x528(%rbp), %esi
movl -0x4dc(%rbp), %edx
leaq 0x15489a(%rip), %rdi    # 0x1f9141
xorl %eax, %eax
callq 0x5070
jmp 0xa48b0
jmp 0xa48b2
movq -0x790(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0xafac0
movl $0x1, -0x540(%rbp)
jmp 0xa5232
testb $0x1, -0x49(%rbp)
je 0xa48f8
movl -0x528(%rbp), %esi
movl -0x4dc(%rbp), %edx
leaq 0x1548cd(%rip), %rdi    # 0x1f91ba
xorl %eax, %eax
callq 0x5070
jmp 0xa48f6
jmp 0xa48f8
jmp 0xa48fa
leaq -0x568(%rbp), %rdi
callq 0xf670
movl $0x0, -0x56c(%rbp)
movl -0x56c(%rbp), %eax
cmpl -0x51c(%rbp), %eax
jge 0xa4958
leaq -0x568(%rbp), %rdi
xorl %esi, %esi
callq 0xf700
jmp 0xa492e
jmp 0xa4930
movl -0x56c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x56c(%rbp)
jmp 0xa4910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0xa5224
leaq -0x588(%rbp), %rdi
callq 0xd0d0
leaq -0x5a0(%rbp), %rdi
callq 0xd0d0
leaq -0x5b8(%rbp), %rdi
callq 0xd0d0
leaq -0x5d0(%rbp), %rdi
callq 0xd0d0
leaq -0x5e8(%rbp), %rdi
callq 0xada60
leaq -0x600(%rbp), %rdi
callq 0xd0d0
leaq -0x618(%rbp), %rdi
callq 0xada60
leaq -0x630(%rbp), %rdi
callq 0xd0d0
leaq -0x648(%rbp), %rdi
callq 0xd0d0
leaq -0x660(%rbp), %rdi
callq 0xd0d0
leaq -0x678(%rbp), %rdi
callq 0xada60
leaq -0x6a0(%rbp), %rdi
callq 0xf670
movq -0x20(%rbp), %rdi
addq $0x3c0, %rdi            # imm = 0x3C0
callq 0xae470
movl %eax, -0x6a4(%rbp)
movl $0x0, -0x6a8(%rbp)
movl -0x6a8(%rbp), %eax
cmpl -0x6a4(%rbp), %eax
jge 0xa4ac9
leaq -0x6a0(%rbp), %rdi
xorl %esi, %esi
callq 0xf700
jmp 0xa4a2a
movl $0x0, -0x6ac(%rbp)
leaq -0x630(%rbp), %rdi
leaq -0x6ac(%rbp), %rsi
callq 0xffc0
jmp 0xa4a49
movl $0x0, -0x6b0(%rbp)
leaq -0x648(%rbp), %rdi
leaq -0x6b0(%rbp), %rsi
callq 0xffc0
jmp 0xa4a68
movl $0x0, -0x6b4(%rbp)
leaq -0x660(%rbp), %rdi
leaq -0x6b4(%rbp), %rsi
callq 0xffc0
jmp 0xa4a87
leaq 0x1ced1a(%rip), %rsi    # 0x2737a8
leaq -0x678(%rbp), %rdi
callq 0xafc20
jmp 0xa4a9c
jmp 0xa4a9e
movl -0x6a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6a8(%rbp)
jmp 0xa4a08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0xa5194
movq 0x1cece8(%rip), %rax    # 0x2737b8
movq %rax, -0x6c0(%rbp)
movups 0x1cecca(%rip), %xmm0   # 0x2737a8
movaps %xmm0, -0x6d0(%rbp)
movq -0x30(%rbp), %r8
movq -0x28(%rbp), %r9
movl 0x10(%rbp), %ecx
movq -0x6c0(%rbp), %rdx
movq %rsp, %rax
movq %rax, -0x7c8(%rbp)
movq %rdx, 0x10(%rax)
movaps -0x6d0(%rbp), %xmm0
movups %xmm0, (%rax)
movl %ecx, 0x78(%rax)
leaq -0x618(%rbp), %rcx
movq %rcx, 0x70(%rax)
leaq -0x600(%rbp), %rcx
movq %rcx, 0x68(%rax)
leaq -0x5e8(%rbp), %rcx
movq %rcx, 0x60(%rax)
leaq -0x5d0(%rbp), %rcx
movq %rcx, 0x58(%rax)
leaq -0x5b8(%rbp), %rcx
movq %rcx, 0x50(%rax)
leaq -0x5a0(%rbp), %rcx
movq %rcx, 0x48(%rax)
leaq -0x6a0(%rbp), %rcx
movq %rcx, 0x40(%rax)
leaq -0x678(%rbp), %rcx
movq %rcx, 0x38(%rax)
leaq -0x660(%rbp), %rcx
movq %rcx, 0x30(%rax)
leaq -0x648(%rbp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x630(%rbp), %rcx
movq %rcx, 0x20(%rax)
leaq -0x568(%rbp), %rcx
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movl %ecx, %edi
movl %ecx, %esi
movl %ecx, %edx
callq 0x111fd0
movb %al, -0x7b9(%rbp)
jmp 0xa4bab
movb -0x7b9(%rbp), %al
andb $0x1, %al
movb %al, -0x6b5(%rbp)
testb $0x1, -0x49(%rbp)
je 0xa4cf0
leaq -0x5e8(%rbp), %rdi
callq 0xae590
movl %eax, -0x6d4(%rbp)
movl $0x0, -0x6d8(%rbp)
movl -0x6d8(%rbp), %eax
cmpl -0x6d4(%rbp), %eax
jge 0xa4cee
movslq -0x6d8(%rbp), %rsi
leaq -0x5e8(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x7d0(%rbp)
jmp 0xa4c0d
movq -0x7d0(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x6e0(%rbp)
movups (%rax), %xmm0
movaps %xmm0, -0x6f0(%rbp)
movslq -0x6d8(%rbp), %rsi
leaq -0x5a0(%rbp), %rdi
callq 0x101d0
movq %rax, -0x7d8(%rbp)
jmp 0xa4c45
movq -0x7d8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x7e4(%rbp)
movslq -0x6d8(%rbp), %rsi
leaq -0x5b8(%rbp), %rdi
callq 0x101d0
movq %rax, -0x7e0(%rbp)
jmp 0xa4c70
movq -0x7e0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x7f4(%rbp)
movslq -0x6d8(%rbp), %rsi
leaq -0x5d0(%rbp), %rdi
callq 0x101d0
movq %rax, -0x7f0(%rbp)
jmp 0xa4c9b
movl -0x7f4(%rbp), %edx
movl -0x7e4(%rbp), %esi
movq -0x7f0(%rbp), %rax
movl (%rax), %ecx
movsd -0x6f0(%rbp), %xmm0
movsd -0x6e8(%rbp), %xmm1
movsd -0x6e0(%rbp), %xmm2
leaq 0x15452c(%rip), %rdi    # 0x1f91fb
movb $0x3, %al
callq 0x5070
jmp 0xa4cd8
jmp 0xa4cda
movl -0x6d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6d8(%rbp)
jmp 0xa4bdf
jmp 0xa4cf0
testb $0x1, -0x6b5(%rbp)
je 0xa4d13
testb $0x1, -0x49(%rbp)
je 0xa4d11
leaq 0x154552(%rip), %rdi    # 0x1f9258
xorl %eax, %eax
callq 0x5070
jmp 0xa4d0f
jmp 0xa4d11
jmp 0xa4d2d
leaq 0x15456e(%rip), %rdi    # 0x1f9288
xorl %eax, %eax
callq 0x5070
jmp 0xa4d23
movl $0x1, %edi
callq 0x67c0
cmpl $0x2, 0x10(%rbp)
jne 0xa4ef5
testb $0x1, -0x49(%rbp)
je 0xa4d4f
leaq 0x15457b(%rip), %rdi    # 0x1f92bf
xorl %eax, %eax
callq 0x5070
jmp 0xa4d4d
jmp 0xa4d4f
movl $0x0, -0x6f4(%rbp)
testb $0x1, -0x39(%rbp)
jne 0xa4dd4
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd -0x48(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x710(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq 0xea8e0
jmp 0xa4d91
leaq -0x618(%rbp), %rdi
leaq -0x710(%rbp), %rsi
callq 0xafc20
jmp 0xa4da6
movl $0x0, -0x714(%rbp)
leaq -0x600(%rbp), %rdi
leaq -0x714(%rbp), %rsi
callq 0xffc0
jmp 0xa4dc5
movl -0x6f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6f4(%rbp)
testb $0x1, -0x3a(%rbp)
jne 0xa4e4f
movq -0x38(%rbp), %rax
movsd (%rax), %xmm1
movq -0x20(%rbp), %rax
movsd 0x10(%rax), %xmm0
mulsd %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
divsd %xmm0, %xmm1
leaq -0x730(%rbp), %rdi
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xea8e0
jmp 0xa4e0c
leaq -0x618(%rbp), %rdi
leaq -0x730(%rbp), %rsi
callq 0xafc20
jmp 0xa4e21
movl $0x1, -0x734(%rbp)
leaq -0x600(%rbp), %rdi
leaq -0x734(%rbp), %rsi
callq 0xffc0
jmp 0xa4e40
movl -0x6f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6f4(%rbp)
testb $0x1, -0x3b(%rbp)
jne 0xa4eca
movq -0x38(%rbp), %rax
movsd (%rax), %xmm2
movq -0x20(%rbp), %rax
movsd 0x18(%rax), %xmm0
mulsd %xmm0, %xmm2
movsd -0x48(%rbp), %xmm0
divsd %xmm0, %xmm2
leaq -0x750(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0xea8e0
jmp 0xa4e87
leaq -0x618(%rbp), %rdi
leaq -0x750(%rbp), %rsi
callq 0xafc20
jmp 0xa4e9c
movl $0x2, -0x754(%rbp)
leaq -0x600(%rbp), %rdi
leaq -0x754(%rbp), %rsi
callq 0xffc0
jmp 0xa4ebb
movl -0x6f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6f4(%rbp)
cmpl $0x1, -0x6f4(%rbp)
je 0xa4ef3
movl -0x6f4(%rbp), %esi
leaq 0x15444f(%rip), %rdi    # 0x1f932f
xorl %eax, %eax
callq 0x5070
jmp 0xa4ee9
movl $0x1, %edi
callq 0x67c0
jmp 0xa4ef5
leaq -0x770(%rbp), %rdi
callq 0xada60
movl $0x0, -0x774(%rbp)
cmpl $0x3, -0x774(%rbp)
jge 0xa5001
movb $0x0, -0x775(%rbp)
movl $0x0, -0x77c(%rbp)
xorl %eax, %eax
cmpl $0x3, -0x77c(%rbp)
movb %al, -0x7f5(%rbp)
jge 0xa4f48
movb -0x775(%rbp), %al
xorb $-0x1, %al
movb %al, -0x7f5(%rbp)
movb -0x7f5(%rbp), %al
testb $0x1, %al
jne 0xa4f57
jmp 0xa4feb
movslq -0x77c(%rbp), %rsi
leaq -0x600(%rbp), %rdi
callq 0x101d0
movq %rax, -0x800(%rbp)
jmp 0xa4f73
movq -0x800(%rbp), %rax
movl (%rax), %eax
cmpl -0x774(%rbp), %eax
jne 0xa4fd5
movslq -0x77c(%rbp), %rsi
leaq -0x618(%rbp), %rdi
callq 0xae5c0
movq %rax, -0x808(%rbp)
jmp 0xa4fa0
movq -0x808(%rbp), %rsi
leaq -0x770(%rbp), %rdi
callq 0xafc20
jmp 0xa4fb5
movb $0x1, -0x775(%rbp)
jmp 0xa4fd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
jmp 0xa5188
jmp 0xa4fd7
movl -0x77c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x77c(%rbp)
jmp 0xa4f29
jmp 0xa4fed
movl -0x774(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x774(%rbp)
jmp 0xa4f0b
leaq -0x770(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0xa0810
jmp 0xa5016
movq -0x28(%rbp), %rsi
leaq -0x4b0(%rbp), %rdi
callq 0xa3b40
jmp 0xa5028
movq -0x790(%rbp), %rdi
movb $0x0, -0x77d(%rbp)
callq 0x95350
jmp 0xa503d
movq -0x790(%rbp), %rsi
leaq -0x4b0(%rbp), %rdi
callq 0x96980
jmp 0xa5052
movq -0x790(%rbp), %rdi
movsd -0x4a8(%rbp), %xmm0
movsd -0x4a0(%rbp), %xmm1
movsd -0x498(%rbp), %xmm2
movsd -0x490(%rbp), %xmm3
movsd -0x488(%rbp), %xmm4
movsd -0x480(%rbp), %xmm5
callq 0x960d0
jmp 0xa5090
movb $0x1, -0x77d(%rbp)
movl $0x1, -0x540(%rbp)
testb $0x1, -0x77d(%rbp)
jne 0xa50db
jmp 0xa50cf
movq -0x790(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x4e8(%rbp)
movl %eax, -0x4ec(%rbp)
callq 0xfde0
jmp 0xa5188
movq -0x790(%rbp), %rdi
callq 0xfde0
leaq -0x770(%rbp), %rdi
callq 0x12210
leaq -0x6a0(%rbp), %rdi
callq 0xf9b0
leaq -0x678(%rbp), %rdi
callq 0x12210
leaq -0x660(%rbp), %rdi
callq 0xec80
leaq -0x648(%rbp), %rdi
callq 0xec80
leaq -0x630(%rbp), %rdi
callq 0xec80
leaq -0x618(%rbp), %rdi
callq 0x12210
leaq -0x600(%rbp), %rdi
callq 0xec80
leaq -0x5e8(%rbp), %rdi
callq 0x12210
leaq -0x5d0(%rbp), %rdi
callq 0xec80
leaq -0x5b8(%rbp), %rdi
callq 0xec80
leaq -0x5a0(%rbp), %rdi
callq 0xec80
leaq -0x588(%rbp), %rdi
callq 0xec80
leaq -0x568(%rbp), %rdi
callq 0xf9b0
jmp 0xa5232
leaq -0x770(%rbp), %rdi
callq 0x12210
leaq -0x6a0(%rbp), %rdi
callq 0xf9b0
leaq -0x678(%rbp), %rdi
callq 0x12210
leaq -0x660(%rbp), %rdi
callq 0xec80
leaq -0x648(%rbp), %rdi
callq 0xec80
leaq -0x630(%rbp), %rdi
callq 0xec80
leaq -0x618(%rbp), %rdi
callq 0x12210
leaq -0x600(%rbp), %rdi
callq 0xec80
leaq -0x5e8(%rbp), %rdi
callq 0x12210
leaq -0x5d0(%rbp), %rdi
callq 0xec80
leaq -0x5b8(%rbp), %rdi
callq 0xec80
leaq -0x5a0(%rbp), %rdi
callq 0xec80
leaq -0x588(%rbp), %rdi
callq 0xec80
leaq -0x568(%rbp), %rdi
callq 0xf9b0
jmp 0xa5267
leaq -0x518(%rbp), %rdi
callq 0xf9b0
leaq -0x4d8(%rbp), %rdi
callq 0xf9b0
leaq -0x4b0(%rbp), %rdi
callq 0xfde0
movq -0x788(%rbp), %rax
addq $0x888, %rsp            # imm = 0x888
popq %rbx
popq %rbp
retq
leaq -0x518(%rbp), %rdi
callq 0xf9b0
leaq -0x4d8(%rbp), %rdi
callq 0xf9b0
leaq -0x4b0(%rbp), %rdi
callq 0xfde0
movq -0x4e8(%rbp), %rdi
callq 0x58f0
nopw (%rax,%rax)