#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 *, 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);
  printf("Calculation finished. - Residual stress: %.3f\n", finalstress);
  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    1562 <CStochasticProximityEmbedding+0x3e2>
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    1549 <CStochasticProximityEmbedding+0x3c9>
cmpl   $0x0,-0x88(%rbp)
je     1549 <CStochasticProximityEmbedding+0x3c9>
cmpl   $0x0,0x10(%rbp)
jle    1549 <CStochasticProximityEmbedding+0x3c9>
cvtsi2sdl -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
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>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
movsd  -0x70(%rbp),%xmm2
lea    0xace(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    154e <CStochasticProximityEmbedding+0x3ce>
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
lea    0xab4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
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,0x8(%rsp)
movsd  %xmm1,(%rsp)
mov    %ecx,%ebp
mov    %edx,%ebx
movsd  %xmm0,0x18(%rsp)
mov    %rsi,%r12
mov    %rdi,0x38(%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    %ebp,0x10(%rsp)
imul   %ebx,%ebp
test   %ebp,%ebp
jle    1229 <CStochasticProximityEmbedding+0xa9>
mov    %ebp,%r15d
mov    0x2df1(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
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,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1200 <CStochasticProximityEmbedding+0x80>
cmpl   $0x0,0x28(%rsp)
mov    0x10(%rsp),%ebp
jle    15d9 <CStochasticProximityEmbedding+0x459>
movsd  (%rsp),%xmm1
mov    0x28(%rsp),%rax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
subsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x48(%rsp)
mov    %ebp,%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)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x30(%rsp)
xor    %r15d,%r15d
mov    %r12,0x20(%rsp)
jmp    12e3 <CStochasticProximityEmbedding+0x163>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x30(%rsp),%xmm0
addsd  0xd42(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
add    $0x1,%r15d
cmp    0x28(%rsp),%r15d
je     15d9 <CStochasticProximityEmbedding+0x459>
mov    %r15d,0x44(%rsp)
cmpl   $0x0,0x14(%rsp)
jle    1560 <CStochasticProximityEmbedding+0x3e0>
movsd  (%rsp),%xmm0
mulsd  0xd00(%rip),%xmm0
movsd  %xmm0,0x80(%rsp)
xor    %r12d,%r12d
jmp    131f <CStochasticProximityEmbedding+0x19f>
xchg   %ax,%ax
add    $0x1,%r12d
cmp    0x14(%rsp),%r12d
je     1560 <CStochasticProximityEmbedding+0x3e0>
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %ebx
mov    %edx,%r15d
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %ebx
cmp    %r15d,%edx
je     1330 <CStochasticProximityEmbedding+0x1b0>
mov    %edx,%r13d
mov    0x20(%rsp),%rdi
mov    %r15d,%esi
mov    %ebp,%ecx
call   1080 <ed@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15d,%edi
mov    %r13d,%esi
call   1060 <trmIndex@plt>
movsd  0x8(%rsp),%xmm2
mov    0x38(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    138c <CStochasticProximityEmbedding+0x20c>
ucomisd 0x18(%rsp),%xmm0
jbe    1310 <CStochasticProximityEmbedding+0x190>
ucomisd %xmm2,%xmm0
jbe    1310 <CStochasticProximityEmbedding+0x190>
movapd %xmm2,%xmm1
addsd  0xc70(%rip),%xmm1
test   %ebp,%ebp
jle    1310 <CStochasticProximityEmbedding+0x190>
subsd  %xmm2,%xmm0
mulsd  0x80(%rsp),%xmm0
divsd  %xmm1,%xmm0
imul   %ebp,%r13d
imul   %ebp,%r15d
movslq %r15d,%rax
movslq %r13d,%rcx
cmp    $0x1,%ebp
je     13e8 <CStochasticProximityEmbedding+0x268>
mov    0x20(%rsp),%r8
lea    (%r8,%rax,8),%rdx
mov    0x78(%rsp),%rdi
lea    (%rdi,%rcx,8),%rsi
cmp    %rsi,%rdx
jae    1443 <CStochasticProximityEmbedding+0x2c3>
lea    (%rdi,%rax,8),%rdx
lea    (%r8,%rcx,8),%rsi
cmp    %rdx,%rsi
jae    1443 <CStochasticProximityEmbedding+0x2c3>
xor    %edx,%edx
mov    0x20(%rsp),%rsi
lea    (%rsi,%rcx,8),%rcx
lea    (%rsi,%rax,8),%rax
nopw   0x0(%rax,%rax,1)
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    1400 <CStochasticProximityEmbedding+0x280>
jmp    1310 <CStochasticProximityEmbedding+0x190>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x68(%rsp)
je     1546 <CStochasticProximityEmbedding+0x3c6>
mov    0x50(%rsp),%rdx
lea    (%rdx,%rax,8),%rsi
lea    (%rdx,%rcx,8),%rdi
mov    0x58(%rsp),%rbp
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,%rbp
jne    1470 <CStochasticProximityEmbedding+0x2f0>
testb  $0x1,0x60(%rsp)
je     152c <CStochasticProximityEmbedding+0x3ac>
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    0x10(%rsp),%ebp
je     1310 <CStochasticProximityEmbedding+0x190>
jmp    13ea <CStochasticProximityEmbedding+0x26a>
xor    %edx,%edx
testb  $0x1,0x60(%rsp)
jne    14ed <CStochasticProximityEmbedding+0x36d>
jmp    152c <CStochasticProximityEmbedding+0x3ac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x44(%rsp),%r15d
mov    %r15d,%eax
cltd
mov    0xc0(%rsp),%ecx
idiv   %ecx
movsd  (%rsp),%xmm0
subsd  0x48(%rsp),%xmm0
movsd  %xmm0,(%rsp)
test   %ecx,%ecx
mov    0x20(%rsp),%r12
jle    12c0 <CStochasticProximityEmbedding+0x140>
test   %r15d,%r15d
je     12c0 <CStochasticProximityEmbedding+0x140>
test   %edx,%edx
jne    12c0 <CStochasticProximityEmbedding+0x140>
mov    0x38(%rsp),%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
movsd  0x18(%rsp),%xmm0
call   1030 <neighbours_stress@plt>
movapd %xmm0,%xmm1
lea    0xa56(%rip),%rdi
movsd  0x30(%rsp),%xmm0
movsd  (%rsp),%xmm2
mov    $0x3,%al
call   1050 <printf@plt>
jmp    12c0 <CStochasticProximityEmbedding+0x140>
mov    0x38(%rsp),%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
movsd  0x18(%rsp),%xmm0
call   1030 <neighbours_stress@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xa4a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
@.str = [47 x i8] c"Cycle %d - Residual stress: %.3f, lambda %.3f\0A\00"
@.str.1 = [47 x i8] c"Calculation finished. - Residual stress: %.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 = %221, %64
%66 = load i32, i32* %34
%67 = load i32, i32* %18
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %224
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 %220
203: ; preds = %189
%204 = load i32, i32* %34
%205 = icmp ne i32 %204, 0
br i1 %205, label %206, label %220
206: ; preds = %203
%207 = load i32, i32* %20
%208 = icmp sgt i32 %207, 0
br i1 %208, label %209, label %220
209: ; preds = %206
%210 = load i32, i32* %34
%211 = sitofp i32 %210 to double
%212 = load double*, double** %11
%213 = load double*, double** %12
%214 = load i32, i32* %15
%215 = load i32, i32* %14
%216 = load double, double* %13
%217 = call double @neighbours_stress(double* %212, double* %213, i32 %214, i32 %215, double %216)
%218 = load double, double* %30
%219 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), double %211, double %217, double %218)
br label %220
220: ; preds = %209, %206, %203, %189
br label %221
221: ; preds = %220
%222 = load i32, i32* %34
%223 = add nsw i32 %222, 1
store i32 %223, i32* %34
br label %65
224: ; preds = %65
%225 = load double*, double** %11
%226 = load double*, double** %12
%227 = load i32, i32* %15
%228 = load i32, i32* %14
%229 = load double, double* %13
%230 = call double @neighbours_stress(double* %225, double* %226, i32 %227, i32 %228, double %229)
store double %230, double* %32
%231 = load double, double* %32
%232 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), double %231)
%233 = load double, double* %32
ret double %233
}

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