user: Converte this assembly snippet into its equivalent C code:

```asm
<Crossover_Kpoint>:
  endbr64
  push   %r15
  push   %r14
  mov    %r9,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rdi,0x8(%rsp)
  lea    0x54(%rsp),%rdx
  lea    0x50(%rsp),%rsi
  mov    0xc8(%rsp),%rax
  mov    %ecx,0x38(%rsp)
  lea    0x68(%rsp),%rdi
  mov    0xd0(%rsp),%rbx
  mov    %r8,0x20(%rsp)
  mov    %ecx,%r8d
  mov    %r13,%rcx
  mov    0xd8(%rsp),%rbp
  mov    %rax,0x30(%rsp)
  movsd  %xmm0,0x28(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  mov    D21(%rip),%rax
  movq   %rax,%xmm0
  call   <CO_select_forward_3@plt>
  movslq 0x50(%rsp),%rax
  lea    0x58(%rsp),%rdi
  mov    %r14,%rsi
  mov    0xc0(%rsp),%edx
  movsd  0x0(%r13,%rax,8),%xmm5
  movapd %xmm5,%xmm0
  movsd  %xmm5,0x10(%rsp)
  call   <self_adj_index_search@plt>
  movslq 0x54(%rsp),%rax
  lea    0x5c(%rsp),%rdi
  mov    %r14,%rsi
  mov    0xc0(%rsp),%edx
  movsd  0x0(%r13,%rax,8),%xmm6
  movapd %xmm6,%xmm0
  movsd  %xmm6,0x18(%rsp)
  call   <self_adj_index_search@plt>
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <integerrng@plt>
  cmp    $0x1,%eax
  je     L177
  cmp    $0x2,%eax
  je     L445
L403:
  mov    %r12d,%esi
  mov    %rbx,%rdi
  call   <cost@plt>
  mov    0xc0(%rsp),%edx
  lea    0x60(%rsp),%rdi
  mov    %r14,%rsi
  movq   %xmm0,%r15
  call   <self_adj_index_search@plt>
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <cost@plt>
  mov    0xc0(%rsp),%edx
  lea    0x64(%rsp),%rdi
  mov    %r14,%rsi
  movsd  %xmm0,(%rsp)
  call   <self_adj_index_search@plt>
  mov    0x54(%rsp),%edx
  mov    0x50(%rsp),%esi
  mov    %r13,%rcx
  mov    D21(%rip),%rax
  mov    0x38(%rsp),%r8d
  lea    0x70(%rsp),%rdi
  movq   %rax,%xmm0
  call   <CO_select_backward_3@plt>
  movsd  0x28(%rsp),%xmm2
  movq   %r15,%xmm1
  mov    0x20(%rsp),%rcx
  movslq 0x60(%rsp),%rax
  divsd  %xmm2,%xmm1
  movsd  (%rcx,%rax,8),%xmm0
  xorpd  D25(%rip),%xmm0
  movslq 0x64(%rsp),%rax
  subsd  %xmm1,%xmm0
  movsd  (%rsp),%xmm1
  subsd  (%rcx,%rax,8),%xmm0
  movslq 0x58(%rsp),%rax
  divsd  %xmm2,%xmm1
  subsd  %xmm1,%xmm0
  movsd  0x10(%rsp),%xmm1
  addsd  0x70(%rsp),%xmm0
  addsd  (%rcx,%rax,8),%xmm0
  movslq 0x5c(%rsp),%rax
  divsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x18(%rsp),%xmm1
  addsd  (%rcx,%rax,8),%xmm0
  divsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  subsd  0x68(%rsp),%xmm0
  comisd D38(%rip),%xmm0
  movsd  D7(%rip),%xmm1
  jbe    L383
L470:
  mov    0x30(%rsp),%r14
  xor    %eax,%eax
  movsd  %xmm1,(%r14)
  call   <uniformrng@plt>
  movsd  (%r14),%xmm1
  comisd %xmm0,%xmm1
  jbe    L165
  movslq 0x50(%rsp),%rax
  movslq 0x54(%rsp),%rsi
  mov    %r15,0x0(%r13,%rax,8)
  lea    0x0(%r13,%rsi,8),%r8
  test   %r12d,%r12d
  jle    L208
  mov    0x8(%rsp),%rdi
  lea    0x10(%rbx),%rcx
  mov    (%rdi,%rax,8),%rdx
  lea    -0x1(%r12),%eax
  cmp    $0x2,%eax
  lea    0x8(%rdx),%rax
  seta   %dil
  cmp    %rax,%rcx
  je     L169
  test   %dil,%dil
  je     L169
  mov    %r12d,%eax
  shr    %eax
  lea    -0x1(%rax),%ecx
  mov    $0x8,%eax
  shl    $0x4,%rcx
  add    $0x18,%rcx
  nopl   0x0(%rax)
L378:
  movupd (%rbx,%rax,1),%xmm3
  movups %xmm3,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L378
  mov    %r12d,%eax
  or     $0x1,%eax
  test   $0x1,%r12b
  je     L502
  cltq
  movsd  (%rbx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
L502:
  mov    0x8(%rsp),%rax
  movsd  (%rsp),%xmm5
  lea    0x10(%rbp),%rcx
  mov    (%rax,%rsi,8),%rdx
  movsd  %xmm5,(%r8)
  lea    0x8(%rdx),%rax
  cmp    %rax,%rcx
  je     L459
  test   %dil,%dil
  je     L459
  mov    %r12d,%eax
  shr    %eax
  lea    -0x1(%rax),%ecx
  mov    $0x8,%eax
  shl    $0x4,%rcx
  add    $0x18,%rcx
  nopl   0x0(%rax)
L346:
  movupd 0x0(%rbp,%rax,1),%xmm4
  movups %xmm4,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rcx
  jne    L346
  mov    %r12d,%eax
  or     $0x1,%eax
  and    $0x1,%r12d
  je     L165
  cltq
  movsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
L165:
  mov    0x78(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L201
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L383:
  call   <exp@plt>
  movapd %xmm0,%xmm1
  jmp    L470
  cs nopw 0x0(%rax,%rax,1)
L177:
  lea    -0x1(%r12),%esi
  mov    $0x1,%edi
  call   <integerrng@plt>
  test   %eax,%eax
  jle    L179
  mov    0x8(%rsp),%rdi
  movslq 0x50(%rsp),%rdx
  lea    0x8(%rbx),%r8
  mov    (%rdi,%rdx,8),%rcx
  movslq 0x54(%rsp),%rdx
  lea    0x10(%rcx),%rsi
  mov    (%rdi,%rdx,8),%rdx
  lea    0x8(%rbp),%rdi
  cmp    %rsi,%r8
  setne  %r9b
  cmp    %rdi,%rsi
  setne  %sil
  and    %esi,%r9d
  lea    0x10(%rbx),%rsi
  cmp    %rsi,%rdi
  setne  %sil
  and    %r9d,%esi
  lea    0x10(%rdx),%r9
  cmp    %r9,%rdi
  lea    0x18(%rbx),%r9
  setne  %dil
  and    %edi,%esi
  lea    0x8(%rdx),%rdi
  cmp    %rdi,%r9
  lea    0x18(%rdx),%r9
  setbe  %dil
  cmp    %r9,%r8
  setae  %r8b
  or     %r8d,%edi
  test   %dil,%sil
  je     L547
  lea    -0x1(%rax),%esi
  cmp    $0x1,%esi
  jbe    L547
  mov    %eax,%esi
  shr    %esi
  lea    -0x1(%rsi),%edi
  mov    $0x8,%esi
  shl    $0x4,%rdi
  add    $0x18,%rdi
  nopl   0x0(%rax)
L181:
  movupd (%rcx,%rsi,1),%xmm7
  movups %xmm7,(%rbx,%rsi,1)
  movupd (%rdx,%rsi,1),%xmm7
  movups %xmm7,0x0(%rbp,%rsi,1)
  add    $0x10,%rsi
  cmp    %rdi,%rsi
  jne    L181
  mov    %eax,%esi
  lea    0x1(%rax),%edi
  mov    %edi,0x3c(%rsp)
  or     $0x1,%esi
  test   $0x1,%al
  je     L520
  movslq %esi,%rsi
  movsd  (%rcx,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  movsd  (%rdx,%rsi,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rsi,8)
L520:
  cmp    0x3c(%rsp),%r12d
  jl     L403
  mov    0x8(%rsp),%rdi
  movslq 0x54(%rsp),%rdx
  mov    (%rdi,%rdx,8),%rsi
  movslq 0x50(%rsp),%rdx
  mov    (%rdi,%rdx,8),%rcx
  mov    %r12d,%edi
  sub    %eax,%edi
  cltq
  add    $0x1,%rax
  mov    %edi,(%rsp)
  lea    0x0(,%rax,8),%rdx
  lea    0x8(%rdx),%r10
  lea    (%rbx,%rdx,1),%r8
  lea    (%rsi,%r10,1),%r15
  lea    0x0(%rbp,%rdx,1),%rdi
  cmp    %r15,%r8
  lea    0x10(%rdx),%r11
  lea    (%rcx,%rdx,1),%r9
  mov    %r11,0x40(%rsp)
  setne  %r11b
  cmp    %rdi,%r15
  setne  %r15b
  and    %r15d,%r11d
  mov    (%rsp),%r15d
  sub    $0x1,%r15d
  cmp    $0x1,%r15d
  seta   %r15b
  and    %r15d,%r11d
  lea    (%rcx,%r10,1),%r15
  cmp    %r15,%rdi
  setne  %r15b
  add    %rbx,%r10
  and    %r11d,%r15d
  cmp    %r10,%rdi
  setne  %r10b
  test   %r10b,%r15b
  je     L267
  mov    0x40(%rsp),%r11
  lea    (%rbx,%r11,1),%r10
  cmp    %r10,%r9
  setae  %r10b
  add    %rcx,%r11
  cmp    %r11,%r8
  setae  %r11b
  or     %r10b,%r11b
  je     L267
  mov    (%rsp),%r10d
  add    %rsi,%rdx
  xor    %eax,%eax
  shr    %r10d
  shl    $0x4,%r10
  xchg   %ax,%ax
L303:
  movupd (%rdx,%rax,1),%xmm7
  movups %xmm7,(%r8,%rax,1)
  movupd (%r9,%rax,1),%xmm3
  movups %xmm3,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %r10,%rax
  jne    L303
L248:
  mov    (%rsp),%edi
  mov    0x3c(%rsp),%eax
  mov    %edi,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%edi
  je     L403
  cltq
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  jmp    L403
  nop
L267:
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%r12d
  jge    L267
  jmp    L403
  nopl   0x0(%rax,%rax,1)
L208:
  movsd  (%rsp),%xmm6
  movsd  %xmm6,(%r8)
  jmp    L165
  nopw   0x0(%rax,%rax,1)
L445:
  lea    -0x1(%r12),%esi
  mov    $0x1,%edi
  call   <integerrng@plt>
  lea    -0x2(%r12),%esi
  mov    $0x1,%edi
  mov    %eax,%r15d
  mov    %eax,(%rsp)
  call   <integerrng@plt>
  cmp    %eax,%r15d
  jg     L235
  add    $0x1,%eax
  cmp    %eax,%r15d
  jg     L235
  mov    %eax,%edx
  mov    %r15d,%eax
  mov    %edx,(%rsp)
L235:
  test   %eax,%eax
  jle    L158
  mov    0x8(%rsp),%rdi
  movslq 0x50(%rsp),%rdx
  lea    0x8(%rbx),%r8
  mov    (%rdi,%rdx,8),%rcx
  movslq 0x54(%rsp),%rdx
  lea    0x10(%rcx),%rsi
  mov    (%rdi,%rdx,8),%rdx
  lea    0x8(%rbp),%rdi
  cmp    %rsi,%r8
  setne  %r9b
  cmp    %rdi,%rsi
  setne  %sil
  and    %esi,%r9d
  lea    0x10(%rbx),%rsi
  cmp    %rsi,%rdi
  setne  %sil
  and    %r9d,%esi
  lea    0x10(%rdx),%r9
  cmp    %r9,%rdi
  lea    0x18(%rbx),%r9
  setne  %dil
  and    %edi,%esi
  lea    0x8(%rdx),%rdi
  cmp    %rdi,%r9
  lea    0x18(%rdx),%r9
  setbe  %dil
  cmp    %r9,%r8
  setae  %r8b
  or     %r8d,%edi
  test   %dil,%sil
  je     L55
  lea    -0x1(%rax),%esi
  cmp    $0x1,%esi
  jbe    L55
  mov    %eax,%esi
  shr    %esi
  lea    -0x1(%rsi),%edi
  mov    $0x8,%esi
  shl    $0x4,%rdi
  add    $0x18,%rdi
  cs nopw 0x0(%rax,%rax,1)
L345:
  movupd (%rcx,%rsi,1),%xmm4
  movups %xmm4,(%rbx,%rsi,1)
  movupd (%rdx,%rsi,1),%xmm5
  movups %xmm5,0x0(%rbp,%rsi,1)
  add    $0x10,%rsi
  cmp    %rdi,%rsi
  jne    L345
  mov    %eax,%esi
  lea    0x1(%rax),%edi
  mov    %edi,0x40(%rsp)
  or     $0x1,%esi
  test   $0x1,%al
  je     L224
  movslq %esi,%rsi
  movsd  (%rcx,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  movsd  (%rdx,%rsi,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rsi,8)
L224:
  cmp    %edi,(%rsp)
  jl     L389
  mov    0x8(%rsp),%rdi
  movslq 0x54(%rsp),%rdx
  mov    (%rdi,%rdx,8),%rsi
  movslq 0x50(%rsp),%rdx
  mov    (%rdi,%rdx,8),%rcx
  mov    (%rsp),%edi
  sub    %eax,%edi
  cltq
  add    $0x1,%rax
  mov    %edi,0x3c(%rsp)
  lea    0x0(,%rax,8),%rdx
  lea    0x8(%rdx),%r10
  lea    (%rbx,%rdx,1),%r8
  lea    (%rsi,%r10,1),%r15
  lea    0x0(%rbp,%rdx,1),%rdi
  cmp    %r15,%r8
  lea    0x10(%rdx),%r11
  lea    (%rcx,%rdx,1),%r9
  mov    %r11,0x48(%rsp)
  setne  %r11b
  cmp    %rdi,%r15
  setne  %r15b
  and    %r15d,%r11d
  mov    0x3c(%rsp),%r15d
  sub    $0x1,%r15d
  cmp    $0x1,%r15d
  seta   %r15b
  and    %r15d,%r11d
  lea    (%rcx,%r10,1),%r15
  cmp    %r15,%rdi
  setne  %r15b
  add    %rbx,%r10
  and    %r11d,%r15d
  cmp    %r10,%rdi
  setne  %r10b
  test   %r10b,%r15b
  je     L530
  mov    0x48(%rsp),%r15
  lea    (%rbx,%r15,1),%r10
  cmp    %r10,%r9
  lea    (%rcx,%r15,1),%r10
  setae  %r11b
  cmp    %r10,%r8
  setae  %r10b
  or     %r11b,%r10b
  je     L530
  mov    0x3c(%rsp),%r10d
  add    %rsi,%rdx
  xor    %eax,%eax
  shr    %r10d
  shl    $0x4,%r10
  nopl   0x0(%rax)
L64:
  movupd (%rdx,%rax,1),%xmm6
  movups %xmm6,(%r8,%rax,1)
  movupd (%r9,%rax,1),%xmm7
  movups %xmm7,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %r10,%rax
  jne    L64
  mov    0x3c(%rsp),%edi
  mov    0x40(%rsp),%eax
  mov    %edi,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%edi
  je     L389
  cltq
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
L389:
  mov    (%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x3c(%rsp)
  cmp    %eax,%r12d
  jl     L403
  mov    0x8(%rsp),%rdx
  movslq 0x50(%rsp),%rax
  mov    (%rdx,%rax,8),%rsi
  movslq 0x54(%rsp),%rax
  mov    (%rdx,%rax,8),%rcx
  mov    (%rsp),%edx
  mov    %r12d,%eax
  sub    %edx,%eax
  mov    %eax,(%rsp)
  movslq %edx,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  lea    0x8(%rdx),%r10
  lea    (%rbx,%rdx,1),%r8
  lea    (%rsi,%r10,1),%r15
  lea    0x0(%rbp,%rdx,1),%rdi
  cmp    %r15,%r8
  lea    0x10(%rdx),%r11
  lea    (%rcx,%rdx,1),%r9
  mov    %r11,0x40(%rsp)
  setne  %r11b
  cmp    %rdi,%r15
  setne  %r15b
  and    %r15d,%r11d
  mov    (%rsp),%r15d
  sub    $0x1,%r15d
  cmp    $0x1,%r15d
  seta   %r15b
  and    %r15d,%r11d
  lea    (%rcx,%r10,1),%r15
  cmp    %r15,%rdi
  setne  %r15b
  add    %rbx,%r10
  and    %r11d,%r15d
  cmp    %r10,%rdi
  setne  %r10b
  test   %r10b,%r15b
  je     L217
  mov    0x40(%rsp),%r15
  lea    (%rbx,%r15,1),%r10
  cmp    %r10,%r9
  lea    (%rcx,%r15,1),%r10
  setae  %r11b
  cmp    %r10,%r8
  setae  %r10b
  or     %r11b,%r10b
  je     L217
  mov    (%rsp),%r10d
  add    %rsi,%rdx
  xor    %eax,%eax
  shr    %r10d
  shl    $0x4,%r10
  nopw   0x0(%rax,%rax,1)
L216:
  movupd (%rdx,%rax,1),%xmm4
  movups %xmm4,(%r8,%rax,1)
  movupd (%r9,%rax,1),%xmm3
  movups %xmm3,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %r10,%rax
  jne    L216
  jmp    L248
  nopw   0x0(%rax,%rax,1)
L217:
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%r12d
  jge    L217
  jmp    L403
  nopl   0x0(%rax,%rax,1)
L459:
  lea    0x1(%r12),%ecx
  mov    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L255:
  movsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L255
  jmp    L165
  nopl   0x0(%rax)
L169:
  lea    0x1(%r12),%ecx
  mov    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L116:
  movsd  (%rbx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L116
  jmp    L502
L179:
  lea    0x1(%rax),%edx
  mov    %edx,0x3c(%rsp)
  jmp    L520
L547:
  lea    0x1(%rax),%edi
  mov    $0x1,%esi
  mov    %edi,0x3c(%rsp)
  nopl   0x0(%rax,%rax,1)
L326:
  movsd  (%rcx,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  movsd  (%rdx,%rsi,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rsi,8)
  add    $0x1,%rsi
  cmp    %rdi,%rsi
  jne    L326
  jmp    L520
L530:
  mov    (%rsp),%edx
  cs nopw 0x0(%rax,%rax,1)
L56:
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%edx
  jge    L56
  jmp    L389
L55:
  lea    0x1(%rax),%edi
  mov    $0x1,%esi
  mov    %edi,0x40(%rsp)
  xchg   %ax,%ax
L538:
  movsd  (%rcx,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  movsd  (%rdx,%rsi,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rsi,8)
  add    $0x1,%rsi
  cmp    %rdi,%rsi
  jne    L538
  mov    0x40(%rsp),%edi
  jmp    L224
L158:
  lea    0x1(%rax),%edx
  mov    %edx,0x40(%rsp)
  mov    %edx,%edi
  jmp    L224
L201:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D21
datatype: f64
name: read_data
arguments: tag: D25
datatype: f32[4]
name: read_data
arguments: tag: D38
datatype: f32
name: read_data
arguments: tag: D7
datatype: f64

tool: D21: 10.1

tool: {"D25": [0.0,-0.0,0.0,0.0]}

tool: D38: 0

tool: D7: 1

assistant: ```c
void Crossover_Kpoint(double **x, double *fx, int N_dimension, int N_population, double *theta, double *grid_points, int grid_size, double temp, double *accpr_pop, double *z_new_1, double *z_new_2) {
  double temp_co;
  int n1;
  int n2;
  int i;
  int K_CO;
  int lab_1;
  int lab_2;
  int k_old_1;
  int k_old_2;
  int k_new_1;
  int k_new_2;
  double pr_fw;
  double pr_bw;
  double fz_old_1;
  double fz_old_2;
  double fz_new_1;
  double fz_new_2;
  double sumv;
  double un;
  double rat;
  temp_co = 10.1;
  CO_select_forward_3(&pr_fw, &n1, &n2, fx, N_population, temp_co);
  fz_old_1 = fx[n1];
  self_adj_index_search(&k_old_1, fz_old_1, grid_points, grid_size);
  fz_old_2 = fx[n2];
  self_adj_index_search(&k_old_2, fz_old_2, grid_points, grid_size);
  K_CO = integerrng(1, 2);
  if (K_CO == 1) {
    lab_1 = integerrng(1, N_dimension - 1);
    for (i = 1; i <= lab_1; i++) {
      z_new_1[i] = x[n1][i];
      z_new_2[i] = x[n2][i];
    }
    for (i = lab_1 + 1; i <= N_dimension; i++) {
      z_new_1[i] = x[n2][i];
      z_new_2[i] = x[n1][i];
    }
  } else if (K_CO == 2) {
    lab_1 = integerrng(1, N_dimension - 1);
    lab_2 = integerrng(1, N_dimension - 2);
    if (lab_2 >= lab_1)
      lab_2++;
    if (lab_1 > lab_2) {
      i = lab_1;
      lab_1 = lab_2;
      lab_2 = i;
    }
    for (i = 1; i <= lab_1; i++) {
      z_new_1[i] = x[n1][i];
      z_new_2[i] = x[n2][i];
    }
    for (i = lab_1 + 1; i <= lab_2; i++) {
      z_new_1[i] = x[n2][i];
      z_new_2[i] = x[n1][i];
    }
    for (i = lab_2 + 1; i <= N_dimension; i++) {
      z_new_1[i] = x[n1][i];
      z_new_2[i] = x[n2][i];
    }
  }
  fz_new_1 = cost(z_new_1, N_dimension);
  self_adj_index_search(&k_new_1, fz_new_1, grid_points, grid_size);
  fz_new_2 = cost(z_new_2, N_dimension);
  self_adj_index_search(&k_new_2, fz_new_2, grid_points, grid_size);
  CO_select_backward_3(&pr_bw, n1, n2, fx, N_population, temp_co);
  rat = -theta[k_new_1] - fz_new_1 / temp - theta[k_new_2] - fz_new_2 / temp + pr_bw + theta[k_old_1] + fz_old_1 / temp + theta[k_old_2] + fz_old_2 / temp - pr_fw;
  *accpr_pop = ((rat > 0.0) ? 1.0 : exp(rat));
  un = uniformrng();
  if (*accpr_pop > un) {
    fx[n1] = fz_new_1;
    for (i = 1; i <= N_dimension; i++)
      x[n1][i] = z_new_1[i];
    fx[n2] = fz_new_2;
    for (i = 1; i <= N_dimension; i++)
      x[n2][i] = z_new_2[i];
  }
}
```