#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 */
double exp(double const);
void getCollisionalTransitions(const int levels, double *F, double **DFDX,
                               const int transitions, const double *weights,
                               const int *lower, const int *upper,
                               const double *energy, const double *CulArr,
                               const double T) {
  double lw, uw;
  int li, ui;
  int i;
  double Cul, Clu;
  for (i = 1; i <= transitions; i++) {
    li = lower[i];
    lw = weights[li];
    ui = upper[i];
    uw = weights[ui];
    Cul = CulArr[i];
    Clu = (uw / lw) * Cul * exp(-(energy[ui] - energy[li]) / T);
    DFDX[li][li] -= Clu;
    DFDX[li][ui] += Cul;
    DFDX[ui][li] += Clu;
    DFDX[ui][ui] -= Cul;
  }
}


x86 assembly (clang, -O0):
<getCollisionalTransitions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1296 <getCollisionalTransitions+0x186>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    0x20(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    0x18(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x38(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x60(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1146 <getCollisionalTransitions+0x36>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCollisionalTransitions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x8(%rsp)
test   %ecx,%ecx
jle    1216 <getCollisionalTransitions+0x106>
movapd %xmm0,%xmm1
mov    %r9,%r15
mov    %r8,%r12
mov    %rdx,%rbx
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r13d
movsd  %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq (%r15,%r13,4),%rbp
mov    0x60(%rsp),%rax
movslq (%rax,%r13,4),%r14
movsd  (%r12,%r14,8),%xmm2
mov    0x70(%rsp),%rax
movsd  (%rax,%r13,8),%xmm0
movsd  %xmm0,0x20(%rsp)
divsd  (%r12,%rbp,8),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
mov    0x68(%rsp),%rax
movsd  (%rax,%r14,8),%xmm0
subsd  (%rax,%rbp,8),%xmm0
xorpd  0xe54(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  0x18(%rsp),%xmm0
mov    (%rbx,%rbp,8),%rax
movsd  (%rax,%rbp,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rbp,8)
movsd  (%rax,%r14,8),%xmm1
movsd  0x20(%rsp),%xmm2
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rax,%r14,8)
movsd  0x10(%rsp),%xmm1
mov    (%rbx,%r14,8),%rax
addsd  (%rax,%rbp,8),%xmm0
movsd  %xmm0,(%rax,%rbp,8)
movsd  (%rax,%r14,8),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%r13
cmp    %r13,0x8(%rsp)
jne    1160 <getCollisionalTransitions+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @getCollisionalTransitions(i32 %0, double* %1, double** %2, i32 %3, double* %4, i32* %5, i32* %6, double* %7, double* %8, double %9) {
%11 = alloca i32
%12 = alloca double*
%13 = alloca double**
%14 = alloca i32
%15 = alloca double*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca double
%27 = alloca double
store i32 %0, i32* %11
store double* %1, double** %12
store double** %2, double*** %13
store i32 %3, i32* %14
store double* %4, double** %15
store i32* %5, i32** %16
store i32* %6, i32** %17
store double* %7, double** %18
store double* %8, double** %19
store double %9, double* %20
store i32 1, i32* %25
br label %28
28: ; preds = %123, %10
%29 = load i32, i32* %25
%30 = load i32, i32* %14
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %126
32: ; preds = %28
%33 = load i32*, i32** %16
%34 = load i32, i32* %25
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
store i32 %37, i32* %23
%38 = load double*, double** %15
%39 = load i32, i32* %23
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
store double %42, double* %21
%43 = load i32*, i32** %17
%44 = load i32, i32* %25
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
store i32 %47, i32* %24
%48 = load double*, double** %15
%49 = load i32, i32* %24
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
store double %52, double* %22
%53 = load double*, double** %19
%54 = load i32, i32* %25
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
store double %57, double* %26
%58 = load double, double* %22
%59 = load double, double* %21
%60 = fdiv double %58, %59
%61 = load double, double* %26
%62 = fmul double %60, %61
%63 = load double*, double** %18
%64 = load i32, i32* %24
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = load double*, double** %18
%69 = load i32, i32* %23
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fsub double %67, %72
%74 = fneg double %73
%75 = load double, double* %20
%76 = fdiv double %74, %75
%77 = call double @exp(double %76)
%78 = fmul double %62, %77
store double %78, double* %27
%79 = load double, double* %27
%80 = load double**, double*** %13
%81 = load i32, i32* %23
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double*, double** %80, i64 %82
%84 = load double*, double** %83
%85 = load i32, i32* %23
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = fsub double %88, %79
store double %89, double* %87
%90 = load double, double* %26
%91 = load double**, double*** %13
%92 = load i32, i32* %23
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double*, double** %91, i64 %93
%95 = load double*, double** %94
%96 = load i32, i32* %24
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %95, i64 %97
%99 = load double, double* %98
%100 = fadd double %99, %90
store double %100, double* %98
%101 = load double, double* %27
%102 = load double**, double*** %13
%103 = load i32, i32* %24
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double*, double** %102, i64 %104
%106 = load double*, double** %105
%107 = load i32, i32* %23
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
%110 = load double, double* %109
%111 = fadd double %110, %101
store double %111, double* %109
%112 = load double, double* %26
%113 = load double**, double*** %13
%114 = load i32, i32* %24
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds double*, double** %113, i64 %115
%117 = load double*, double** %116
%118 = load i32, i32* %24
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = fsub double %121, %112
store double %122, double* %120
br label %123
123: ; preds = %32
%124 = load i32, i32* %25
%125 = add nsw i32 %124, 1
store i32 %125, i32* %25
br label %28
126: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @getCollisionalTransitions(i32 %0, double* nocapture readnone %1, double** nocapture %2, i32 %3, double* nocapture %4, i32* nocapture %5, i32* nocapture %6, double* nocapture %7, double* nocapture %8, double %9) {
%11 = icmp slt i32 %3, 1
br i1 %11, label %58, label %12
12: ; preds = %10
%13 = add nuw i32 %3, 1
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 1, %12 ], [ %56, %15 ]
%17 = getelementptr inbounds i32, i32* %5, i64 %16
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %4, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds i32, i32* %6, i64 %16
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %4, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %8, i64 %16
%28 = load double, double* %27
%29 = fdiv double %26, %21
%30 = fmul double %29, %28
%31 = getelementptr inbounds double, double* %7, i64 %24
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %7, i64 %19
%34 = load double, double* %33
%35 = fsub double %32, %34
%36 = fneg double %35
%37 = fdiv double %36, %9
%38 = tail call double @exp(double %37)
%39 = fmul double %30, %38
%40 = getelementptr inbounds double*, double** %2, i64 %19
%41 = load double*, double** %40
%42 = getelementptr inbounds double, double* %41, i64 %19
%43 = load double, double* %42
%44 = fsub double %43, %39
store double %44, double* %42
%45 = getelementptr inbounds double, double* %41, i64 %24
%46 = load double, double* %45
%47 = fadd double %28, %46
store double %47, double* %45
%48 = getelementptr inbounds double*, double** %2, i64 %24
%49 = load double*, double** %48
%50 = getelementptr inbounds double, double* %49, i64 %19
%51 = load double, double* %50
%52 = fadd double %39, %51
store double %52, double* %50
%53 = getelementptr inbounds double, double* %49, i64 %24
%54 = load double, double* %53
%55 = fsub double %54, %28
store double %55, double* %53
%56 = add nuw nsw i64 %16, 1
%57 = icmp eq i64 %56, %14
br i1 %57, label %58, label %15
58: ; preds = %15, %10
ret void
}