// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/simulation.c
// Function: Change_kin
void Change_kin(int *first_kin, int *last_kin, struct axe *axes,
		int naxes, int natoms1, struct Reference Ref1)
{
  int refatom[natoms1], i; for(i=0; i<natoms1; i++)refatom[i]=-1;
  for(i=0; i<Ref1.N_ref; i++)refatom[Ref1.atom_num[i]]=i;
  int *first=first_kin, *last=last_kin;
  struct axe *axe=axes;
  //printf("#first_atom first_kin last_atom last_kin\n");
  printf("Changing reference atoms of axes\n");
  for(int a=0; a<naxes; a++){
    *first=axe->first_kin; axe->first_kin=-1;
    for(i=axe->first_atom; i<=axe->last_atom; i++){
      if((axe->first_kin<0)&&(refatom[i]>=0)){
	axe->first_kin=refatom[i]; break;
      }
    }
    *last=axe->last_kin; axe->last_kin=-1;
    for(i=axe->last_atom; i>=axe->first_atom; i--){
      if((axe->last_kin<0)&&(refatom[i]>=0)){
	axe->last_kin=refatom[i]; break;
      }
    }
    if((axe->first_kin<0)||(axe->last_kin<0)||(axe->first_kin>axe->last_kin)){
      printf("ERROR, axe %d out of %d\n", a+1, naxes);
      printf("first_kin= %d last_kin= %d first_atom= %d last_atom= %d\n",
	     axe->first_kin, axe->last_kin, axe->first_atom, axe->last_atom);
      printf("Last atom of axe: %s %d %c\n",
	     axe->bond->atom->name, axe->bond->atom->res, axe->bond->atom->aa);
      exit(8);
    }
    axe++; first++; last++;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x50703
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x506e1
movl $0x0, -0x34(%rbp)
movq -0x68(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl (%rcx), %eax
jge 0x5073a
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movl -0x34(%rbp), %edx
movq 0x28(%rcx), %rcx
movslq -0x34(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5070a
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x3033b(%rip), %rdi     # 0x80a94
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x50923
movq -0x50(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jg 0x507da
movq -0x50(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jge 0x507cd
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x507cd
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x507da
jmp 0x507cf
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x50795
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x48(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl $0xffffffff, 0x1c(%rax) # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x50841
movq -0x50(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jge 0x50834
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x50834
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x50841
jmp 0x50836
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x507fc
movq -0x50(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jl 0x50869
movq -0x50(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jl 0x50869
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x508ef
movl -0x54(%rbp), %esi
addl $0x1, %esi
movl -0x1c(%rbp), %edx
leaq 0x3023d(%rip), %rdi     # 0x80ab6
movb $0x0, %al
callq 0x10d0
movq -0x50(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %edx
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x50(%rbp), %rax
movl 0x14(%rax), %r8d
leaq 0x3022b(%rip), %rdi     # 0x80acf
movb $0x0, %al
callq 0x10d0
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rsi
addq $0x18, %rsi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movl 0x64(%rax), %edx
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movsbl 0x68(%rax), %ecx
leaq 0x3022a(%rip), %rdi     # 0x80b08
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movq -0x50(%rbp), %rax
addq $0x158, %rax            # imm = 0x158
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x50767
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop