#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;
int /*<<< orphan*/ printf(char *, ...);
double rand();
int /*<<< orphan*/ srand(unsigned int);
void init_velocities(int nAtoms, int ig, double Ar_mmass, double RT, double R,
                     double *int_temp, double *Tot_kinetic_en,
                     double **atomVelocities) {
  double sumv[3] = {0.0, 0.0, 0.0};
  double sumv2;
  int i, j;
  double scale_factor;
  double dof;
  double convert;
  double convert2;
  double sqrt(double x);
  srand((unsigned)ig);
  dof = nAtoms * 3;
  sumv2 = 0.0;
  convert = 0.0001;
  convert2 = 4184 * convert;
  *Tot_kinetic_en = 0.0;
  *int_temp = 0.0;
  for (j = 0; j < 3; j++) {
    sumv[j] = 0.0;
    for (i = 0; i < nAtoms; i++) {
      atomVelocities[i][j] = (rand() / ((double)RAND_MAX) - 0.5);
      sumv[j] += atomVelocities[i][j];
      sumv2 += atomVelocities[i][j] * atomVelocities[i][j];
    }
    sumv[j] = sumv[j] / nAtoms;
  }
  printf("average velocity (Ang ps^-1): %12.6f%12.6f%12.6f\n", sumv[0], sumv[1],
         sumv[2]);
  printf("Total velocity squared (Ang^2 ps^-2): %12.6f\n", sumv2);
  sumv2 = sumv2 / dof;
  printf("average velocity squared (Ang^2 ps^-2): %12.6f\n", sumv2);
  scale_factor = sqrt(RT * convert2 / (Ar_mmass * sumv2));
  printf("scale factor = %12.6f\n", scale_factor);
  sumv2 = 0.0;
  for (i = 0; i < nAtoms; i++) {
    for (j = 0; j < 3; j++) {
      sumv[j] = 0.0;
      atomVelocities[i][j] = (atomVelocities[i][j] - sumv[j]) * scale_factor;
      sumv[j] += atomVelocities[i][j];
      sumv[j] = sumv[j] / nAtoms;
      sumv2 += atomVelocities[i][j] * atomVelocities[i][j];
    }
  }
  printf("After velocity scaling:\n");
  printf("average velocity (Ang ps^-1): %12.6f%12.6f%12.6f\n", sumv[0], sumv[1],
         sumv[2]);
  printf("Total velocity squared (Ang^2 ps^-2): %12.6f\n", sumv2);
  *Tot_kinetic_en = 0.5 * Ar_mmass * sumv2 / convert2;
  sumv2 = sumv2 / dof;
  *int_temp = (Ar_mmass * sumv2) / (R * convert2);
  printf("Total Kinetic Energy (kcal mol^-1): %12.6f\n", *Tot_kinetic_en);
  printf("average velocity squared (Ang^2 ps^-2): %12.6f\n", sumv2);
  printf("Instantaneous Temperature (K): %12.6f\n", *int_temp);
}


x86 assembly (clang, -O0):
<init_velocities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%edi
call   1050 <srand@plt>
imul   $0x3,-0x4(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe42(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x60(%rbp)
cmpl   $0x3,-0x60(%rbp)
jge    12e1 <init_velocities+0x191>
movslq -0x60(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b6 <init_velocities+0x166>
mov    $0x0,%al
call   1070 <rand@plt>
mov    0x2dcb(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xde2(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x60(%rbp),%rax
addsd  -0x50(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1203 <init_velocities+0xb3>
movslq -0x60(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movslq -0x60(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11e5 <init_velocities+0x95>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xd21(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xd40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
divsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
lea    0xd4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0xd47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1479 <init_velocities+0x329>
movl   $0x0,-0x60(%rbp)
cmpl   $0x3,-0x60(%rbp)
jge    1466 <init_velocities+0x316>
movslq -0x60(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x60(%rbp),%rax
subsd  -0x50(%rbp,%rax,8),%xmm0
mulsd  -0x68(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x60(%rbp),%rax
addsd  -0x50(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x50(%rbp,%rax,8)
movslq -0x60(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movslq -0x60(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    138a <init_velocities+0x23a>
jmp    146b <init_velocities+0x31b>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1377 <init_velocities+0x227>
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xb7b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xb9a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xb51(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
divsd  -0x80(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
divsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xbc4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xb51(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xbc7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_velocities>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8,%r13
mov    %rcx,%r15
mov    %rdx,%rbp
movsd  %xmm2,0x68(%rsp)
movsd  %xmm1,0x60(%rsp)
movsd  %xmm0,0x48(%rsp)
mov    %edi,%r12d
mov    %esi,%edi
call   1050 <srand@plt>
lea    (%r12,%r12,2),%eax
movq   $0x0,(%r15)
movq   $0x0,0x0(%rbp)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movapd %xmm0,0x70(%rsp)
xorpd  %xmm1,%xmm1
mov    %r12d,%ebx
test   %r12d,%r12d
jle    132c <init_velocities+0x1dc>
mov    %eax,0x1c(%rsp)
mov    %rbp,0x30(%rsp)
xorpd  %xmm3,%xmm3
mov    0x2e1d(%rip),%r14
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  %xmm3,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
movsd  0xe06(%rip),%xmm2
movsd  0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mov    0x0(%r13,%rbp,8),%rax
movsd  %xmm0,(%rax)
addsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <init_velocities+0x90>
test   %r12d,%r12d
jle    133b <init_velocities+0x1eb>
movsd  %xmm3,0x10(%rsp)
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movapd %xmm1,0x20(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
movapd 0x20(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sdq (%r14),%xmm2
divsd  %xmm2,%xmm0
addsd  0xd74(%rip),%xmm0
mov    0x0(%r13,%rbp,8),%rax
movsd  %xmm0,0x8(%rax)
addsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1260 <init_velocities+0x110>
test   %r12d,%r12d
jle    1346 <init_velocities+0x1f6>
movaps %xmm1,0x20(%rsp)
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
xchg   %ax,%ax
movapd %xmm2,0x50(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
movapd 0x50(%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
addsd  0xd09(%rip),%xmm0
mov    0x0(%r13,%rbp,8),%rax
movsd  %xmm0,0x10(%rax)
addsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12d0 <init_velocities+0x180>
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm2,%xmm1
jmp    134a <init_velocities+0x1fa>
xorpd  %xmm3,%xmm3
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    1359 <init_velocities+0x209>
mov    0x30(%rsp),%rbp
xorpd  %xmm1,%xmm1
jmp    1355 <init_velocities+0x205>
movq   %xmm1,%xmm1
mov    0x30(%rsp),%rbp
movsd  0x10(%rsp),%xmm3
mov    0x1c(%rsp),%eax
movapd 0x70(%rsp),%xmm0
divsd  %xmm0,%xmm3
unpcklpd %xmm0,%xmm0
movapd %xmm0,0x30(%rsp)
divpd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x50(%rsp)
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
lea    0xc93(%rip),%rdi
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm0
movapd %xmm1,0x20(%rsp)
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xca7(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
divsd  0x50(%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xcb2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x60(%rsp),%xmm0
mulsd  0xc25(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  0x48(%rsp),%xmm1
divsd  %xmm1,%xmm0
ucomisd 0xc1e(%rip),%xmm0
jb     1402 <init_velocities+0x2b2>
sqrtsd %xmm0,%xmm0
jmp    1407 <init_velocities+0x2b7>
call   1060 <sqrt@plt>
lea    0xca2(%rip),%rdi
movapd %xmm0,(%rsp)
mov    $0x1,%al
call   1040 <printf@plt>
test   %r12d,%r12d
jle    14bf <init_velocities+0x36f>
movapd (%rsp),%xmm6
movapd %xmm6,%xmm0
unpcklpd %xmm6,%xmm0
xorpd  %xmm5,%xmm5
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%r13,%rax,8),%rcx
movsd  (%rcx),%xmm3
mulsd  %xmm6,%xmm3
movsd  %xmm3,(%rcx)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm5,%xmm1
movupd 0x8(%rcx),%xmm4
mulpd  %xmm0,%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
movupd %xmm4,0x8(%rcx)
movapd %xmm4,%xmm5
unpckhpd %xmm4,%xmm5
mulsd  %xmm5,%xmm5
addsd  %xmm2,%xmm5
add    $0x1,%rax
cmp    %rax,%rbx
jne    1440 <init_velocities+0x2f0>
xorpd  %xmm0,%xmm0
addpd  %xmm0,%xmm4
divpd  0x30(%rsp),%xmm4
movapd %xmm4,0x20(%rsp)
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm3
divsd  0x70(%rsp),%xmm3
movsd  %xmm3,0x10(%rsp)
movapd %xmm5,(%rsp)
jmp    14c8 <init_velocities+0x378>
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
lea    0xc4b(%rip),%rdi
call   1030 <puts@plt>
movaps 0x20(%rsp),%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
lea    0xb39(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xb57(%rip),%rdi
movaps (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0xb02(%rip),%xmm0
movsd  0x48(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movapd (%rsp),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xadf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
divsd  0x50(%rsp),%xmm3
movapd %xmm3,(%rsp)
mulsd  %xmm3,%xmm2
movsd  0x68(%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x0(%rbp)
movsd  (%r15),%xmm0
lea    0xb67(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xb12(%rip),%rdi
movaps (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x0(%rbp),%xmm0
lea    0xb6e(%rip),%rdi
mov    $0x1,%al
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@RAND_MAX = global i64 0
@.str = [50 x i8] c"average velocity (Ang ps^-1): %12.6f%12.6f%12.6f\0A\00"
@.str.1 = [46 x i8] c"Total velocity squared (Ang^2 ps^-2): %12.6f\0A\00"
@.str.2 = [48 x i8] c"average velocity squared (Ang^2 ps^-2): %12.6f\0A\00"
@.str.3 = [23 x i8] c"scale factor = %12.6f\0A\00"
@.str.4 = [25 x i8] c"After velocity scaling:\0A\00"
@.str.5 = [44 x i8] c"Total Kinetic Energy (kcal mol^-1): %12.6f\0A\00"
@.str.6 = [39 x i8] c"Instantaneous Temperature (K): %12.6f\0A\00"
define void @init_velocities(i32 %0, i32 %1, double %2, double %3, double %4, double* %5, double* %6, double** %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double*
%15 = alloca double*
%16 = alloca double**
%17 = alloca [3 x double]
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double* %5, double** %14
store double* %6, double** %15
store double** %7, double*** %16
%25 = bitcast [3 x double]* %17 to i8*
%26 = load i32, i32* %10
%27 = call i32 @srand(i32 %26)
%28 = load i32, i32* %9
%29 = mul nsw i32 %28, 3
%30 = sitofp i32 %29 to double
store double %30, double* %22
store double 0.000000e+00, double* %18
store double 1.000000e-04, double* %23
%31 = load double, double* %23
%32 = fmul double 4.184000e+03, %31
store double %32, double* %24
%33 = load double*, double** %15
store double 0.000000e+00, double* %33
%34 = load double*, double** %14
store double 0.000000e+00, double* %34
store i32 0, i32* %20
br label %35
35: ; preds = %108, %8
%36 = load i32, i32* %20
%37 = icmp slt i32 %36, 3
br i1 %37, label %38, label %111
38: ; preds = %35
%39 = load i32, i32* %20
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %40
store double 0.000000e+00, double* %41
store i32 0, i32* %19
br label %42
42: ; preds = %94, %38
%43 = load i32, i32* %19
%44 = load i32, i32* %9
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %97
46: ; preds = %42
%47 = call double (...) @rand()
%48 = load i64, i64* @RAND_MAX
%49 = sitofp i64 %48 to double
%50 = fdiv double %47, %49
%51 = fsub double %50, 5.000000e-01
%52 = load double**, double*** %16
%53 = load i32, i32* %19
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double*, double** %52, i64 %54
%56 = load double*, double** %55
%57 = load i32, i32* %20
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %51, double* %59
%60 = load double**, double*** %16
%61 = load i32, i32* %19
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double*, double** %60, i64 %62
%64 = load double*, double** %63
%65 = load i32, i32* %20
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load i32, i32* %20
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %70
%72 = load double, double* %71
%73 = fadd double %72, %68
store double %73, double* %71
%74 = load double**, double*** %16
%75 = load i32, i32* %19
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double*, double** %74, i64 %76
%78 = load double*, double** %77
%79 = load i32, i32* %20
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load double, double* %81
%83 = load double**, double*** %16
%84 = load i32, i32* %19
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double*, double** %83, i64 %85
%87 = load double*, double** %86
%88 = load i32, i32* %20
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %87, i64 %89
%91 = load double, double* %90
%92 = load double, double* %18
%93 = call double @llvm.fmuladd.f64(double %82, double %91, double %92)
store double %93, double* %18
br label %94
94: ; preds = %46
%95 = load i32, i32* %19
%96 = add nsw i32 %95, 1
store i32 %96, i32* %19
br label %42
97: ; preds = %42
%98 = load i32, i32* %20
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %99
%101 = load double, double* %100
%102 = load i32, i32* %9
%103 = sitofp i32 %102 to double
%104 = fdiv double %101, %103
%105 = load i32, i32* %20
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %106
store double %104, double* %107
br label %108
108: ; preds = %97
%109 = load i32, i32* %20
%110 = add nsw i32 %109, 1
store i32 %110, i32* %20
br label %35
111: ; preds = %35
%112 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%113 = load double, double* %112
%114 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 1
%115 = load double, double* %114
%116 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 2
%117 = load double, double* %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %113, double %115, double %117)
%119 = load double, double* %18
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), double %119)
%121 = load double, double* %18
%122 = load double, double* %22
%123 = fdiv double %121, %122
store double %123, double* %18
%124 = load double, double* %18
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %124)
%126 = load double, double* %12
%127 = load double, double* %24
%128 = fmul double %126, %127
%129 = load double, double* %11
%130 = load double, double* %18
%131 = fmul double %129, %130
%132 = fdiv double %128, %131
%133 = call double @sqrt(double %132)
store double %133, double* %21
%134 = load double, double* %21
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %134)
store double 0.000000e+00, double* %18
store i32 0, i32* %19
br label %136
136: ; preds = %220, %111
%137 = load i32, i32* %19
%138 = load i32, i32* %9
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %223
140: ; preds = %136
store i32 0, i32* %20
br label %141
141: ; preds = %216, %140
%142 = load i32, i32* %20
%143 = icmp slt i32 %142, 3
br i1 %143, label %144, label %219
144: ; preds = %141
%145 = load i32, i32* %20
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %146
store double 0.000000e+00, double* %147
%148 = load double**, double*** %16
%149 = load i32, i32* %19
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double*, double** %148, i64 %150
%152 = load double*, double** %151
%153 = load i32, i32* %20
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %152, i64 %154
%156 = load double, double* %155
%157 = load i32, i32* %20
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %158
%160 = load double, double* %159
%161 = fsub double %156, %160
%162 = load double, double* %21
%163 = fmul double %161, %162
%164 = load double**, double*** %16
%165 = load i32, i32* %19
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double*, double** %164, i64 %166
%168 = load double*, double** %167
%169 = load i32, i32* %20
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %168, i64 %170
store double %163, double* %171
%172 = load double**, double*** %16
%173 = load i32, i32* %19
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds double*, double** %172, i64 %174
%176 = load double*, double** %175
%177 = load i32, i32* %20
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load i32, i32* %20
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %182
%184 = load double, double* %183
%185 = fadd double %184, %180
store double %185, double* %183
%186 = load i32, i32* %20
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %187
%189 = load double, double* %188
%190 = load i32, i32* %9
%191 = sitofp i32 %190 to double
%192 = fdiv double %189, %191
%193 = load i32, i32* %20
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 %194
store double %192, double* %195
%196 = load double**, double*** %16
%197 = load i32, i32* %19
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds double*, double** %196, i64 %198
%200 = load double*, double** %199
%201 = load i32, i32* %20
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds double, double* %200, i64 %202
%204 = load double, double* %203
%205 = load double**, double*** %16
%206 = load i32, i32* %19
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds double*, double** %205, i64 %207
%209 = load double*, double** %208
%210 = load i32, i32* %20
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds double, double* %209, i64 %211
%213 = load double, double* %212
%214 = load double, double* %18
%215 = call double @llvm.fmuladd.f64(double %204, double %213, double %214)
store double %215, double* %18
br label %216
216: ; preds = %144
%217 = load i32, i32* %20
%218 = add nsw i32 %217, 1
store i32 %218, i32* %20
br label %141
219: ; preds = %141
br label %220
220: ; preds = %219
%221 = load i32, i32* %19
%222 = add nsw i32 %221, 1
store i32 %222, i32* %19
br label %136
223: ; preds = %136
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%225 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%226 = load double, double* %225
%227 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 1
%228 = load double, double* %227
%229 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 2
%230 = load double, double* %229
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %226, double %228, double %230)
%232 = load double, double* %18
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), double %232)
%234 = load double, double* %11
%235 = fmul double 5.000000e-01, %234
%236 = load double, double* %18
%237 = fmul double %235, %236
%238 = load double, double* %24
%239 = fdiv double %237, %238
%240 = load double*, double** %15
store double %239, double* %240
%241 = load double, double* %18
%242 = load double, double* %22
%243 = fdiv double %241, %242
store double %243, double* %18
%244 = load double, double* %11
%245 = load double, double* %18
%246 = fmul double %244, %245
%247 = load double, double* %13
%248 = load double, double* %24
%249 = fmul double %247, %248
%250 = fdiv double %246, %249
%251 = load double*, double** %14
store double %250, double* %251
%252 = load double*, double** %15
%253 = load double, double* %252
%254 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %253)
%255 = load double, double* %18
%256 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %255)
%257 = load double*, double** %14
%258 = load double, double* %257
%259 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), double %258)
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [50 x i8] c"average velocity (Ang ps^-1): %12.6f%12.6f%12.6f\0A\00"
@.str.1 = [46 x i8] c"Total velocity squared (Ang^2 ps^-2): %12.6f\0A\00"
@.str.2 = [48 x i8] c"average velocity squared (Ang^2 ps^-2): %12.6f\0A\00"
@.str.3 = [23 x i8] c"scale factor = %12.6f\0A\00"
@.str.5 = [44 x i8] c"Total Kinetic Energy (kcal mol^-1): %12.6f\0A\00"
@.str.6 = [39 x i8] c"Instantaneous Temperature (K): %12.6f\0A\00"
@str = [24 x i8] c"After velocity scaling:\00"
define void @init_velocities(i32 %0, i32 %1, double %2, double %3, double %4, double* nocapture %5, double* nocapture %6, double** nocapture %7) {
%9 = tail call i32 @srand(i32 %1)
%10 = mul nsw i32 %0, 3
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %5
%11 = icmp sgt i32 %0, 0
%12 = sitofp i32 %0 to double
br i1 %11, label %13, label %72
13: ; preds = %8
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %15
%16 = phi double [ 0.000000e+00, %13 ], [ %26, %15 ]
%17 = phi i64 [ 0, %13 ], [ %28, %15 ]
%18 = phi double [ 0.000000e+00, %13 ], [ %27, %15 ]
%19 = tail call double (...) @rand()
%20 = load i64, i64* @RAND_MAX
%21 = sitofp i64 %20 to double
%22 = fdiv double %19, %21
%23 = fadd double %22, -5.000000e-01
%24 = getelementptr inbounds double*, double** %7, i64 %17
%25 = load double*, double** %24
store double %23, double* %25
%26 = fadd double %16, %23
%27 = tail call double @llvm.fmuladd.f64(double %23, double %23, double %18)
%28 = add nuw nsw i64 %17, 1
%29 = icmp eq i64 %28, %14
br i1 %29, label %30, label %15
30: ; preds = %15
br i1 %11, label %31, label %72
31: ; preds = %30
%32 = zext i32 %0 to i64
br label %33
33: ; preds = %33, %31
%34 = phi double [ 0.000000e+00, %31 ], [ %45, %33 ]
%35 = phi i64 [ 0, %31 ], [ %47, %33 ]
%36 = phi double [ %27, %31 ], [ %46, %33 ]
%37 = tail call double (...) @rand()
%38 = load i64, i64* @RAND_MAX
%39 = sitofp i64 %38 to double
%40 = fdiv double %37, %39
%41 = fadd double %40, -5.000000e-01
%42 = getelementptr inbounds double*, double** %7, i64 %35
%43 = load double*, double** %42
%44 = getelementptr inbounds double, double* %43, i64 1
store double %41, double* %44
%45 = fadd double %34, %41
%46 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %36)
%47 = add nuw nsw i64 %35, 1
%48 = icmp eq i64 %47, %32
br i1 %48, label %49, label %33
49: ; preds = %33
%50 = insertelement <2 x double> <double poison, double 0.000000e+00>, double %45, i64 0
br i1 %11, label %51, label %72
51: ; preds = %49
%52 = zext i32 %0 to i64
%53 = insertelement <2 x double> poison, double %45, i64 0
br label %54
54: ; preds = %54, %51
%55 = phi double [ 0.000000e+00, %51 ], [ %66, %54 ]
%56 = phi i64 [ 0, %51 ], [ %68, %54 ]
%57 = phi double [ %46, %51 ], [ %67, %54 ]
%58 = tail call double (...) @rand()
%59 = load i64, i64* @RAND_MAX
%60 = sitofp i64 %59 to double
%61 = fdiv double %58, %60
%62 = fadd double %61, -5.000000e-01
%63 = getelementptr inbounds double*, double** %7, i64 %56
%64 = load double*, double** %63
%65 = getelementptr inbounds double, double* %64, i64 2
store double %62, double* %65
%66 = fadd double %55, %62
%67 = tail call double @llvm.fmuladd.f64(double %62, double %62, double %57)
%68 = add nuw nsw i64 %56, 1
%69 = icmp eq i64 %68, %52
br i1 %69, label %70, label %54
70: ; preds = %54
%71 = insertelement <2 x double> %53, double %66, i64 1
br label %72
72: ; preds = %8, %70, %30, %49
%73 = phi double [ %26, %49 ], [ %26, %30 ], [ %26, %70 ], [ 0.000000e+00, %8 ]
%74 = phi double [ %46, %49 ], [ %27, %30 ], [ %67, %70 ], [ 0.000000e+00, %8 ]
%75 = phi <2 x double> [ %50, %49 ], [ zeroinitializer, %30 ], [ %71, %70 ], [ zeroinitializer, %8 ]
%76 = fdiv double %73, %12
%77 = insertelement <2 x double> poison, double %12, i64 0
%78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
%79 = fdiv <2 x double> %75, %78
%80 = sitofp i32 %10 to double
%81 = extractelement <2 x double> %79, i64 0
%82 = extractelement <2 x double> %79, i64 1
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %76, double %81, double %82)
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), double %74)
%85 = fdiv double %74, %80
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %85)
%87 = fmul double %3, 4.184000e-01
%88 = fmul double %85, %2
%89 = fdiv double %87, %88
%90 = tail call double @sqrt(double %89)
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), double %90)
br i1 %11, label %92, label %120
92: ; preds = %72
%93 = zext i32 %0 to i64
%94 = insertelement <2 x double> poison, double %90, i64 0
%95 = shufflevector <2 x double> %94, <2 x double> poison, <2 x i32> zeroinitializer
br label %96
96: ; preds = %92, %96
%97 = phi i64 [ 0, %92 ], [ %113, %96 ]
%98 = phi double [ 0.000000e+00, %92 ], [ %112, %96 ]
%99 = getelementptr inbounds double*, double** %7, i64 %97
%100 = load double*, double** %99
%101 = load double, double* %100
%102 = fmul double %90, %101
store double %102, double* %100
%103 = tail call double @llvm.fmuladd.f64(double %102, double %102, double %98)
%104 = getelementptr inbounds double, double* %100, i64 1
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = fmul <2 x double> %95, %106
%108 = extractelement <2 x double> %107, i64 0
%109 = tail call double @llvm.fmuladd.f64(double %108, double %108, double %103)
%110 = bitcast double* %104 to <2 x double>*
store <2 x double> %107, <2 x double>* %110
%111 = extractelement <2 x double> %107, i64 1
%112 = tail call double @llvm.fmuladd.f64(double %111, double %111, double %109)
%113 = add nuw nsw i64 %97, 1
%114 = icmp eq i64 %113, %93
br i1 %114, label %115, label %96
115: ; preds = %96
%116 = fadd <2 x double> %107, zeroinitializer
%117 = fdiv <2 x double> %116, %78
%118 = fadd double %102, 0.000000e+00
%119 = fdiv double %118, %12
br label %120
120: ; preds = %115, %72
%121 = phi double [ %119, %115 ], [ %76, %72 ]
%122 = phi double [ %112, %115 ], [ 0.000000e+00, %72 ]
%123 = phi <2 x double> [ %117, %115 ], [ %79, %72 ]
%124 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%125 = extractelement <2 x double> %123, i64 0
%126 = extractelement <2 x double> %123, i64 1
%127 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %121, double %125, double %126)
%128 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), double %122)
%129 = fmul double %2, 5.000000e-01
%130 = fmul double %129, %122
%131 = fdiv double %130, 4.184000e-01
store double %131, double* %6
%132 = fdiv double %122, %80
%133 = fmul double %132, %2
%134 = fmul double %4, 4.184000e-01
%135 = fdiv double %133, %134
store double %135, double* %5
%136 = load double, double* %6
%137 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %136)
%138 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %132)
%139 = load double, double* %5
%140 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), double %139)
ret void
}