#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 *permutation(int);
double sqrt(double);
extern void force(double **dist, double **Y, int instances, int max_iter,
                  double eps, double delta_frac) {
  int i;
  int j;
  int k;
  int instance1, instance2;
  double dr2 = 0.0, drn = 0.0, delta = 0.0;
  double x1x2 = 0.0, y1y2 = 0.0;
  int *index;
  index = permutation(instances);
  for (i = 0; i < max_iter; i++) {
    for (j = 0; j < instances; j++) {
      instance1 = index[j];
      for (k = 0; k < instances; k++) {
        instance2 = index[k];
        if (instance1 == instance2) {
          continue;
        } else {
          x1x2 = Y[instance2][0] - Y[instance1][0];
          y1y2 = Y[instance2][1] - Y[instance1][1];
          dr2 = sqrt((x1x2 * x1x2) + (y1y2 * y1y2));
        }
        if (dr2 < eps) {
          dr2 = eps;
        }
        drn = dist[instance1][instance2] - dr2;
        delta = drn - dr2;
        delta /= delta_frac;
        Y[instance2][0] += delta * (x1x2 / dr2);
        Y[instance2][1] += delta * (y1y2 / dr2);
      }
    }
  }
}


x86 assembly (clang, -O0):
<force>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <permutation@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1337 <force+0x217>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1324 <force+0x204>
mov    -0x70(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1311 <force+0x1f1>
mov    -0x70(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    11da <force+0xba>
jmp    1303 <force+0x1e3>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    126a <force+0x14a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
divsd  -0x48(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
divsd  -0x48(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11af <force+0x8f>
jmp    1316 <force+0x1f6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    118e <force+0x6e>
jmp    1329 <force+0x209>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117b <force+0x5b>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<force>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %rdi,0x18(%rsp)
mov    %edx,(%rsp)
mov    %edx,%edi
call   1040 <permutation@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
jle    1272 <force+0x152>
mov    %rax,%r13
mov    (%rsp),%ebp
xor    %eax,%eax
xorpd  %xmm2,%xmm2
jmp    1182 <force+0x62>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
add    $0x1,%eax
cmp    0x4(%rsp),%eax
je     1272 <force+0x152>
mov    %rax,0x8(%rsp)
cmpl   $0x0,(%rsp)
jle    1170 <force+0x50>
xor    %eax,%eax
jmp    11ae <force+0x8e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rax
add    $0x1,%rax
cmp    %rbp,%rax
je     1170 <force+0x50>
mov    %rax,0x10(%rsp)
movslq 0x0(%r13,%rax,4),%r14
xor    %r15d,%r15d
jmp    1229 <force+0x109>
nopl   (%rax)
movapd %xmm3,0x30(%rsp)
call   1030 <sqrt@plt>
movapd 0x30(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x20(%rsp),%xmm1
maxsd  %xmm0,%xmm1
mov    0x18(%rsp),%rax
mov    (%rax,%r14,8),%rax
movsd  (%rax,%r12,8),%xmm0
subsd  %xmm1,%xmm0
subsd  %xmm1,%xmm0
divsd  0x28(%rsp),%xmm0
mov    (%rbx,%r12,8),%rax
unpcklpd %xmm1,%xmm1
divpd  %xmm1,%xmm3
movupd (%rax),%xmm1
unpcklpd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm1,%xmm0
movupd %xmm0,(%rax)
add    $0x1,%r15
cmp    %r15,%rbp
je     11a0 <force+0x80>
movslq 0x0(%r13,%r15,4),%r12
cmp    %r12d,%r14d
je     121c <force+0xfc>
mov    (%rbx,%r12,8),%rax
mov    (%rbx,%r14,8),%rcx
movupd (%rax),%xmm3
movupd (%rcx),%xmm0
subpd  %xmm0,%xmm3
movapd %xmm3,%xmm1
mulpd  %xmm3,%xmm1
unpckhpd %xmm1,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11c0 <force+0xa0>
sqrtsd %xmm0,%xmm0
jmp    11d5 <force+0xb5>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @force(double** %0, double** %1, i32 %2, i32 %3, double %4, double %5) {
%7 = alloca double**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca i32*
store double** %0, double*** %7
store double** %1, double*** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store double %4, double* %11
store double %5, double* %12
store double 0.000000e+00, double* %18
store double 0.000000e+00, double* %19
store double 0.000000e+00, double* %20
store double 0.000000e+00, double* %21
store double 0.000000e+00, double* %22
%24 = load i32, i32* %9
%25 = call i32* @permutation(i32 %24)
store i32* %25, i32** %23
store i32 0, i32* %13
br label %26
26: ; preds = %149, %6
%27 = load i32, i32* %13
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %152
30: ; preds = %26
store i32 0, i32* %14
br label %31
31: ; preds = %145, %30
%32 = load i32, i32* %14
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %148
35: ; preds = %31
%36 = load i32*, i32** %23
%37 = load i32, i32* %14
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
store i32 %40, i32* %16
store i32 0, i32* %15
br label %41
41: ; preds = %141, %35
%42 = load i32, i32* %15
%43 = load i32, i32* %9
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %144
45: ; preds = %41
%46 = load i32*, i32** %23
%47 = load i32, i32* %15
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
store i32 %50, i32* %17
%51 = load i32, i32* %16
%52 = load i32, i32* %17
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %55
54: ; preds = %45
br label %141
55: ; preds = %45
%56 = load double**, double*** %8
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double*, double** %56, i64 %58
%60 = load double*, double** %59
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = load double**, double*** %8
%64 = load i32, i32* %16
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double*, double** %63, i64 %65
%67 = load double*, double** %66
%68 = getelementptr inbounds double, double* %67, i64 0
%69 = load double, double* %68
%70 = fsub double %62, %69
store double %70, double* %21
%71 = load double**, double*** %8
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double*, double** %71, i64 %73
%75 = load double*, double** %74
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load double, double* %76
%78 = load double**, double*** %8
%79 = load i32, i32* %16
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double*, double** %78, i64 %80
%82 = load double*, double** %81
%83 = getelementptr inbounds double, double* %82, i64 1
%84 = load double, double* %83
%85 = fsub double %77, %84
store double %85, double* %22
%86 = load double, double* %21
%87 = load double, double* %21
%88 = load double, double* %22
%89 = load double, double* %22
%90 = fmul double %88, %89
%91 = call double @llvm.fmuladd.f64(double %86, double %87, double %90)
%92 = call double @sqrt(double %91)
store double %92, double* %18
br label %93
93: ; preds = %55
%94 = load double, double* %18
%95 = load double, double* %11
%96 = fcmp olt double %94, %95
br i1 %96, label %97, label %99
97: ; preds = %93
%98 = load double, double* %11
store double %98, double* %18
br label %99
99: ; preds = %97, %93
%100 = load double**, double*** %7
%101 = load i32, i32* %16
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double*, double** %100, i64 %102
%104 = load double*, double** %103
%105 = load i32, i32* %17
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
%108 = load double, double* %107
%109 = load double, double* %18
%110 = fsub double %108, %109
store double %110, double* %19
%111 = load double, double* %19
%112 = load double, double* %18
%113 = fsub double %111, %112
store double %113, double* %20
%114 = load double, double* %12
%115 = load double, double* %20
%116 = fdiv double %115, %114
store double %116, double* %20
%117 = load double, double* %20
%118 = load double, double* %21
%119 = load double, double* %18
%120 = fdiv double %118, %119
%121 = load double**, double*** %8
%122 = load i32, i32* %17
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double*, double** %121, i64 %123
%125 = load double*, double** %124
%126 = getelementptr inbounds double, double* %125, i64 0
%127 = load double, double* %126
%128 = call double @llvm.fmuladd.f64(double %117, double %120, double %127)
store double %128, double* %126
%129 = load double, double* %20
%130 = load double, double* %22
%131 = load double, double* %18
%132 = fdiv double %130, %131
%133 = load double**, double*** %8
%134 = load i32, i32* %17
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double*, double** %133, i64 %135
%137 = load double*, double** %136
%138 = getelementptr inbounds double, double* %137, i64 1
%139 = load double, double* %138
%140 = call double @llvm.fmuladd.f64(double %129, double %132, double %139)
store double %140, double* %138
br label %141
141: ; preds = %99, %54
%142 = load i32, i32* %15
%143 = add nsw i32 %142, 1
store i32 %143, i32* %15
br label %41
144: ; preds = %41
br label %145
145: ; preds = %144
%146 = load i32, i32* %14
%147 = add nsw i32 %146, 1
store i32 %147, i32* %14
br label %31
148: ; preds = %31
br label %149
149: ; preds = %148
%150 = load i32, i32* %13
%151 = add nsw i32 %150, 1
store i32 %151, i32* %13
br label %26
152: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @force(double** nocapture %0, double** nocapture %1, i32 %2, i32 %3, double %4, double %5) {
%7 = tail call i32* @permutation(i32 %2)
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %68
9: ; preds = %6
%10 = icmp sgt i32 %2, 0
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %9, %65
%13 = phi i32 [ 0, %9 ], [ %66, %65 ]
br i1 %10, label %14, label %65
14: ; preds = %12, %62
%15 = phi i64 [ %63, %62 ], [ 0, %12 ]
%16 = getelementptr inbounds i32, i32* %7, i64 %15
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double*, double** %1, i64 %18
%20 = getelementptr inbounds double*, double** %0, i64 %18
%21 = bitcast double** %19 to <2 x double>**
br label %22
22: ; preds = %14, %59
%23 = phi i64 [ 0, %14 ], [ %60, %59 ]
%24 = getelementptr inbounds i32, i32* %7, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %17, %25
br i1 %26, label %59, label %27
27: ; preds = %22
%28 = sext i32 %25 to i64
%29 = getelementptr inbounds double*, double** %1, i64 %28
%30 = bitcast double** %29 to <2 x double>**
%31 = load <2 x double>*, <2 x double>** %30
%32 = load <2 x double>*, <2 x double>** %21
%33 = load <2 x double>, <2 x double>* %31
%34 = load <2 x double>, <2 x double>* %32
%35 = fsub <2 x double> %33, %34
%36 = fmul <2 x double> %35, %35
%37 = extractelement <2 x double> %36, i64 1
%38 = extractelement <2 x double> %35, i64 0
%39 = tail call double @llvm.fmuladd.f64(double %38, double %38, double %37)
%40 = tail call double @sqrt(double %39)
%41 = fcmp olt double %40, %4
%42 = select i1 %41, double %4, double %40
%43 = load double*, double** %20
%44 = getelementptr inbounds double, double* %43, i64 %28
%45 = load double, double* %44
%46 = fsub double %45, %42
%47 = fsub double %46, %42
%48 = fdiv double %47, %5
%49 = load double*, double** %29
%50 = insertelement <2 x double> poison, double %42, i64 0
%51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
%52 = fdiv <2 x double> %35, %51
%53 = bitcast double* %49 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = insertelement <2 x double> poison, double %48, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %56, <2 x double> %52, <2 x double> %54)
%58 = bitcast double* %49 to <2 x double>*
store <2 x double> %57, <2 x double>* %58
br label %59
59: ; preds = %22, %27
%60 = add nuw nsw i64 %23, 1
%61 = icmp eq i64 %60, %11
br i1 %61, label %62, label %22
62: ; preds = %59
%63 = add nuw nsw i64 %15, 1
%64 = icmp eq i64 %63, %11
br i1 %64, label %65, label %14
65: ; preds = %62, %12
%66 = add nuw nsw i32 %13, 1
%67 = icmp eq i32 %66, %3
br i1 %67, label %68, label %12
68: ; preds = %65, %6
ret void
}