#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 pow(double, long);
void finish_lazy_updates_Katyusha(double *w, double *wold, double *ww,
                                  double *g, long *last_seen, double stepSize,
                                  double lambda, long iter, long d, double *ym,
                                  double *zm, double tau, double tau1,
                                  double tau2) {
  for (long j = 0; j < d; j++) {
    double tmp =
        stepSize * (iter - last_seen[j]) * (g[j] + lambda * (w[j] - wold[j]));
    zm[j] -= tmp;
    ym[j] -= tmp * tau;
    w[j] = zm[j] * tau + wold[j] * 0.5 + ym[j] * tau1;
    for (long k = last_seen[j]; k < iter; k++) {
      ww[j] -= tmp * tau * pow(tau2, k);
    }
  }
}


x86 assembly (clang, -O0):
<finish_lazy_updates_Katyusha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
movsd  %xmm2,-0x48(%rbp)
movsd  %xmm3,-0x50(%rbp)
movsd  %xmm4,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
cmp    0x10(%rbp),%rax
jge    1310 <finish_lazy_updates_Katyusha+0x200>
movsd  -0x30(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x60(%rbp),%rdx
sub    (%rcx,%rdx,8),%rax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm1
mov    0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mov    0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    0x20(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x48(%rbp),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  0xdbf(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0x40(%rbp),%rax
jge    12fa <finish_lazy_updates_Katyusha+0x1ea>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x70(%rbp),%rdi
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1285 <finish_lazy_updates_Katyusha+0x175>
jmp    12ff <finish_lazy_updates_Katyusha+0x1ef>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1160 <finish_lazy_updates_Katyusha+0x50>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finish_lazy_updates_Katyusha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movsd  %xmm3,0x50(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x48(%rsp)
movsd  %xmm0,0x40(%rsp)
mov    %r8,0x38(%rsp)
mov    %rcx,0x30(%rsp)
mov    %rsi,0x28(%rsp)
cmpq   $0x0,0x90(%rsp)
jle    12f1 <finish_lazy_updates_Katyusha+0x1e1>
mov    %r9,%r12
mov    %rdx,%rbx
mov    %rdi,%rbp
mov    %r9,%rax
neg    %rax
mov    %rax,0x20(%rsp)
xor    %r13d,%r13d
movsd  %xmm4,(%rsp)
jmp    1192 <finish_lazy_updates_Katyusha+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13
cmp    0x90(%rsp),%r13
je     12f1 <finish_lazy_updates_Katyusha+0x1e1>
mov    0x38(%rsp),%rax
mov    (%rax,%r13,8),%r15
mov    %r12,%rax
sub    %r15,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x0(%rbp,%r13,8),%xmm5
mov    0x28(%rsp),%rcx
subsd  (%rcx,%r13,8),%xmm5
mulsd  0x40(%rsp),%xmm0
mulsd  0x48(%rsp),%xmm5
mov    0x30(%rsp),%rax
addsd  (%rax,%r13,8),%xmm5
mulsd  %xmm0,%xmm5
mov    0xa0(%rsp),%rax
movsd  (%rax,%r13,8),%xmm0
subsd  %xmm5,%xmm0
movsd  %xmm0,(%rax,%r13,8)
mov    0x98(%rsp),%rdx
movsd  (%rdx,%r13,8),%xmm0
movapd %xmm5,%xmm1
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%r13,8)
movsd  (%rcx,%r13,8),%xmm1
mulsd  0xdee(%rip),%xmm1
movsd  (%rax,%r13,8),%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mulsd  0x50(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x0(%rbp,%r13,8)
jle    1180 <finish_lazy_updates_Katyusha+0x70>
xorpd  0xdb1(%rip),%xmm5
mulsd  0x8(%rsp),%xmm5
movapd %xmm5,0x10(%rsp)
mov    %r12d,%eax
sub    %r15d,%eax
mov    %r15,%r14
test   $0x1,%al
je     128f <finish_lazy_updates_Katyusha+0x17f>
movapd %xmm4,%xmm0
mov    %r15,%rdi
call   1030 <pow@plt>
movsd  (%rsp),%xmm4
mulsd  0x10(%rsp),%xmm0
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
lea    0x1(%r15),%r14
not    %r15
cmp    0x20(%rsp),%r15
je     1180 <finish_lazy_updates_Katyusha+0x70>
nopl   (%rax)
movapd %xmm4,%xmm0
mov    %r14,%rdi
call   1030 <pow@plt>
mulsd  0x10(%rsp),%xmm0
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
lea    0x1(%r14),%rdi
movsd  (%rsp),%xmm0
call   1030 <pow@plt>
movsd  (%rsp),%xmm4
mulsd  0x10(%rsp),%xmm0
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
add    $0x2,%r14
cmp    %r12,%r14
jne    12a0 <finish_lazy_updates_Katyusha+0x190>
jmp    1180 <finish_lazy_updates_Katyusha+0x70>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @finish_lazy_updates_Katyusha(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i64* nocapture %4, double %5, double %6, i64 %7, i64 %8, double* nocapture %9, double* nocapture %10, double %11, double %12, double %13) {
%15 = icmp sgt i64 %8, 0
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = sub i64 0, %7
br label %19
18: ; preds = %63, %14
ret void
19: ; preds = %16, %63
%20 = phi i64 [ %64, %63 ], [ 0, %16 ]
%21 = getelementptr inbounds i64, i64* %4, i64 %20
%22 = load i64, i64* %21
%23 = sub nsw i64 %7, %22
%24 = sitofp i64 %23 to double
%25 = fmul double %24, %5
%26 = getelementptr inbounds double, double* %3, i64 %20
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %0, i64 %20
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %1, i64 %20
%31 = load double, double* %30
%32 = fsub double %29, %31
%33 = tail call double @llvm.fmuladd.f64(double %6, double %32, double %27)
%34 = fmul double %25, %33
%35 = getelementptr inbounds double, double* %10, i64 %20
%36 = load double, double* %35
%37 = fsub double %36, %34
store double %37, double* %35
%38 = getelementptr inbounds double, double* %9, i64 %20
%39 = load double, double* %38
%40 = fneg double %34
%41 = tail call double @llvm.fmuladd.f64(double %40, double %11, double %39)
store double %41, double* %38
%42 = load double, double* %35
%43 = load double, double* %30
%44 = fmul double %43, 5.000000e-01
%45 = tail call double @llvm.fmuladd.f64(double %42, double %11, double %44)
%46 = tail call double @llvm.fmuladd.f64(double %41, double %12, double %45)
store double %46, double* %28
%47 = icmp slt i64 %22, %7
br i1 %47, label %48, label %63
48: ; preds = %19
%49 = getelementptr inbounds double, double* %2, i64 %20
%50 = fmul double %40, %11
%51 = sub i64 %7, %22
%52 = xor i64 %22, -1
%53 = and i64 %51, 1
%54 = icmp eq i64 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %48
%56 = tail call double @pow(double %13, i64 %22)
%57 = load double, double* %49
%58 = tail call double @llvm.fmuladd.f64(double %50, double %56, double %57)
store double %58, double* %49
%59 = add i64 %22, 1
br label %60
60: ; preds = %55, %48
%61 = phi i64 [ %22, %48 ], [ %59, %55 ]
%62 = icmp eq i64 %52, %17
br i1 %62, label %63, label %66
63: ; preds = %60, %66, %19
%64 = add nuw nsw i64 %20, 1
%65 = icmp eq i64 %64, %8
br i1 %65, label %18, label %19
66: ; preds = %60, %66
%67 = phi i64 [ %75, %66 ], [ %61, %60 ]
%68 = tail call double @pow(double %13, i64 %67)
%69 = load double, double* %49
%70 = tail call double @llvm.fmuladd.f64(double %50, double %68, double %69)
store double %70, double* %49
%71 = add i64 %67, 1
%72 = tail call double @pow(double %13, i64 %71)
%73 = load double, double* %49
%74 = tail call double @llvm.fmuladd.f64(double %50, double %72, double %73)
store double %74, double* %49
%75 = add i64 %67, 2
%76 = icmp eq i64 %75, %7
br i1 %76, label %63, label %66
}