// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/allostery.c
// Function: Random_sites
void Random_sites(int *site_ran, int nres, int *site_res,
		  int *ichain, int *min_chain, int *max_chain,
		  int *all_chain, int nchain,
		  int *ini_chain, int *end_chain)
{
  int THR=6, RMAX=40, i, ic;
  //float RANFACTOR=pow(12.0,1/3.0);
  unsigned long iran=randomgenerator();
  if(ini_ran==0){
    InitRandom((RANDOMTYPE)iran); ini_ran=1;
  }
  for(i=0; i<nres; i++)site_ran[i]=-1;
  for(ic=0; ic<nchain; ic++){
    // Shift all chains independently
    int c=all_chain[ic];
    int shiftmin=ini_chain[c]-min_chain[ic];
    int shiftmax=end_chain[c]-max_chain[ic];
    int shift; i=0;
    while(i<RMAX){
      shift=RandomFloating()*(shiftmax-shiftmin)+shiftmin;
      if((shift>THR)||(shift<-THR))break;
      i++;
    }
    if(i==RMAX){
      printf("WARNING, no allowed random site found in %d attempts\n",
	     RMAX); shift=0;
    }
    for(i=0; i<nres; i++){
      if(ichain[i]==ic){
	site_ran[i]=site_res[i]+shift;
	// Check
	if((site_ran[i]<ini_chain[c])||(site_ran[i]>end_chain[c])){
	    printf("ERROR, incorrect random site %d = %d\n", i,site_ran[i]);
	    printf("Chain %d in site, %d in prot\n", ic, c);
	    printf("Site: ini %d end %d Protein: ini %d end %d\n",
		   min_chain[ic], max_chain[ic], ini_chain[c], end_chain[c]);
	    exit(8);
	}
      }
    }
  }
  for(i=0; i<nres; i++){
    if(site_ran[i]<0){
      printf("ERROR, residue %d not set\n", i); exit(8);
    }
  }
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x6, -0x34(%rbp)
movl $0x28, -0x38(%rbp)
callq 0x49ce0
movq %rax, -0x48(%rbp)
cmpl $0x0, 0x36c68(%rip)     # 0x9da54
jne 0x66e01
movq -0x48(%rbp), %rdi
callq 0x756e0
movl $0x1, 0x36c53(%rip)     # 0x9da54
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x66e2a
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x66e08
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl 0x18(%rbp), %eax
jge 0x66ff9
movq 0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq 0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x50(%rbp)
movq 0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movslq -0x40(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x66ed2
movb $0x0, %al
callq 0x75930
movl -0x54(%rbp), %eax
subl -0x50(%rbp), %eax
cvtsi2sd %eax, %xmm2
cvtsi2sdl -0x50(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x66ec5
movl -0x58(%rbp), %eax
xorl %ecx, %ecx
subl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66ec7
jmp 0x66ed2
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x66e84
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x66ef2
movl -0x38(%rbp), %esi
leaq 0x1b969(%rip), %rdi     # 0x8284d
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x58(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x66fe9
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x40(%rbp), %eax
jne 0x66fd9
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl -0x58(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x20(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jl 0x66f62
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x28(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x66fd7
movl -0x3c(%rbp), %esi
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x1b90c(%rip), %rdi     # 0x82883
movb $0x0, %al
callq 0x10d0
movl -0x40(%rbp), %esi
movl -0x4c(%rbp), %edx
leaq 0x1b91e(%rip), %rdi     # 0x828a9
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %esi
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x28(%rbp), %rax
movslq -0x4c(%rbp), %rdi
movl (%rax,%rdi,4), %r8d
leaq 0x1b901(%rip), %rdi     # 0x828c7
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
jmp 0x66fd9
jmp 0x66fdb
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x66ef9
jmp 0x66feb
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x66e31
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x6703e
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x67031
movl -0x3c(%rbp), %esi
leaq 0x1b8d3(%rip), %rdi     # 0x828f3
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
jmp 0x67033
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x67000
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)