#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ check_pairs(long, long, char *, long **, double **,
                               double **, double **, double **, char **,
                               double *, double *, long *, int /*<<< orphan*/);
long get_round(double);
void best_pair(long i, long num_residue, long *RY, long **seidx, double **xyz,
               double **Nxyz, long *matched_idx, double **orien, double **org,
               char **AtomName, char *bseq, double *BPRS, long *pair_stat) {
  double ddmin = 1.0e+18, rtn_val[21];
  long bpid, j, k, nout = 16;
  for (j = 1; j <= nout; j++)
    pair_stat[j] = 0;
  for (j = 1; j <= num_residue; j++) {
    if (j == i || RY[j] < 0 || matched_idx[j])
      continue;
    check_pairs(i, j, bseq, seidx, xyz, Nxyz, orien, org, AtomName, BPRS,
                rtn_val, &bpid, 0);
    if (bpid && rtn_val[5] < ddmin) {
      ddmin = rtn_val[5];
      pair_stat[1] = j;
      pair_stat[2] = bpid;
      for (k = 1; k <= 14; k++)
        pair_stat[2 + k] = get_round(10000.0 * rtn_val[k]);
    }
  }
}


x86 assembly (clang, -O0):
<best_pair>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %r8,-0x48(%rbp)
mov    %r9,-0x50(%rbp)
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   $0x10,-0x120(%rbp)
movq   $0x1,-0x110(%rbp)
mov    -0x110(%rbp),%rax
cmp    -0x120(%rbp),%rax
jg     11c7 <best_pair+0xa7>
mov    0x40(%rbp),%rax
mov    -0x110(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x110(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x110(%rbp)
jmp    1189 <best_pair+0x69>
movq   $0x1,-0x110(%rbp)
mov    -0x110(%rbp),%rax
cmp    -0x30(%rbp),%rax
jg     135f <best_pair+0x23f>
mov    -0x110(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1220 <best_pair+0x100>
mov    -0x38(%rbp),%rax
mov    -0x110(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jl     1220 <best_pair+0x100>
mov    0x10(%rbp),%rax
mov    -0x110(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1225 <best_pair+0x105>
jmp    1348 <best_pair+0x228>
mov    -0x28(%rbp),%rdi
mov    -0x110(%rbp),%rsi
mov    0x30(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    0x18(%rbp),%r15
mov    0x20(%rbp),%r14
mov    0x28(%rbp),%rbx
mov    0x38(%rbp),%r11
lea    -0x100(%rbp),%r10
lea    -0x108(%rbp),%rax
xor    %r12d,%r12d
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
movl   $0x0,0x30(%rsp)
call   1030 <check_pairs@plt>
cmpq   $0x0,-0x108(%rbp)
je     1343 <best_pair+0x223>
movsd  -0xd8(%rbp),%xmm1
ff
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1343 <best_pair+0x223>
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x58(%rbp)
mov    -0x110(%rbp),%rcx
mov    0x40(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x108(%rbp),%rcx
mov    0x40(%rbp),%rax
mov    %rcx,0x10(%rax)
movq   $0x1,-0x118(%rbp)
cmpq   $0xe,-0x118(%rbp)
0e
jg     133e <best_pair+0x21e>
mov    -0x118(%rbp),%rax
movsd  0xd05(%rip),%xmm0
mulsd  -0x100(%rbp,%rax,8),%xmm0
ff ff
call   1040 <get_round@plt>
mov    %rax,%rdx
mov    0x40(%rbp),%rax
mov    -0x118(%rbp),%rcx
add    $0x2,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    12e6 <best_pair+0x1c6>
jmp    1343 <best_pair+0x223>
jmp    1348 <best_pair+0x228>
mov    -0x110(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x110(%rbp)
jmp    11d2 <best_pair+0xb2>
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<best_pair>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,0x10(%rsp)
mov    0x140(%rsp),%r15
xorpd  %xmm0,%xmm0
movupd %xmm0,0x78(%r15)
movupd %xmm0,0x68(%r15)
movupd %xmm0,0x58(%r15)
movupd %xmm0,0x48(%r15)
movupd %xmm0,0x38(%r15)
movupd %xmm0,0x28(%r15)
movupd %xmm0,0x18(%r15)
movupd %xmm0,0x8(%r15)
test   %rsi,%rsi
jle    13bd <best_pair+0x29d>
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x110(%rsp),%r12
neg    %rbx
mov    $0x1,%r14d
movsd  0xe59(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    11c6 <best_pair+0xa6>
nop
lea    (%rbx,%r14,1),%rax
add    $0x1,%rax
add    $0x1,%r14
cmp    $0x1,%rax
je     13bd <best_pair+0x29d>
cmp    %r14,%rbp
je     11b0 <best_pair+0x90>
cmpq   $0x0,0x0(%r13,%r14,8)
js     11b0 <best_pair+0x90>
cmpq   $0x0,(%r12,%r14,8)
jne    11b0 <best_pair+0x90>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    0x138(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    0x28(%rsp),%r9
push   $0x0
lea    0x38(%rsp),%rax
push   %rax
lea    0x48(%rsp),%rax
push   %rax
push   0x158(%rsp)
push   0x150(%rsp)
push   0x150(%rsp)
push   0x150(%rsp)
call   1030 <check_pairs@plt>
add    $0x40,%rsp
mov    0x28(%rsp),%rax
test   %rax,%rax
je     11b0 <best_pair+0x90>
movsd  0x58(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11b0 <best_pair+0x90>
mov    %r14,0x8(%r15)
mov    %rax,0x10(%r15)
movsd  %xmm0,0x8(%rsp)
movsd  0x38(%rsp),%xmm0
movsd  0xd9a(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <get_round@plt>
mov    %rax,0x18(%r15)
movsd  0x40(%rsp),%xmm0
mulsd  0xd7f(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x20(%r15)
movsd  0x48(%rsp),%xmm0
mulsd  0xd68(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x28(%r15)
movsd  0x50(%rsp),%xmm0
mulsd  0xd51(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x30(%r15)
movsd  0x58(%rsp),%xmm0
mulsd  0xd3a(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x38(%r15)
movsd  0x60(%rsp),%xmm0
mulsd  0xd23(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x40(%r15)
movsd  0x68(%rsp),%xmm0
mulsd  0xd0c(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x48(%r15)
movsd  0x70(%rsp),%xmm0
mulsd  0xcf5(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x50(%r15)
movsd  0x78(%rsp),%xmm0
mulsd  0xcde(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x58(%r15)
movsd  0x80(%rsp),%xmm0
mulsd  0xcc4(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x60(%r15)
movsd  0x88(%rsp),%xmm0
mulsd  0xcaa(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x68(%r15)
movsd  0x90(%rsp),%xmm0
mulsd  0xc90(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x70(%r15)
movsd  0x98(%rsp),%xmm0
mulsd  0xc76(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x78(%r15)
movsd  0xa0(%rsp),%xmm0
mulsd  0xc5c(%rip),%xmm0
call   1040 <get_round@plt>
mov    %rax,0x80(%r15)
jmp    11b0 <best_pair+0x90>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @best_pair(i64 %0, i64 %1, i64* %2, i64** %3, double** %4, double** %5, i64* %6, double** %7, double** %8, i8** %9, i8* %10, double* %11, i64* %12) {
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64*
%17 = alloca i64**
%18 = alloca double**
%19 = alloca double**
%20 = alloca i64*
%21 = alloca double**
%22 = alloca double**
%23 = alloca i8**
%24 = alloca i8*
%25 = alloca double*
%26 = alloca i64*
%27 = alloca double
%28 = alloca [21 x double]
%29 = alloca i64
%30 = alloca i64
%31 = alloca i64
%32 = alloca i64
store i64 %0, i64* %14
store i64 %1, i64* %15
store i64* %2, i64** %16
store i64** %3, i64*** %17
store double** %4, double*** %18
store double** %5, double*** %19
store i64* %6, i64** %20
store double** %7, double*** %21
store double** %8, double*** %22
store i8** %9, i8*** %23
store i8* %10, i8** %24
store double* %11, double** %25
store i64* %12, i64** %26
store double 1.000000e+18, double* %27
store i64 16, i64* %32
store i64 1, i64* %30
br label %33
33: ; preds = %41, %13
%34 = load i64, i64* %30
%35 = load i64, i64* %32
%36 = icmp sle i64 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i64*, i64** %26
%39 = load i64, i64* %30
%40 = getelementptr inbounds i64, i64* %38, i64 %39
store i64 0, i64* %40
br label %41
41: ; preds = %37
%42 = load i64, i64* %30
%43 = add nsw i64 %42, 1
store i64 %43, i64* %30
br label %33
44: ; preds = %33
store i64 1, i64* %30
br label %45
45: ; preds = %113, %44
%46 = load i64, i64* %30
%47 = load i64, i64* %15
%48 = icmp sle i64 %46, %47
br i1 %48, label %49, label %116
49: ; preds = %45
%50 = load i64, i64* %30
%51 = load i64, i64* %14
%52 = icmp eq i64 %50, %51
br i1 %52, label %65, label %53
53: ; preds = %49
%54 = load i64*, i64** %16
%55 = load i64, i64* %30
%56 = getelementptr inbounds i64, i64* %54, i64 %55
%57 = load i64, i64* %56
%58 = icmp slt i64 %57, 0
br i1 %58, label %65, label %59
59: ; preds = %53
%60 = load i64*, i64** %20
%61 = load i64, i64* %30
%62 = getelementptr inbounds i64, i64* %60, i64 %61
%63 = load i64, i64* %62
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %59, %53, %49
br label %113
66: ; preds = %59
%67 = load i64, i64* %14
%68 = load i64, i64* %30
%69 = load i8*, i8** %24
%70 = load i64**, i64*** %17
%71 = load double**, double*** %18
%72 = load double**, double*** %19
%73 = load double**, double*** %21
%74 = load double**, double*** %22
%75 = load i8**, i8*** %23
%76 = load double*, double** %25
%77 = getelementptr inbounds [21 x double], [21 x double]* %28, i64 0, i64 0
%78 = call i32 @check_pairs(i64 %67, i64 %68, i8* %69, i64** %70, double** %71, double** %72, double** %73, double** %74, i8** %75, double* %76, double* %77, i64* %29, i32 0)
%79 = load i64, i64* %29
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %112
81: ; preds = %66
%82 = getelementptr inbounds [21 x double], [21 x double]* %28, i64 0, i64 5
%83 = load double, double* %82
%84 = load double, double* %27
%85 = fcmp olt double %83, %84
br i1 %85, label %86, label %112
86: ; preds = %81
%87 = getelementptr inbounds [21 x double], [21 x double]* %28, i64 0, i64 5
%88 = load double, double* %87
store double %88, double* %27
%89 = load i64, i64* %30
%90 = load i64*, i64** %26
%91 = getelementptr inbounds i64, i64* %90, i64 1
store i64 %89, i64* %91
%92 = load i64, i64* %29
%93 = load i64*, i64** %26
%94 = getelementptr inbounds i64, i64* %93, i64 2
store i64 %92, i64* %94
store i64 1, i64* %31
br label %95
95: ; preds = %108, %86
%96 = load i64, i64* %31
%97 = icmp sle i64 %96, 14
br i1 %97, label %98, label %111
98: ; preds = %95
%99 = load i64, i64* %31
%100 = getelementptr inbounds [21 x double], [21 x double]* %28, i64 0, i64 %99
%101 = load double, double* %100
%102 = fmul double 1.000000e+04, %101
%103 = call i64 @get_round(double %102)
%104 = load i64*, i64** %26
%105 = load i64, i64* %31
%106 = add nsw i64 2, %105
%107 = getelementptr inbounds i64, i64* %104, i64 %106
store i64 %103, i64* %107
br label %108
108: ; preds = %98
%109 = load i64, i64* %31
%110 = add nsw i64 %109, 1
store i64 %110, i64* %31
br label %95
111: ; preds = %95
br label %112
112: ; preds = %111, %81, %66
br label %113
113: ; preds = %112, %65
%114 = load i64, i64* %30
%115 = add nsw i64 %114, 1
store i64 %115, i64* %30
br label %45
116: ; preds = %45
ret void
}

LLVM IR (-O2):
define void @best_pair(i64 %0, i64 %1, i64* nocapture %2, i64** %3, double** %4, double** %5, i64* nocapture %6, double** %7, double** %8, i8** %9, i8* %10, double* %11, i64* nocapture writeonly %12) {
%14 = alloca [21 x double]
%15 = alloca i64
%16 = bitcast [21 x double]* %14 to i8*
%17 = bitcast i64* %15 to i8*
%18 = getelementptr i64, i64* %12, i64 1
%19 = bitcast i64* %18 to i8*
%20 = icmp slt i64 %1, 1
br i1 %20, label %118, label %21
21: ; preds = %13
%22 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 0
%23 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 5
%24 = getelementptr inbounds i64, i64* %12, i64 2
%25 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 1
%26 = getelementptr inbounds i64, i64* %12, i64 3
%27 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 2
%28 = getelementptr inbounds i64, i64* %12, i64 4
%29 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 3
%30 = getelementptr inbounds i64, i64* %12, i64 5
%31 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 4
%32 = getelementptr inbounds i64, i64* %12, i64 6
%33 = getelementptr inbounds i64, i64* %12, i64 7
%34 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 6
%35 = getelementptr inbounds i64, i64* %12, i64 8
%36 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 7
%37 = getelementptr inbounds i64, i64* %12, i64 9
%38 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 8
%39 = getelementptr inbounds i64, i64* %12, i64 10
%40 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 9
%41 = getelementptr inbounds i64, i64* %12, i64 11
%42 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 10
%43 = getelementptr inbounds i64, i64* %12, i64 12
%44 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 11
%45 = getelementptr inbounds i64, i64* %12, i64 13
%46 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 12
%47 = getelementptr inbounds i64, i64* %12, i64 14
%48 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 13
%49 = getelementptr inbounds i64, i64* %12, i64 15
%50 = getelementptr inbounds [21 x double], [21 x double]* %14, i64 0, i64 14
%51 = getelementptr inbounds i64, i64* %12, i64 16
br label %52
52: ; preds = %21, %114
%53 = phi double [ 1.000000e+18, %21 ], [ %115, %114 ]
%54 = phi i64 [ 1, %21 ], [ %116, %114 ]
%55 = icmp eq i64 %54, %0
br i1 %55, label %114, label %56
56: ; preds = %52
%57 = getelementptr inbounds i64, i64* %2, i64 %54
%58 = load i64, i64* %57
%59 = icmp slt i64 %58, 0
br i1 %59, label %114, label %60
60: ; preds = %56
%61 = getelementptr inbounds i64, i64* %6, i64 %54
%62 = load i64, i64* %61
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %114
64: ; preds = %60
%65 = call i32 @check_pairs(i64 %0, i64 %54, i8* %10, i64** %3, double** %4, double** %5, double** %7, double** %8, i8** %9, double* %11, double* %22, i64* %15, i32 0)
%66 = load i64, i64* %15
%67 = icmp eq i64 %66, 0
br i1 %67, label %114, label %68
68: ; preds = %64
%69 = load double, double* %23
%70 = fcmp olt double %69, %53
br i1 %70, label %71, label %114
71: ; preds = %68
store i64 %54, i64* %18
store i64 %66, i64* %24
%72 = load double, double* %25
%73 = fmul double %72, 1.000000e+04
%74 = call i64 @get_round(double %73)
store i64 %74, i64* %26
%75 = load double, double* %27
%76 = fmul double %75, 1.000000e+04
%77 = call i64 @get_round(double %76)
store i64 %77, i64* %28
%78 = load double, double* %29
%79 = fmul double %78, 1.000000e+04
%80 = call i64 @get_round(double %79)
store i64 %80, i64* %30
%81 = load double, double* %31
%82 = fmul double %81, 1.000000e+04
%83 = call i64 @get_round(double %82)
store i64 %83, i64* %32
%84 = load double, double* %23
%85 = fmul double %84, 1.000000e+04
%86 = call i64 @get_round(double %85)
store i64 %86, i64* %33
%87 = load double, double* %34
%88 = fmul double %87, 1.000000e+04
%89 = call i64 @get_round(double %88)
store i64 %89, i64* %35
%90 = load double, double* %36
%91 = fmul double %90, 1.000000e+04
%92 = call i64 @get_round(double %91)
store i64 %92, i64* %37
%93 = load double, double* %38
%94 = fmul double %93, 1.000000e+04
%95 = call i64 @get_round(double %94)
store i64 %95, i64* %39
%96 = load double, double* %40
%97 = fmul double %96, 1.000000e+04
%98 = call i64 @get_round(double %97)
store i64 %98, i64* %41
%99 = load double, double* %42
%100 = fmul double %99, 1.000000e+04
%101 = call i64 @get_round(double %100)
store i64 %101, i64* %43
%102 = load double, double* %44
%103 = fmul double %102, 1.000000e+04
%104 = call i64 @get_round(double %103)
store i64 %104, i64* %45
%105 = load double, double* %46
%106 = fmul double %105, 1.000000e+04
%107 = call i64 @get_round(double %106)
store i64 %107, i64* %47
%108 = load double, double* %48
%109 = fmul double %108, 1.000000e+04
%110 = call i64 @get_round(double %109)
store i64 %110, i64* %49
%111 = load double, double* %50
%112 = fmul double %111, 1.000000e+04
%113 = call i64 @get_round(double %112)
store i64 %113, i64* %51
br label %114
114: ; preds = %71, %64, %68, %52, %56, %60
%115 = phi double [ %53, %52 ], [ %53, %56 ], [ %53, %60 ], [ %53, %68 ], [ %53, %64 ], [ %69, %71 ]
%116 = add nuw i64 %54, 1
%117 = icmp eq i64 %54, %1
br i1 %117, label %118, label %52
118: ; preds = %114, %13
ret void
}