void log_weights(double *El, double *gl, double *wl, int N, double T) {
  int i;
  double beta = 1 / T;
  for (i = 0; i < N; ++i) {
    wl[i] = gl[i] - beta * El[i];
  }
}


x86 assembly (clang, -O0):
<log_weights>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  0xee0(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1196 <log_weights+0x96>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1131 <log_weights+0x31>
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_weights>:
test   %ecx,%ecx
jle    12af <log_weights+0x1af>
movsd  0xef0(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    1187 <log_weights+0x87>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r8b
je     1141 <log_weights+0x41>
movsd  (%rdi,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
or     $0x1,%rcx
add    %r8,%rax
je     12af <log_weights+0x1af>
nopw   0x0(%rax,%rax,1)
movsd  (%rdi,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
movsd  0x8(%rdi,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x8(%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1150 <log_weights+0x50>
jmp    12af <log_weights+0x1af>
lea    (%rdx,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rdx,%rax
seta   %r10b
lea    (%rdi,%r8,8),%rax
cmp    %rsi,%rcx
seta   %r11b
cmp    %rdx,%rax
seta   %al
cmp    %rdi,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    111e <log_weights+0x1e>
and    %r9b,%al
jne    111e <log_weights+0x1e>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12b0 <log_weights+0x1b0>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdi,%rax,8),%xmm4
movupd 0x10(%rdi,%rax,8),%xmm5
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm0,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdx,%rax,8)
movupd %xmm5,0x10(%rdx,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm2
movupd 0x30(%rsi,%rax,8),%xmm3
movupd 0x20(%rdi,%rax,8),%xmm4
movupd 0x30(%rdi,%rax,8),%xmm5
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm0,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,0x20(%rdx,%rax,8)
movupd %xmm5,0x30(%rdx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1200 <log_weights+0x100>
test   $0x1,%r9b
je     12a6 <log_weights+0x1a6>
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdi,%rax,8),%xmm4
movupd 0x10(%rdi,%rax,8),%xmm5
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm0,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdx,%rax,8)
movupd %xmm5,0x10(%rdx,%rax,8)
cmp    %r8,%rcx
jne    111e <log_weights+0x1e>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1275 <log_weights+0x175>
jmp    12a6 <log_weights+0x1a6>

LLVM IR (-O0):
define void @log_weights(double* %0, double* %1, double* %2, i32 %3, double %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store double %4, double* %10
%13 = load double, double* %10
%14 = fdiv double 1.000000e+00, %13
store double %14, double* %12
store i32 0, i32* %11
br label %15
15: ; preds = %37, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %9
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = load double*, double** %7
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double, double* %12
%26 = load double*, double** %6
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = fneg double %25
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double %24)
%33 = load double*, double** %8
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
br label %37
37: ; preds = %19
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %15
40: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @log_weights(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, i32 %3, double %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %136
7: ; preds = %5
%8 = fdiv double -1.000000e+00, %4
%9 = zext i32 %3 to i64
%10 = icmp ult i32 %3, 4
br i1 %10, label %102, label %11
11: ; preds = %7
%12 = getelementptr double, double* %2, i64 %9
%13 = getelementptr double, double* %1, i64 %9
%14 = getelementptr double, double* %0, i64 %9
%15 = icmp ugt double* %13, %2
%16 = icmp ugt double* %12, %1
%17 = and i1 %15, %16
%18 = icmp ugt double* %14, %2
%19 = icmp ugt double* %12, %0
%20 = and i1 %18, %19
%21 = or i1 %17, %20
br i1 %21, label %102, label %22
22: ; preds = %11
%23 = and i64 %9, 4294967292
%24 = insertelement <2 x double> poison, double %8, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = insertelement <2 x double> poison, double %8, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = add nsw i64 %23, -4
%29 = lshr exact i64 %28, 2
%30 = add nuw nsw i64 %29, 1
%31 = and i64 %30, 1
%32 = icmp eq i64 %28, 0
br i1 %32, label %78, label %33
33: ; preds = %22
%34 = and i64 %30, 9223372036854775806
br label %35
35: ; preds = %35, %33
%36 = phi i64 [ 0, %33 ], [ %75, %35 ]
%37 = phi i64 [ 0, %33 ], [ %76, %35 ]
%38 = getelementptr inbounds double, double* %1, i64 %36
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %0, i64 %36
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %46, <2 x double> %40)
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %49, <2 x double> %43)
%52 = getelementptr inbounds double, double* %2, i64 %36
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %50, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %51, <2 x double>* %55
%56 = or i64 %36, 4
%57 = getelementptr inbounds double, double* %1, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %57, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %0, i64 %56
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %65, <2 x double> %59)
%70 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %68, <2 x double> %62)
%71 = getelementptr inbounds double, double* %2, i64 %56
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %69, <2 x double>* %72
%73 = getelementptr inbounds double, double* %71, i64 2
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %70, <2 x double>* %74
%75 = add nuw i64 %36, 8
%76 = add i64 %37, 2
%77 = icmp eq i64 %76, %34
br i1 %77, label %78, label %35
78: ; preds = %35, %22
%79 = phi i64 [ 0, %22 ], [ %75, %35 ]
%80 = icmp eq i64 %31, 0
br i1 %80, label %100, label %81
81: ; preds = %78
%82 = getelementptr inbounds double, double* %1, i64 %79
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %82, i64 2
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %0, i64 %79
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %88, i64 2
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %90, <2 x double> %84)
%95 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %93, <2 x double> %87)
%96 = getelementptr inbounds double, double* %2, i64 %79
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %94, <2 x double>* %97
%98 = getelementptr inbounds double, double* %96, i64 2
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %95, <2 x double>* %99
br label %100
100: ; preds = %78, %81
%101 = icmp eq i64 %23, %9
br i1 %101, label %136, label %102
102: ; preds = %11, %7, %100
%103 = phi i64 [ 0, %11 ], [ 0, %7 ], [ %23, %100 ]
%104 = xor i64 %103, -1
%105 = and i64 %9, 1
%106 = icmp eq i64 %105, 0
br i1 %106, label %115, label %107
107: ; preds = %102
%108 = getelementptr inbounds double, double* %1, i64 %103
%109 = load double, double* %108
%110 = getelementptr inbounds double, double* %0, i64 %103
%111 = load double, double* %110
%112 = tail call double @llvm.fmuladd.f64(double %8, double %111, double %109)
%113 = getelementptr inbounds double, double* %2, i64 %103
store double %112, double* %113
%114 = or i64 %103, 1
br label %115
115: ; preds = %107, %102
%116 = phi i64 [ %103, %102 ], [ %114, %107 ]
%117 = sub nsw i64 0, %9
%118 = icmp eq i64 %104, %117
br i1 %118, label %136, label %119
119: ; preds = %115, %119
%120 = phi i64 [ %134, %119 ], [ %116, %115 ]
%121 = getelementptr inbounds double, double* %1, i64 %120
%122 = load double, double* %121
%123 = getelementptr inbounds double, double* %0, i64 %120
%124 = load double, double* %123
%125 = tail call double @llvm.fmuladd.f64(double %8, double %124, double %122)
%126 = getelementptr inbounds double, double* %2, i64 %120
store double %125, double* %126
%127 = add nuw nsw i64 %120, 1
%128 = getelementptr inbounds double, double* %1, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %0, i64 %127
%131 = load double, double* %130
%132 = tail call double @llvm.fmuladd.f64(double %8, double %131, double %129)
%133 = getelementptr inbounds double, double* %2, i64 %127
store double %132, double* %133
%134 = add nuw nsw i64 %120, 2
%135 = icmp eq i64 %134, %9
br i1 %135, label %136, label %119
136: ; preds = %115, %119, %100, %5
ret void
}