#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 */
typedef int int16_t;

/* Variables and functions */
double exp(double);
void weightExpVec(const int16_t ns, const int16_t nc, const int16_t dims,
                  const int16_t *restrict tcounts,
                  const int16_t *restrict fcounts,
                  const double *restrict weights, double *restrict tprob,
                  double *restrict tvec, double *restrict fprob,
                  double *restrict fvec) {
  for (int t = 0; t < ns * nc; ++t) {
    double lp = 0;
    for (int i = 0; i < dims; ++i)
      lp += tcounts[t * dims + i] * weights[i];
    double p = exp(-lp);
    tprob[t] = p;
    for (int i = 0; i < dims; ++i)
      tvec[t * dims + i] = p * tcounts[t * dims + i];
  }
  for (int t = 0; t < ns; ++t) {
    double lp = 0;
    for (int i = 0; i < dims; ++i)
      lp += fcounts[t * dims + i] * weights[i];
    double p = exp(-lp);
    fprob[t] = p;
    for (int i = 0; i < dims; ++i)
      fvec[t * dims + i] = p * fcounts[t * dims + i];
  }
}


x86 assembly (clang, -O0):
<weightExpVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1255 <weightExpVec+0x145>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <weightExpVec+0xa4>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1165 <weightExpVec+0x55>
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1242 <weightExpVec+0x132>
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm1
mulsd  %xmm1,%xmm0
mov    0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11f3 <weightExpVec+0xe3>
jmp    1247 <weightExpVec+0x137>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1144 <weightExpVec+0x34>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1367 <weightExpVec+0x257>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c6 <weightExpVec+0x1b6>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x5c(%rbp),%ecx
movslq %ecx,%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x5c(%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    1277 <weightExpVec+0x167>
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mov    0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1354 <weightExpVec+0x244>
movsd  -0x68(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm1
mulsd  %xmm1,%xmm0
mov    0x28(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1305 <weightExpVec+0x1f5>
jmp    1359 <weightExpVec+0x249>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    125c <weightExpVec+0x14c>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weightExpVec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%rbx
mov    %r8,0x28(%rsp)
mov    %rcx,(%rsp)
movabs $0x7ffffffffffffffe,%rax
ff ff 7f
mov    %rax,0x68(%rsp)
mov    %edi,0x64(%rsp)
imul   %edi,%esi
movslq %edx,%rax
mov    %rax,0x10(%rsp)
mov    %edx,%edi
test   %esi,%esi
mov    %edx,0xc(%rsp)
mov    %rdi,0x70(%rsp)
jle    13d0 <weightExpVec+0x2c0>
mov    0xc8(%rsp),%r13
mov    %esi,%eax
mov    %rax,0x50(%rsp)
mov    %edi,%eax
and    $0xfffffffc,%eax
mov    %rax,0x20(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x18(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %edi,%esi
and    $0xfffffffe,%esi
mov    %rcx,%rax
mov    %rcx,0x80(%rsp)
movabs $0x7ffffffffffffffe,%rax
ff ff 7f
and    %rax,%rcx
mov    %rcx,0x78(%rsp)
mov    (%rsp),%r12
lea    0x4(%r12),%r15
mov    0x10(%rsp),%rax
lea    0x0(,%rax,4),%rcx
mov    %rcx,0x48(%rsp)
lea    0x30(%r13),%rbp
lea    0x0(,%rax,8),%rax
mov    %rax,0x40(%rsp)
lea    0x18(%r12),%r14
xor    %r8d,%r8d
mov    %rsi,0x30(%rsp)
jmp    122e <weightExpVec+0x11e>
nopl   0x0(%rax,%rax,1)
movabs $0x3ff0000000000000,%rax
mov    0xc0(%rsp),%rcx
mov    %rax,(%rcx,%r8,8)
add    $0x1,%r8
mov    0x48(%rsp),%rax
add    %rax,%r15
mov    0x40(%rsp),%rcx
add    %rcx,%rbp
add    %rax,%r14
add    %rax,%r12
add    %rcx,%r13
cmp    0x50(%rsp),%r8
je     13d0 <weightExpVec+0x2c0>
test   %edx,%edx
jle    11f0 <weightExpVec+0xe0>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cmp    $0x1,%edx
je     126f <weightExpVec+0x15f>
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sdl -0x4(%r15,%rax,4),%xmm1
mulsd  (%rbx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl (%r15,%rax,4),%xmm0
mulsd  0x8(%rbx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
add    $0x2,%rax
cmp    %rax,%rsi
jne    1240 <weightExpVec+0x130>
mov    %r8,%rsi
imul   0x10(%rsp),%rsi
test   $0x1,%dil
mov    %r8,0x58(%rsp)
je     129c <weightExpVec+0x18c>
lea    (%rax,%rsi,1),%rcx
mov    (%rsp),%rdx
xorps  %xmm1,%xmm1
cvtsi2sdl (%rdx,%rcx,4),%xmm1
mulsd  (%rbx,%rax,8),%xmm1
addsd  %xmm1,%xmm0
mov    %rsi,0x38(%rsp)
xorpd  0xd57(%rip),%xmm0
call   1030 <exp@plt>
mov    0xc0(%rsp),%rax
mov    0x58(%rsp),%r8
movsd  %xmm0,(%rax,%r8,8)
mov    0xc(%rsp),%edx
test   %edx,%edx
mov    0x70(%rsp),%rdi
mov    0x30(%rsp),%rsi
jle    1206 <weightExpVec+0xf6>
cmp    $0x4,%edx
jae    12e3 <weightExpVec+0x1d3>
xor    %eax,%eax
jmp    13a0 <weightExpVec+0x290>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x18(%rsp)
je     13c2 <weightExpVec+0x2b2>
mov    0x78(%rsp),%rcx
xor    %eax,%eax
xchg   %ax,%ax
cvtdq2pd -0x18(%r14,%rax,4),%xmm2
cvtdq2pd -0x10(%r14,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
cvtdq2pd -0x8(%r14,%rax,4),%xmm4
movupd %xmm2,-0x30(%rbp,%rax,8)
cvtdq2pd (%r14,%rax,4),%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x20(%rbp,%rax,8)
mulpd  %xmm1,%xmm4
mulpd  %xmm1,%xmm2
movupd %xmm4,-0x10(%rbp,%rax,8)
movupd %xmm2,0x0(%rbp,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    1300 <weightExpVec+0x1f0>
testb  $0x1,0x80(%rsp)
01
je     1386 <weightExpVec+0x276>
add    0x38(%rsp),%rax
mov    (%rsp),%rcx
cvtdq2pd (%rcx,%rax,4),%xmm2
cvtdq2pd 0x8(%rcx,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
mov    0xc8(%rsp),%rcx
movupd %xmm2,(%rcx,%rax,8)
movupd %xmm3,0x10(%rcx,%rax,8)
mov    0x20(%rsp),%rcx
mov    %rcx,%rax
cmp    %rdi,%rcx
je     1206 <weightExpVec+0xf6>
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sdl (%r12,%rax,4),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdi
jne    13a0 <weightExpVec+0x290>
jmp    1206 <weightExpVec+0xf6>
xor    %eax,%eax
testb  $0x1,0x80(%rsp)
01
jne    1357 <weightExpVec+0x247>
jmp    1386 <weightExpVec+0x276>
mov    0x64(%rsp),%eax
test   %eax,%eax
jle    163d <weightExpVec+0x52d>
mov    0xd8(%rsp),%r13
mov    %eax,%eax
mov    %rax,0x50(%rsp)
mov    %edi,%eax
and    $0xfffffffc,%eax
mov    %rax,(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x20(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %edi,%esi
and    $0xfffffffe,%esi
mov    %rax,%rcx
mov    %rax,0x18(%rsp)
and    %rax,0x68(%rsp)
mov    0x28(%rsp),%r15
lea    0x4(%r15),%rbp
mov    0x10(%rsp),%rax
lea    0x0(,%rax,4),%rcx
mov    %rcx,0x48(%rsp)
lea    0x30(%r13),%r14
lea    0x0(,%rax,8),%rax
mov    %rax,0x40(%rsp)
lea    0x18(%r15),%r12
xor    %r8d,%r8d
mov    %rsi,0x30(%rsp)
jmp    149e <weightExpVec+0x38e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movabs $0x3ff0000000000000,%rax
mov    0xd0(%rsp),%rcx
mov    %rax,(%rcx,%r8,8)
add    $0x1,%r8
mov    0x48(%rsp),%rax
add    %rax,%rbp
mov    0x40(%rsp),%rcx
add    %rcx,%r14
add    %rax,%r12
add    %rax,%r15
add    %rcx,%r13
cmp    0x50(%rsp),%r8
je     163d <weightExpVec+0x52d>
test   %edx,%edx
jle    1460 <weightExpVec+0x350>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cmp    $0x1,%edx
je     14de <weightExpVec+0x3ce>
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sdl -0x4(%rbp,%rax,4),%xmm1
mulsd  (%rbx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%rbp,%rax,4),%xmm0
mulsd  0x8(%rbx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
add    $0x2,%rax
cmp    %rax,%rsi
jne    14b0 <weightExpVec+0x3a0>
mov    %r8,%rsi
imul   0x10(%rsp),%rsi
test   $0x1,%dil
mov    %r8,0x58(%rsp)
je     150c <weightExpVec+0x3fc>
lea    (%rax,%rsi,1),%rcx
mov    0x28(%rsp),%rdx
xorps  %xmm1,%xmm1
cvtsi2sdl (%rdx,%rcx,4),%xmm1
mulsd  (%rbx,%rax,8),%xmm1
addsd  %xmm1,%xmm0
mov    %rsi,0x38(%rsp)
xorpd  0xae7(%rip),%xmm0
call   1030 <exp@plt>
mov    0xd0(%rsp),%rax
mov    0x58(%rsp),%r8
movsd  %xmm0,(%rax,%r8,8)
mov    0xc(%rsp),%edx
test   %edx,%edx
mov    0x70(%rsp),%rdi
mov    0x30(%rsp),%rsi
jle    1476 <weightExpVec+0x366>
cmp    $0x4,%edx
jae    1553 <weightExpVec+0x443>
xor    %eax,%eax
jmp    1610 <weightExpVec+0x500>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x20(%rsp)
je     1632 <weightExpVec+0x522>
mov    0x68(%rsp),%rcx
xor    %eax,%eax
xchg   %ax,%ax
cvtdq2pd -0x18(%r12,%rax,4),%xmm2
cvtdq2pd -0x10(%r12,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
cvtdq2pd -0x8(%r12,%rax,4),%xmm4
movupd %xmm2,-0x30(%r14,%rax,8)
cvtdq2pd (%r12,%rax,4),%xmm2
mulpd  %xmm1,%xmm3
movupd %xmm3,-0x20(%r14,%rax,8)
mulpd  %xmm1,%xmm4
mulpd  %xmm1,%xmm2
movupd %xmm4,-0x10(%r14,%rax,8)
movupd %xmm2,(%r14,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rcx
jne    1570 <weightExpVec+0x460>
testb  $0x1,0x18(%rsp)
je     15f7 <weightExpVec+0x4e7>
add    0x38(%rsp),%rax
mov    0x28(%rsp),%rcx
cvtdq2pd (%rcx,%rax,4),%xmm2
cvtdq2pd 0x8(%rcx,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
mulpd  %xmm1,%xmm3
mov    0xd8(%rsp),%rcx
movupd %xmm2,(%rcx,%rax,8)
movupd %xmm3,0x10(%rcx,%rax,8)
mov    (%rsp),%rcx
mov    %rcx,%rax
cmp    %rdi,%rcx
je     1476 <weightExpVec+0x366>
nopw   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sdl (%r15,%rax,4),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdi
jne    1610 <weightExpVec+0x500>
jmp    1476 <weightExpVec+0x366>
xor    %eax,%eax
testb  $0x1,0x18(%rsp)
jne    15c7 <weightExpVec+0x4b7>
jmp    15f7 <weightExpVec+0x4e7>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @weightExpVec(i32 %0, i32 %1, i32 %2, i32* noalias nocapture %3, i32* noalias nocapture %4, double* noalias nocapture %5, double* noalias nocapture writeonly %6, double* noalias nocapture writeonly %7, double* noalias nocapture writeonly %8, double* noalias nocapture writeonly %9) {
%11 = mul i32 %1, %0
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %10
%14 = icmp sgt i32 %2, 0
%15 = sext i32 %2 to i64
%16 = zext i32 %11 to i64
%17 = zext i32 %2 to i64
%18 = zext i32 %2 to i64
%19 = and i64 %17, 4294967292
%20 = add nsw i64 %19, -4
%21 = lshr exact i64 %20, 2
%22 = add nuw nsw i64 %21, 1
%23 = and i64 %17, 1
%24 = icmp eq i32 %2, 1
%25 = and i64 %17, 4294967294
%26 = icmp eq i64 %23, 0
%27 = icmp ult i32 %2, 4
%28 = and i64 %17, 4294967292
%29 = and i64 %22, 1
%30 = icmp eq i64 %20, 0
%31 = and i64 %22, 9223372036854775806
%32 = icmp eq i64 %29, 0
%33 = icmp eq i64 %28, %17
br label %34
34: ; preds = %13, %167
%35 = phi i64 [ 0, %13 ], [ %168, %167 ]
br i1 %14, label %38, label %36
36: ; preds = %34
%37 = getelementptr inbounds double, double* %6, i64 %35
store double 1.000000e+00, double* %37
br label %167
38: ; preds = %34
%39 = mul nsw i64 %35, %15
br i1 %24, label %63, label %145
40: ; preds = %167, %10
%41 = icmp sgt i32 %0, 0
br i1 %41, label %42, label %186
42: ; preds = %40
%43 = icmp sgt i32 %2, 0
%44 = sext i32 %2 to i64
%45 = zext i32 %0 to i64
%46 = zext i32 %2 to i64
%47 = zext i32 %2 to i64
%48 = and i64 %46, 4294967292
%49 = add nsw i64 %48, -4
%50 = lshr exact i64 %49, 2
%51 = add nuw nsw i64 %50, 1
%52 = and i64 %46, 1
%53 = icmp eq i32 %2, 1
%54 = and i64 %46, 4294967294
%55 = icmp eq i64 %52, 0
%56 = icmp ult i32 %2, 4
%57 = and i64 %46, 4294967292
%58 = and i64 %51, 1
%59 = icmp eq i64 %49, 0
%60 = and i64 %51, 9223372036854775806
%61 = icmp eq i64 %58, 0
%62 = icmp eq i64 %57, %46
br label %180
63: ; preds = %145, %38
%64 = phi double [ undef, %38 ], [ %163, %145 ]
%65 = phi i64 [ 0, %38 ], [ %164, %145 ]
%66 = phi double [ 0.000000e+00, %38 ], [ %163, %145 ]
br i1 %26, label %75, label %67
67: ; preds = %63
%68 = add nsw i64 %65, %39
%69 = getelementptr inbounds i32, i32* %3, i64 %68
%70 = load i32, i32* %69
%71 = sitofp i32 %70 to double
%72 = getelementptr inbounds double, double* %5, i64 %65
%73 = load double, double* %72
%74 = tail call double @llvm.fmuladd.f64(double %71, double %73, double %66)
br label %75
75: ; preds = %63, %67
%76 = phi double [ %64, %63 ], [ %74, %67 ]
%77 = fneg double %76
%78 = tail call double @exp(double %77)
%79 = getelementptr inbounds double, double* %6, i64 %35
store double %78, double* %79
br i1 %14, label %80, label %167
80: ; preds = %75
%81 = mul nsw i64 %35, %15
br i1 %27, label %143, label %82
82: ; preds = %80
%83 = insertelement <2 x double> poison, double %78, i64 0
%84 = shufflevector <2 x double> %83, <2 x double> poison, <2 x i32> zeroinitializer
%85 = insertelement <2 x double> poison, double %78, i64 0
%86 = shufflevector <2 x double> %85, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %30, label %124, label %87
87: ; preds = %82, %87
%88 = phi i64 [ %121, %87 ], [ 0, %82 ]
%89 = phi i64 [ %122, %87 ], [ 0, %82 ]
%90 = add nsw i64 %88, %81
%91 = getelementptr inbounds i32, i32* %3, i64 %90
%92 = bitcast i32* %91 to <2 x i32>*
%93 = load <2 x i32>, <2 x i32>* %92
%94 = getelementptr inbounds i32, i32* %91, i64 2
%95 = bitcast i32* %94 to <2 x i32>*
%96 = load <2 x i32>, <2 x i32>* %95
%97 = sitofp <2 x i32> %93 to <2 x double>
%98 = sitofp <2 x i32> %96 to <2 x double>
%99 = fmul <2 x double> %84, %97
%100 = fmul <2 x double> %86, %98
%101 = getelementptr inbounds double, double* %7, i64 %90
%102 = bitcast double* %101 to <2 x double>*
store <2 x double> %99, <2 x double>* %102
%103 = getelementptr inbounds double, double* %101, i64 2
%104 = bitcast double* %103 to <2 x double>*
store <2 x double> %100, <2 x double>* %104
%105 = or i64 %88, 4
%106 = add nsw i64 %105, %81
%107 = getelementptr inbounds i32, i32* %3, i64 %106
%108 = bitcast i32* %107 to <2 x i32>*
%109 = load <2 x i32>, <2 x i32>* %108
%110 = getelementptr inbounds i32, i32* %107, i64 2
%111 = bitcast i32* %110 to <2 x i32>*
%112 = load <2 x i32>, <2 x i32>* %111
%113 = sitofp <2 x i32> %109 to <2 x double>
%114 = sitofp <2 x i32> %112 to <2 x double>
%115 = fmul <2 x double> %84, %113
%116 = fmul <2 x double> %86, %114
%117 = getelementptr inbounds double, double* %7, i64 %106
%118 = bitcast double* %117 to <2 x double>*
store <2 x double> %115, <2 x double>* %118
%119 = getelementptr inbounds double, double* %117, i64 2
%120 = bitcast double* %119 to <2 x double>*
store <2 x double> %116, <2 x double>* %120
%121 = add nuw i64 %88, 8
%122 = add i64 %89, 2
%123 = icmp eq i64 %122, %31
br i1 %123, label %124, label %87
124: ; preds = %87, %82
%125 = phi i64 [ 0, %82 ], [ %121, %87 ]
br i1 %32, label %142, label %126
126: ; preds = %124
%127 = add nsw i64 %125, %81
%128 = getelementptr inbounds i32, i32* %3, i64 %127
%129 = bitcast i32* %128 to <2 x i32>*
%130 = load <2 x i32>, <2 x i32>* %129
%131 = getelementptr inbounds i32, i32* %128, i64 2
%132 = bitcast i32* %131 to <2 x i32>*
%133 = load <2 x i32>, <2 x i32>* %132
%134 = sitofp <2 x i32> %130 to <2 x double>
%135 = sitofp <2 x i32> %133 to <2 x double>
%136 = fmul <2 x double> %84, %134
%137 = fmul <2 x double> %86, %135
%138 = getelementptr inbounds double, double* %7, i64 %127
%139 = bitcast double* %138 to <2 x double>*
store <2 x double> %136, <2 x double>* %139
%140 = getelementptr inbounds double, double* %138, i64 2
%141 = bitcast double* %140 to <2 x double>*
store <2 x double> %137, <2 x double>* %141
br label %142
142: ; preds = %124, %126
br i1 %33, label %167, label %143
143: ; preds = %80, %142
%144 = phi i64 [ 0, %80 ], [ %28, %142 ]
br label %170
145: ; preds = %38, %145
%146 = phi i64 [ %164, %145 ], [ 0, %38 ]
%147 = phi double [ %163, %145 ], [ 0.000000e+00, %38 ]
%148 = phi i64 [ %165, %145 ], [ 0, %38 ]
%149 = add nsw i64 %146, %39
%150 = getelementptr inbounds i32, i32* %3, i64 %149
%151 = load i32, i32* %150
%152 = sitofp i32 %151 to double
%153 = getelementptr inbounds double, double* %5, i64 %146
%154 = load double, double* %153
%155 = tail call double @llvm.fmuladd.f64(double %152, double %154, double %147)
%156 = or i64 %146, 1
%157 = add nsw i64 %156, %39
%158 = getelementptr inbounds i32, i32* %3, i64 %157
%159 = load i32, i32* %158
%160 = sitofp i32 %159 to double
%161 = getelementptr inbounds double, double* %5, i64 %156
%162 = load double, double* %161
%163 = tail call double @llvm.fmuladd.f64(double %160, double %162, double %155)
%164 = add nuw nsw i64 %146, 2
%165 = add i64 %148, 2
%166 = icmp eq i64 %165, %25
br i1 %166, label %63, label %145
167: ; preds = %170, %142, %36, %75
%168 = add nuw nsw i64 %35, 1
%169 = icmp eq i64 %168, %16
br i1 %169, label %40, label %34
170: ; preds = %143, %170
%171 = phi i64 [ %178, %170 ], [ %144, %143 ]
%172 = add nsw i64 %171, %81
%173 = getelementptr inbounds i32, i32* %3, i64 %172
%174 = load i32, i32* %173
%175 = sitofp i32 %174 to double
%176 = fmul double %78, %175
%177 = getelementptr inbounds double, double* %7, i64 %172
store double %176, double* %177
%178 = add nuw nsw i64 %171, 1
%179 = icmp eq i64 %178, %18
br i1 %179, label %167, label %170
180: ; preds = %42, %291
%181 = phi i64 [ 0, %42 ], [ %292, %291 ]
br i1 %43, label %184, label %182
182: ; preds = %180
%183 = getelementptr inbounds double, double* %8, i64 %181
store double 1.000000e+00, double* %183
br label %291
184: ; preds = %180
%185 = mul nsw i64 %181, %44
br i1 %53, label %187, label %269
186: ; preds = %291, %40
ret void
187: ; preds = %269, %184
%188 = phi double [ undef, %184 ], [ %287, %269 ]
%189 = phi i64 [ 0, %184 ], [ %288, %269 ]
%190 = phi double [ 0.000000e+00, %184 ], [ %287, %269 ]
br i1 %55, label %199, label %191
191: ; preds = %187
%192 = add nsw i64 %189, %185
%193 = getelementptr inbounds i32, i32* %4, i64 %192
%194 = load i32, i32* %193
%195 = sitofp i32 %194 to double
%196 = getelementptr inbounds double, double* %5, i64 %189
%197 = load double, double* %196
%198 = tail call double @llvm.fmuladd.f64(double %195, double %197, double %190)
br label %199
199: ; preds = %187, %191
%200 = phi double [ %188, %187 ], [ %198, %191 ]
%201 = fneg double %200
%202 = tail call double @exp(double %201)
%203 = getelementptr inbounds double, double* %8, i64 %181
store double %202, double* %203
br i1 %43, label %204, label %291
204: ; preds = %199
%205 = mul nsw i64 %181, %44
br i1 %56, label %267, label %206
206: ; preds = %204
%207 = insertelement <2 x double> poison, double %202, i64 0
%208 = shufflevector <2 x double> %207, <2 x double> poison, <2 x i32> zeroinitializer
%209 = insertelement <2 x double> poison, double %202, i64 0
%210 = shufflevector <2 x double> %209, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %59, label %248, label %211
211: ; preds = %206, %211
%212 = phi i64 [ %245, %211 ], [ 0, %206 ]
%213 = phi i64 [ %246, %211 ], [ 0, %206 ]
%214 = add nsw i64 %212, %205
%215 = getelementptr inbounds i32, i32* %4, i64 %214
%216 = bitcast i32* %215 to <2 x i32>*
%217 = load <2 x i32>, <2 x i32>* %216
%218 = getelementptr inbounds i32, i32* %215, i64 2
%219 = bitcast i32* %218 to <2 x i32>*
%220 = load <2 x i32>, <2 x i32>* %219
%221 = sitofp <2 x i32> %217 to <2 x double>
%222 = sitofp <2 x i32> %220 to <2 x double>
%223 = fmul <2 x double> %208, %221
%224 = fmul <2 x double> %210, %222
%225 = getelementptr inbounds double, double* %9, i64 %214
%226 = bitcast double* %225 to <2 x double>*
store <2 x double> %223, <2 x double>* %226
%227 = getelementptr inbounds double, double* %225, i64 2
%228 = bitcast double* %227 to <2 x double>*
store <2 x double> %224, <2 x double>* %228
%229 = or i64 %212, 4
%230 = add nsw i64 %229, %205
%231 = getelementptr inbounds i32, i32* %4, i64 %230
%232 = bitcast i32* %231 to <2 x i32>*
%233 = load <2 x i32>, <2 x i32>* %232
%234 = getelementptr inbounds i32, i32* %231, i64 2
%235 = bitcast i32* %234 to <2 x i32>*
%236 = load <2 x i32>, <2 x i32>* %235
%237 = sitofp <2 x i32> %233 to <2 x double>
%238 = sitofp <2 x i32> %236 to <2 x double>
%239 = fmul <2 x double> %208, %237
%240 = fmul <2 x double> %210, %238
%241 = getelementptr inbounds double, double* %9, i64 %230
%242 = bitcast double* %241 to <2 x double>*
store <2 x double> %239, <2 x double>* %242
%243 = getelementptr inbounds double, double* %241, i64 2
%244 = bitcast double* %243 to <2 x double>*
store <2 x double> %240, <2 x double>* %244
%245 = add nuw i64 %212, 8
%246 = add i64 %213, 2
%247 = icmp eq i64 %246, %60
br i1 %247, label %248, label %211
248: ; preds = %211, %206
%249 = phi i64 [ 0, %206 ], [ %245, %211 ]
br i1 %61, label %266, label %250
250: ; preds = %248
%251 = add nsw i64 %249, %205
%252 = getelementptr inbounds i32, i32* %4, i64 %251
%253 = bitcast i32* %252 to <2 x i32>*
%254 = load <2 x i32>, <2 x i32>* %253
%255 = getelementptr inbounds i32, i32* %252, i64 2
%256 = bitcast i32* %255 to <2 x i32>*
%257 = load <2 x i32>, <2 x i32>* %256
%258 = sitofp <2 x i32> %254 to <2 x double>
%259 = sitofp <2 x i32> %257 to <2 x double>
%260 = fmul <2 x double> %208, %258
%261 = fmul <2 x double> %210, %259
%262 = getelementptr inbounds double, double* %9, i64 %251
%263 = bitcast double* %262 to <2 x double>*
store <2 x double> %260, <2 x double>* %263
%264 = getelementptr inbounds double, double* %262, i64 2
%265 = bitcast double* %264 to <2 x double>*
store <2 x double> %261, <2 x double>* %265
br label %266
266: ; preds = %248, %250
br i1 %62, label %291, label %267
267: ; preds = %204, %266
%268 = phi i64 [ 0, %204 ], [ %57, %266 ]
br label %294
269: ; preds = %184, %269
%270 = phi i64 [ %288, %269 ], [ 0, %184 ]
%271 = phi double [ %287, %269 ], [ 0.000000e+00, %184 ]
%272 = phi i64 [ %289, %269 ], [ 0, %184 ]
%273 = add nsw i64 %270, %185
%274 = getelementptr inbounds i32, i32* %4, i64 %273
%275 = load i32, i32* %274
%276 = sitofp i32 %275 to double
%277 = getelementptr inbounds double, double* %5, i64 %270
%278 = load double, double* %277
%279 = tail call double @llvm.fmuladd.f64(double %276, double %278, double %271)
%280 = or i64 %270, 1
%281 = add nsw i64 %280, %185
%282 = getelementptr inbounds i32, i32* %4, i64 %281
%283 = load i32, i32* %282
%284 = sitofp i32 %283 to double
%285 = getelementptr inbounds double, double* %5, i64 %280
%286 = load double, double* %285
%287 = tail call double @llvm.fmuladd.f64(double %284, double %286, double %279)
%288 = add nuw nsw i64 %270, 2
%289 = add i64 %272, 2
%290 = icmp eq i64 %289, %54
br i1 %290, label %187, label %269
291: ; preds = %294, %266, %182, %199
%292 = add nuw nsw i64 %181, 1
%293 = icmp eq i64 %292, %45
br i1 %293, label %186, label %180
294: ; preds = %267, %294
%295 = phi i64 [ %302, %294 ], [ %268, %267 ]
%296 = add nsw i64 %295, %205
%297 = getelementptr inbounds i32, i32* %4, i64 %296
%298 = load i32, i32* %297
%299 = sitofp i32 %298 to double
%300 = fmul double %202, %299
%301 = getelementptr inbounds double, double* %9, i64 %296
store double %300, double* %301
%302 = add nuw nsw i64 %295, 1
%303 = icmp eq i64 %302, %47
br i1 %303, label %291, label %294
}