#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 */
scalar_t__ RAND_MAX;
double ed(double *, int, int, int);
int getpid();
double neighbours_stress(double *, double *, int, int, double);
int /*<<< orphan*/ printf(char *, int, double, double);
int rand();
int /*<<< orphan*/ srand(scalar_t__);
scalar_t__ time(int /*<<< orphan*/ *);
size_t trmIndex(int, int);
double CStochasticProximityEmbedding(double *s, double *d_coords, double rco,
                                     int nelem, int dim, double maxlam,
                                     double minlam, int ncycle, int nstep,
                                     int stressfreq) {
  int a = 0, b = 0, idx = 0, idxa = 0, idxb = 0, idxak = 0, idxbk = 0;
  double dab = 0.0, rab = 0.0;
  double lam = maxlam;
  double t = 0.0;
  double finalstress = 0.0;
  srand(time(NULL) + getpid() * getpid());
  for (int i = 0; i < nelem * dim; i++) {
    d_coords[i] = (double)rand() / (double)RAND_MAX;
  }
  for (int i = 0; i < ncycle; i++) {
    for (int j = 0; j < nstep; j++) {
      a = rand() % nelem;
      while (1) {
        b = rand() % nelem;
        if (b != a)
          break;
      }
      dab = ed(d_coords, a, b, dim);
      rab = s[trmIndex(a, b)];
      if (rab <= rco || (rab > rco && dab < rab)) {
        idxa = a * dim;
        idxb = b * dim;
        t = lam * 0.5 * (rab - dab) / (dab + 1e-8);
        for (int k = 0; k < dim; k++) {
          idxak = idxa + k;
          idxbk = idxb + k;
          d_coords[idxak] =
              d_coords[idxak] + t * (d_coords[idxak] - d_coords[idxbk]);
          d_coords[idxbk] =
              d_coords[idxbk] + t * (d_coords[idxbk] - d_coords[idxak]);
        }
      }
    }
    lam = lam - (maxlam - minlam) / (double)(ncycle - 1);
    if (i % stressfreq == 0 && i != 0 && stressfreq > 0)
      printf("Cycle %d - Residual stress: %.3f, lambda %.3f\n", i,
             neighbours_stress(s, d_coords, dim, nelem, rco), lam);
  }
  finalstress = neighbours_stress(s, d_coords, dim, nelem, rco);
  return (finalstress);
}


x86 assembly (clang, -O0):
<CStochasticProximityEmbedding>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %rax,-0xa0(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x94(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
imul   %ecx,%eax
cltq
add    %rax,%rdi
call   1070 <srand@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    12ac <CStochasticProximityEmbedding+0x12c>
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    0x2d69(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1258 <CStochasticProximityEmbedding+0xd8>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1557 <CStochasticProximityEmbedding+0x3d7>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    14b3 <CStochasticProximityEmbedding+0x333>
mov    $0x0,%al
call   10a0 <rand@plt>
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x3c(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
je     130b <CStochasticProximityEmbedding+0x18b>
jmp    1310 <CStochasticProximityEmbedding+0x190>
jmp    12ec <CStochasticProximityEmbedding+0x16c>
mov    -0x10(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1080 <ed@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1060 <trmIndex@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    1389 <CStochasticProximityEmbedding+0x209>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    149a <CStochasticProximityEmbedding+0x31a>
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    149a <CStochasticProximityEmbedding+0x31a>
mov    -0x3c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movsd  0xc63(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
subsd  -0x60(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc40(%rip),%xmm1
addsd  -0x60(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movl   $0x0,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1495 <CStochasticProximityEmbedding+0x315>
mov    -0x48(%rbp),%eax
add    -0x90(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
add    -0x90(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x78(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x78(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x50(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    13d8 <CStochasticProximityEmbedding+0x258>
jmp    149a <CStochasticProximityEmbedding+0x31a>
jmp    149f <CStochasticProximityEmbedding+0x31f>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    12cf <CStochasticProximityEmbedding+0x14f>
movsd  -0x70(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x88(%rbp),%eax
cltd
idivl  0x10(%rbp)
cmp    $0x0,%edx
jne    153e <CStochasticProximityEmbedding+0x3be>
cmpl   $0x0,-0x88(%rbp)
je     153e <CStochasticProximityEmbedding+0x3be>
cmpl   $0x0,0x10(%rbp)
jle    153e <CStochasticProximityEmbedding+0x3be>
mov    -0x88(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
call   1030 <neighbours_stress@plt>
mov    -0xac(%rbp),%esi
movsd  -0x70(%rbp),%xmm1
lea    0xad7(%rip),%rdi
call   1050 <printf@plt>
jmp    1543 <CStochasticProximityEmbedding+0x3c3>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    12b6 <CStochasticProximityEmbedding+0x136>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
call   1030 <neighbours_stress@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CStochasticProximityEmbedding>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8,0x28(%rsp)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    %ecx,%ebx
mov    %edx,%ebp
movsd  %xmm0,0x18(%rsp)
mov    %rsi,%r12
mov    %rdi,0x30(%rsp)
mov    0xc0(%rsp),%eax
mov    %eax,0x40(%rsp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1040 <getpid@plt>
imul   %r13d,%eax
movslq %eax,%rdi
add    %r15,%rdi
call   1070 <srand@plt>
mov    %ebx,0x4(%rsp)
imul   %ebp,%ebx
test   %ebx,%ebx
jle    1239 <CStochasticProximityEmbedding+0xb9>
mov    %ebx,%r15d
mov    0x2de5(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1210 <CStochasticProximityEmbedding+0x90>
cmpl   $0x0,0x28(%rsp)
mov    0x14(%rsp),%r15d
jle    15c1 <CStochasticProximityEmbedding+0x441>
movsd  0x8(%rsp),%xmm1
subsd  0x38(%rsp),%xmm1
mov    0x28(%rsp),%rax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x48(%rsp)
mov    0x4(%rsp),%r14d
lea    (%r12,%r14,8),%rax
mov    %rax,0x78(%rsp)
mov    %r14d,%eax
and    $0xfffffffe,%eax
mov    %rax,0x70(%rsp)
add    $0xfffffffffffffffe,%rax
mov    %rax,0x68(%rsp)
mov    %rax,%rcx
shr    %rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x60(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x58(%rsp)
lea    0x10(%r12),%rax
mov    %rax,0x50(%rsp)
xor    %ebx,%ebx
mov    %r12,0x20(%rsp)
jmp    12cd <CStochasticProximityEmbedding+0x14d>
xchg   %ax,%ax
add    $0x1,%ebx
cmp    0x28(%rsp),%ebx
je     15c1 <CStochasticProximityEmbedding+0x441>
mov    %ebx,0x44(%rsp)
mov    %r15d,%ebx
test   %r15d,%r15d
jle    1550 <CStochasticProximityEmbedding+0x3d0>
movsd  0x8(%rsp),%xmm0
mulsd  0xd15(%rip),%xmm0
movsd  %xmm0,0x80(%rsp)
xor    %r12d,%r12d
jmp    130d <CStochasticProximityEmbedding+0x18d>
nopl   0x0(%rax)
add    $0x1,%r12d
cmp    %ebx,%r12d
je     1550 <CStochasticProximityEmbedding+0x3d0>
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %ebp
mov    %edx,%r15d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %ebp
cmp    %r15d,%edx
je     1320 <CStochasticProximityEmbedding+0x1a0>
mov    %edx,%r13d
mov    0x20(%rsp),%rdi
mov    %r15d,%esi
mov    0x4(%rsp),%ecx
call   1080 <ed@plt>
movsd  %xmm0,0x38(%rsp)
mov    %r15d,%edi
mov    %r13d,%esi
call   1060 <trmIndex@plt>
movsd  0x38(%rsp),%xmm2
mov    0x30(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    137e <CStochasticProximityEmbedding+0x1fe>
ucomisd 0x18(%rsp),%xmm0
jbe    1300 <CStochasticProximityEmbedding+0x180>
ucomisd %xmm2,%xmm0
jbe    1300 <CStochasticProximityEmbedding+0x180>
movapd %xmm2,%xmm1
addsd  0xc7e(%rip),%xmm1
cmpl   $0x0,0x4(%rsp)
jle    1300 <CStochasticProximityEmbedding+0x180>
subsd  %xmm2,%xmm0
mulsd  0x80(%rsp),%xmm0
divsd  %xmm1,%xmm0
mov    0x4(%rsp),%edx
imul   %edx,%r13d
imul   %edx,%r15d
movslq %r15d,%rax
movslq %r13d,%rcx
cmp    $0x1,%edx
je     13e1 <CStochasticProximityEmbedding+0x261>
mov    0x20(%rsp),%r8
lea    (%r8,%rax,8),%rdx
mov    0x78(%rsp),%rdi
lea    (%rdi,%rcx,8),%rsi
cmp    %rsi,%rdx
jae    1433 <CStochasticProximityEmbedding+0x2b3>
lea    (%rdi,%rax,8),%rdx
lea    (%r8,%rcx,8),%rsi
cmp    %rdx,%rsi
jae    1433 <CStochasticProximityEmbedding+0x2b3>
xor    %edx,%edx
mov    0x20(%rsp),%rsi
lea    (%rsi,%rcx,8),%rcx
lea    (%rsi,%rax,8),%rax
movsd  (%rax,%rdx,8),%xmm1
movapd %xmm1,%xmm2
subsd  (%rcx,%rdx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rax,%rdx,8)
movsd  (%rcx,%rdx,8),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rcx,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%r14
jne    13f0 <CStochasticProximityEmbedding+0x270>
jmp    1300 <CStochasticProximityEmbedding+0x180>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x68(%rsp)
je     1536 <CStochasticProximityEmbedding+0x3b6>
mov    0x50(%rsp),%rdx
lea    (%rdx,%rax,8),%rsi
lea    (%rdx,%rcx,8),%rdi
mov    0x58(%rsp),%rbx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movupd -0x10(%rsi,%rdx,8),%xmm2
movupd -0x10(%rdi,%rdx,8),%xmm3
movapd %xmm2,%xmm4
subpd  %xmm3,%xmm4
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm4,-0x10(%rsi,%rdx,8)
movapd %xmm3,%xmm2
subpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm3,%xmm2
movupd %xmm2,-0x10(%rdi,%rdx,8)
movupd (%rsi,%rdx,8),%xmm2
movupd (%rdi,%rdx,8),%xmm3
movapd %xmm2,%xmm4
subpd  %xmm3,%xmm4
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm4,(%rsi,%rdx,8)
movapd %xmm3,%xmm2
subpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm3,%xmm2
movupd %xmm2,(%rdi,%rdx,8)
add    $0x4,%rdx
add    $0xfffffffffffffffe,%rbx
jne    1460 <CStochasticProximityEmbedding+0x2e0>
testb  $0x1,0x60(%rsp)
je     151c <CStochasticProximityEmbedding+0x39c>
lea    (%rdx,%rax,1),%rsi
add    %rcx,%rdx
movupd (%r8,%rsi,8),%xmm2
movupd (%r8,%rdx,8),%xmm3
movapd %xmm2,%xmm4
subpd  %xmm3,%xmm4
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm4,(%r8,%rsi,8)
movapd %xmm3,%xmm2
subpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm3,%xmm2
movupd %xmm2,(%r8,%rdx,8)
mov    0x70(%rsp),%rsi
mov    %rsi,%rdx
cmp    %r14,%rsi
mov    0x14(%rsp),%ebx
je     1300 <CStochasticProximityEmbedding+0x180>
jmp    13e3 <CStochasticProximityEmbedding+0x263>
xor    %edx,%edx
testb  $0x1,0x60(%rsp)
jne    14dd <CStochasticProximityEmbedding+0x35d>
jmp    151c <CStochasticProximityEmbedding+0x39c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r15d
mov    0x44(%rsp),%ebx
mov    %ebx,%eax
cltd
mov    0x40(%rsp),%ecx
idiv   %ecx
movsd  0x8(%rsp),%xmm0
subsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
test   %ecx,%ecx
mov    0x20(%rsp),%r12
jle    12c0 <CStochasticProximityEmbedding+0x140>
test   %ebx,%ebx
je     12c0 <CStochasticProximityEmbedding+0x140>
test   %edx,%edx
jne    12c0 <CStochasticProximityEmbedding+0x140>
mov    0x30(%rsp),%rdi
mov    %r12,%rsi
mov    0x4(%rsp),%edx
mov    %ebp,%ecx
movsd  0x18(%rsp),%xmm0
call   1030 <neighbours_stress@plt>
lea    0xa61(%rip),%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm1
call   1050 <printf@plt>
jmp    12c0 <CStochasticProximityEmbedding+0x140>
mov    0x30(%rsp),%rdi
mov    %r12,%rsi
mov    0x4(%rsp),%edx
mov    %ebp,%ecx
movsd  0x18(%rsp),%xmm0
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <neighbours_stress@plt>

LLVM IR (-O0):
@RAND_MAX = global i64 0
@.str = [47 x i8] c"Cycle %d - Residual stress: %.3f, lambda %.3f\0A\00"
define double @CStochasticProximityEmbedding(double* %0, double* %1, double %2, i32 %3, i32 %4, double %5, double %6, i32 %7, i32 %8, i32 %9) {
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32
store double* %0, double** %11
store double* %1, double** %12
store double %2, double* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store double %5, double* %16
store double %6, double* %17
store i32 %7, i32* %18
store i32 %8, i32* %19
store i32 %9, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
store i32 0, i32* %25
store i32 0, i32* %26
store i32 0, i32* %27
store double 0.000000e+00, double* %28
store double 0.000000e+00, double* %29
%37 = load double, double* %16
store double %37, double* %30
store double 0.000000e+00, double* %31
store double 0.000000e+00, double* %32
%38 = call i64 @time(i32* null)
%39 = call i32 (...) @getpid()
%40 = call i32 (...) @getpid()
%41 = mul nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = add nsw i64 %38, %42
%44 = call i32 @srand(i64 %43)
store i32 0, i32* %33
br label %45
45: ; preds = %61, %10
%46 = load i32, i32* %33
%47 = load i32, i32* %14
%48 = load i32, i32* %15
%49 = mul nsw i32 %47, %48
%50 = icmp slt i32 %46, %49
br i1 %50, label %51, label %64
51: ; preds = %45
%52 = call i32 (...) @rand()
%53 = sitofp i32 %52 to double
%54 = load i64, i64* @RAND_MAX
%55 = sitofp i64 %54 to double
%56 = fdiv double %53, %55
%57 = load double*, double** %12
%58 = load i32, i32* %33
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
store double %56, double* %60
br label %61
61: ; preds = %51
%62 = load i32, i32* %33
%63 = add nsw i32 %62, 1
store i32 %63, i32* %33
br label %45
64: ; preds = %45
store i32 0, i32* %34
br label %65
65: ; preds = %220, %64
%66 = load i32, i32* %34
%67 = load i32, i32* %18
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %223
69: ; preds = %65
store i32 0, i32* %35
br label %70
70: ; preds = %186, %69
%71 = load i32, i32* %35
%72 = load i32, i32* %19
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %189
74: ; preds = %70
%75 = call i32 (...) @rand()
%76 = load i32, i32* %14
%77 = srem i32 %75, %76
store i32 %77, i32* %21
br label %78
78: ; preds = %74, %86
%79 = call i32 (...) @rand()
%80 = load i32, i32* %14
%81 = srem i32 %79, %80
store i32 %81, i32* %22
%82 = load i32, i32* %22
%83 = load i32, i32* %21
%84 = icmp ne i32 %82, %83
br i1 %84, label %85, label %86
85: ; preds = %78
br label %87
86: ; preds = %78
br label %78
87: ; preds = %85
%88 = load double*, double** %12
%89 = load i32, i32* %21
%90 = load i32, i32* %22
%91 = load i32, i32* %15
%92 = call double @ed(double* %88, i32 %89, i32 %90, i32 %91)
store double %92, double* %28
%93 = load double*, double** %11
%94 = load i32, i32* %21
%95 = load i32, i32* %22
%96 = call i64 @trmIndex(i32 %94, i32 %95)
%97 = getelementptr inbounds double, double* %93, i64 %96
%98 = load double, double* %97
store double %98, double* %29
%99 = load double, double* %29
%100 = load double, double* %13
%101 = fcmp ole double %99, %100
br i1 %101, label %110, label %102
102: ; preds = %87
%103 = load double, double* %29
%104 = load double, double* %13
%105 = fcmp ogt double %103, %104
br i1 %105, label %106, label %185
106: ; preds = %102
%107 = load double, double* %28
%108 = load double, double* %29
%109 = fcmp olt double %107, %108
br i1 %109, label %110, label %185
110: ; preds = %106, %87
%111 = load i32, i32* %21
%112 = load i32, i32* %15
%113 = mul nsw i32 %111, %112
store i32 %113, i32* %24
%114 = load i32, i32* %22
%115 = load i32, i32* %15
%116 = mul nsw i32 %114, %115
store i32 %116, i32* %25
%117 = load double, double* %30
%118 = fmul double %117, 5.000000e-01
%119 = load double, double* %29
%120 = load double, double* %28
%121 = fsub double %119, %120
%122 = fmul double %118, %121
%123 = load double, double* %28
%124 = fadd double %123, 1.000000e-08
%125 = fdiv double %122, %124
store double %125, double* %31
store i32 0, i32* %36
br label %126
126: ; preds = %181, %110
%127 = load i32, i32* %36
%128 = load i32, i32* %15
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %184
130: ; preds = %126
%131 = load i32, i32* %24
%132 = load i32, i32* %36
%133 = add nsw i32 %131, %132
store i32 %133, i32* %26
%134 = load i32, i32* %25
%135 = load i32, i32* %36
%136 = add nsw i32 %134, %135
store i32 %136, i32* %27
%137 = load double*, double** %12
%138 = load i32, i32* %26
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds double, double* %137, i64 %139
%141 = load double, double* %140
%142 = load double, double* %31
%143 = load double*, double** %12
%144 = load i32, i32* %26
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %143, i64 %145
%147 = load double, double* %146
%148 = load double*, double** %12
%149 = load i32, i32* %27
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %148, i64 %150
%152 = load double, double* %151
%153 = fsub double %147, %152
%154 = call double @llvm.fmuladd.f64(double %142, double %153, double %141)
%155 = load double*, double** %12
%156 = load i32, i32* %26
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %155, i64 %157
store double %154, double* %158
%159 = load double*, double** %12
%160 = load i32, i32* %27
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %159, i64 %161
%163 = load double, double* %162
%164 = load double, double* %31
%165 = load double*, double** %12
%166 = load i32, i32* %27
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
%169 = load double, double* %168
%170 = load double*, double** %12
%171 = load i32, i32* %26
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %170, i64 %172
%174 = load double, double* %173
%175 = fsub double %169, %174
%176 = call double @llvm.fmuladd.f64(double %164, double %175, double %163)
%177 = load double*, double** %12
%178 = load i32, i32* %27
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds double, double* %177, i64 %179
store double %176, double* %180
br label %181
181: ; preds = %130
%182 = load i32, i32* %36
%183 = add nsw i32 %182, 1
store i32 %183, i32* %36
br label %126
184: ; preds = %126
br label %185
185: ; preds = %184, %106, %102
br label %186
186: ; preds = %185
%187 = load i32, i32* %35
%188 = add nsw i32 %187, 1
store i32 %188, i32* %35
br label %70
189: ; preds = %70
%190 = load double, double* %30
%191 = load double, double* %16
%192 = load double, double* %17
%193 = fsub double %191, %192
%194 = load i32, i32* %18
%195 = sub nsw i32 %194, 1
%196 = sitofp i32 %195 to double
%197 = fdiv double %193, %196
%198 = fsub double %190, %197
store double %198, double* %30
%199 = load i32, i32* %34
%200 = load i32, i32* %20
%201 = srem i32 %199, %200
%202 = icmp eq i32 %201, 0
br i1 %202, label %203, label %219
203: ; preds = %189
%204 = load i32, i32* %34
%205 = icmp ne i32 %204, 0
br i1 %205, label %206, label %219
206: ; preds = %203
%207 = load i32, i32* %20
%208 = icmp sgt i32 %207, 0
br i1 %208, label %209, label %219
209: ; preds = %206
%210 = load i32, i32* %34
%211 = load double*, double** %11
%212 = load double*, double** %12
%213 = load i32, i32* %15
%214 = load i32, i32* %14
%215 = load double, double* %13
%216 = call double @neighbours_stress(double* %211, double* %212, i32 %213, i32 %214, double %215)
%217 = load double, double* %30
%218 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %210, double %216, double %217)
br label %219
219: ; preds = %209, %206, %203, %189
br label %220
220: ; preds = %219
%221 = load i32, i32* %34
%222 = add nsw i32 %221, 1
store i32 %222, i32* %34
br label %65
223: ; preds = %65
%224 = load double*, double** %11
%225 = load double*, double** %12
%226 = load i32, i32* %15
%227 = load i32, i32* %14
%228 = load double, double* %13
%229 = call double @neighbours_stress(double* %224, double* %225, i32 %226, i32 %227, double %228)
store double %229, double* %32
%230 = load double, double* %32
ret double %230
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [47 x i8] c"Cycle %d - Residual stress: %.3f, lambda %.3f\0A\00"
define double @CStochasticProximityEmbedding(double* %0, double* %1, double %2, i32 %3, i32 %4, double %5, double %6, i32 %7, i32 %8, i32 %9) {
%11 = tail call i64 @time(i32* null)
%12 = tail call i32 (...) @getpid()
%13 = tail call i32 (...) @getpid()
%14 = mul nsw i32 %13, %12
%15 = sext i32 %14 to i64
%16 = add nsw i64 %11, %15
%17 = tail call i32 @srand(i64 %16)
%18 = mul i32 %4, %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = zext i32 %18 to i64
br label %46
22: ; preds = %46, %10
%23 = icmp sgt i32 %7, 0
br i1 %23, label %24, label %61
24: ; preds = %22
%25 = icmp sgt i32 %8, 0
%26 = icmp sgt i32 %4, 0
%27 = fsub double %5, %6
%28 = add nsw i32 %7, -1
%29 = sitofp i32 %28 to double
%30 = fdiv double %27, %29
%31 = icmp sgt i32 %9, 0
%32 = zext i32 %4 to i64
%33 = getelementptr double, double* %1, i64 %32
%34 = getelementptr double, double* %1, i64 %32
%35 = and i64 %32, 4294967294
%36 = add nsw i64 %35, -2
%37 = lshr exact i64 %36, 1
%38 = add nuw i64 %37, 1
%39 = icmp eq i32 %4, 1
%40 = and i64 %32, 4294967294
%41 = and i64 %38, 1
%42 = icmp eq i64 %36, 0
%43 = and i64 %38, -2
%44 = icmp eq i64 %41, 0
%45 = icmp eq i64 %40, %32
br label %56
46: ; preds = %20, %46
%47 = phi i64 [ 0, %20 ], [ %54, %46 ]
%48 = tail call i32 (...) @rand()
%49 = sitofp i32 %48 to double
%50 = load i64, i64* @RAND_MAX
%51 = sitofp i64 %50 to double
%52 = fdiv double %49, %51
%53 = getelementptr inbounds double, double* %1, i64 %47
store double %52, double* %53
%54 = add nuw nsw i64 %47, 1
%55 = icmp eq i64 %54, %21
br i1 %55, label %22, label %46
56: ; preds = %24, %185
%57 = phi i32 [ 0, %24 ], [ %186, %185 ]
%58 = phi double [ %5, %24 ], [ %64, %185 ]
br i1 %25, label %59, label %63
59: ; preds = %56
%60 = fmul double %58, 5.000000e-01
br label %70
61: ; preds = %185, %22
%62 = tail call double @neighbours_stress(double* %0, double* %1, i32 %4, i32 %3, double %2)
ret double %62
63: ; preds = %179, %56
%64 = fsub double %58, %30
%65 = srem i32 %57, %9
%66 = icmp eq i32 %65, 0
%67 = icmp ne i32 %57, 0
%68 = and i1 %67, %66
%69 = and i1 %31, %68
br i1 %69, label %182, label %185
70: ; preds = %59, %179
%71 = phi i32 [ 0, %59 ], [ %180, %179 ]
%72 = tail call i32 (...) @rand()
%73 = srem i32 %72, %3
br label %74
74: ; preds = %74, %70
%75 = tail call i32 (...) @rand()
%76 = srem i32 %75, %3
%77 = icmp eq i32 %76, %73
br i1 %77, label %74, label %78
78: ; preds = %74
%79 = tail call double @ed(double* %1, i32 %73, i32 %76, i32 %4)
%80 = tail call i64 @trmIndex(i32 %73, i32 %76)
%81 = getelementptr inbounds double, double* %0, i64 %80
%82 = load double, double* %81
%83 = fcmp ugt double %82, %2
br i1 %83, label %84, label %88
84: ; preds = %78
%85 = fcmp ogt double %82, %2
%86 = fcmp olt double %79, %82
%87 = select i1 %85, i1 %86, i1 false
br i1 %87, label %88, label %179
88: ; preds = %84, %78
%89 = fsub double %82, %79
%90 = fmul double %60, %89
%91 = fadd double %79, 1.000000e-08
%92 = fdiv double %90, %91
br i1 %26, label %93, label %179
93: ; preds = %88
%94 = mul nsw i32 %76, %4
%95 = mul nsw i32 %73, %4
%96 = sext i32 %95 to i64
%97 = sext i32 %94 to i64
br i1 %39, label %162, label %98
98: ; preds = %93
%99 = getelementptr double, double* %1, i64 %96
%100 = getelementptr double, double* %33, i64 %96
%101 = getelementptr double, double* %1, i64 %97
%102 = getelementptr double, double* %34, i64 %97
%103 = icmp ult double* %99, %102
%104 = icmp ult double* %101, %100
%105 = and i1 %103, %104
br i1 %105, label %162, label %106
106: ; preds = %98
%107 = insertelement <2 x double> poison, double %92, i64 0
%108 = shufflevector <2 x double> %107, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %42, label %144, label %109
109: ; preds = %106, %109
%110 = phi i64 [ %141, %109 ], [ 0, %106 ]
%111 = phi i64 [ %142, %109 ], [ 0, %106 ]
%112 = add nsw i64 %110, %96
%113 = add nsw i64 %110, %97
%114 = getelementptr inbounds double, double* %1, i64 %112
%115 = bitcast double* %114 to <2 x double>*
%116 = load <2 x double>, <2 x double>* %115
%117 = getelementptr inbounds double, double* %1, i64 %113
%118 = bitcast double* %117 to <2 x double>*
%119 = load <2 x double>, <2 x double>* %118
%120 = fsub <2 x double> %116, %119
%121 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %120, <2 x double> %116)
%122 = bitcast double* %114 to <2 x double>*
store <2 x double> %121, <2 x double>* %122
%123 = fsub <2 x double> %119, %121
%124 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %123, <2 x double> %119)
%125 = bitcast double* %117 to <2 x double>*
store <2 x double> %124, <2 x double>* %125
%126 = or i64 %110, 2
%127 = add nsw i64 %126, %96
%128 = add nsw i64 %126, %97
%129 = getelementptr inbounds double, double* %1, i64 %127
%130 = bitcast double* %129 to <2 x double>*
%131 = load <2 x double>, <2 x double>* %130
%132 = getelementptr inbounds double, double* %1, i64 %128
%133 = bitcast double* %132 to <2 x double>*
%134 = load <2 x double>, <2 x double>* %133
%135 = fsub <2 x double> %131, %134
%136 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %135, <2 x double> %131)
%137 = bitcast double* %129 to <2 x double>*
store <2 x double> %136, <2 x double>* %137
%138 = fsub <2 x double> %134, %136
%139 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %138, <2 x double> %134)
%140 = bitcast double* %132 to <2 x double>*
store <2 x double> %139, <2 x double>* %140
%141 = add nuw i64 %110, 4
%142 = add nuw i64 %111, 2
%143 = icmp eq i64 %142, %43
br i1 %143, label %144, label %109
144: ; preds = %109, %106
%145 = phi i64 [ 0, %106 ], [ %141, %109 ]
br i1 %44, label %161, label %146
146: ; preds = %144
%147 = add nsw i64 %145, %96
%148 = add nsw i64 %145, %97
%149 = getelementptr inbounds double, double* %1, i64 %147
%150 = bitcast double* %149 to <2 x double>*
%151 = load <2 x double>, <2 x double>* %150
%152 = getelementptr inbounds double, double* %1, i64 %148
%153 = bitcast double* %152 to <2 x double>*
%154 = load <2 x double>, <2 x double>* %153
%155 = fsub <2 x double> %151, %154
%156 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %155, <2 x double> %151)
%157 = bitcast double* %149 to <2 x double>*
store <2 x double> %156, <2 x double>* %157
%158 = fsub <2 x double> %154, %156
%159 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %108, <2 x double> %158, <2 x double> %154)
%160 = bitcast double* %152 to <2 x double>*
store <2 x double> %159, <2 x double>* %160
br label %161
161: ; preds = %144, %146
br i1 %45, label %179, label %162
162: ; preds = %98, %93, %161
%163 = phi i64 [ 0, %98 ], [ 0, %93 ], [ %40, %161 ]
br label %164
164: ; preds = %162, %164
%165 = phi i64 [ %177, %164 ], [ %163, %162 ]
%166 = add nsw i64 %165, %96
%167 = add nsw i64 %165, %97
%168 = getelementptr inbounds double, double* %1, i64 %166
%169 = load double, double* %168
%170 = getelementptr inbounds double, double* %1, i64 %167
%171 = load double, double* %170
%172 = fsub double %169, %171
%173 = tail call double @llvm.fmuladd.f64(double %92, double %172, double %169)
store double %173, double* %168
%174 = load double, double* %170
%175 = fsub double %174, %173
%176 = tail call double @llvm.fmuladd.f64(double %92, double %175, double %174)
store double %176, double* %170
%177 = add nuw nsw i64 %165, 1
%178 = icmp eq i64 %177, %32
br i1 %178, label %179, label %164
179: ; preds = %164, %161, %88, %84
%180 = add nuw nsw i32 %71, 1
%181 = icmp eq i32 %180, %8
br i1 %181, label %63, label %70
182: ; preds = %63
%183 = tail call double @neighbours_stress(double* %0, double* %1, i32 %4, i32 %3, double %2)
%184 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %57, double %183, double %64)
br label %185
185: ; preds = %63, %182
%186 = add nuw nsw i32 %57, 1
%187 = icmp eq i32 %186, %7
br i1 %187, label %61, label %56
}