// File: /workspace/github_cpp_makefile_star2_O2/ekg[P]sgd2/src/sgd2.hpp
// Function: sgd2::schedule_convergent(std::vector<sgd2::term, std::allocator<sgd2::term>> const&, unsigned long, double, unsigned long)
std::vector<double> schedule_convergent(const std::vector<term> &terms, uint64_t t_max, double eps, uint64_t t_maxmax)
{
    double w_min = terms[0].w, w_max = terms[0].w;
    for (uint64_t i=1; i<terms.size(); i++)
    {
        double w = terms[i].w;
        if (w < w_min) w_min = w;
        if (w > w_max) w_max = w;
    }
    double eta_max = 1.0 / w_min;
    double eta_min = eps / w_max;

    double lambda = log(eta_max/eta_min) / ((double)t_max-1);

    // initialize step sizes
    std::vector<double> etas;
    etas.reserve(t_maxmax);
    double eta_switch = 1.0 / w_max;
    for (uint64_t t=0; t<t_maxmax; t++)
    {
        double eta = eta_max * exp(-lambda * t);
        if (eta < eta_switch)
            break;

        etas.push_back(eta);
    }
    uint64_t tau = etas.size();
    for (uint64_t t=tau; t<t_maxmax; t++)
    {
        double eta = eta_switch / (1 + lambda*((double)t-tau));
        etas.push_back(eta);
    }

    return etas;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
movsd 0x18(%rax), %xmm4
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x38, %rax
pushq $0x1
popq %rdx
movapd %xmm4, %xmm1
cmpq %rcx, %rdx
jae 0x2f85
movsd (%rax), %xmm2
movapd %xmm2, %xmm3
minsd %xmm1, %xmm3
maxsd %xmm4, %xmm2
incq %rdx
addq $0x20, %rax
movapd %xmm2, %xmm4
movapd %xmm3, %xmm1
jmp 0x2f5f
movsd 0x807b(%rip), %xmm2     # 0xb008
divsd %xmm1, %xmm2
divsd %xmm4, %xmm0
movsd %xmm2, -0x40(%rbp)
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd %xmm4, -0x28(%rbp)
callq 0x2100
movapd %xmm0, -0x50(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61fc
movq %r15, %xmm0
punpckldq 0x8086(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x808e(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x802a(%rip), %xmm1     # 0xb020
movapd -0x50(%rbp), %xmm2
divsd %xmm1, %xmm2
movsd 0x8001(%rip), %xmm0     # 0xb008
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movapd 0x8077(%rip), %xmm0     # 0xb090
movapd %xmm2, -0x50(%rbp)
xorpd %xmm2, %xmm0
movapd %xmm0, -0x60(%rbp)
xorl %r12d, %r12d
leaq -0x30(%rbp), %r15
cmpq %r12, %r14
je 0x3083
movq %r12, %xmm1
punpckldq 0x8020(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x8028(%rip), %xmm1     # 0xb070
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd -0x60(%rbp), %xmm0
callq 0x2220
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x3083
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6292
incq %r12
jmp 0x302e
movq 0x8(%rbx), %r12
subq (%rbx), %r12
sarq $0x3, %r12
movq %r12, %xmm0
punpckldq 0x7fc5(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7fcd(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, -0x40(%rbp)
leaq -0x30(%rbp), %r15
cmpq %r14, %r12
jae 0x310e
movq %r12, %xmm0
punpckldq 0x7f96(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7f9e(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
subsd -0x40(%rbp), %xmm1
mulsd -0x50(%rbp), %xmm1
addsd 0x7f18(%rip), %xmm1     # 0xb008
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6292
incq %r12
jmp 0x30b8
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3122
jmp 0x3122
movq %rax, %r14
movq %rbx, %rdi
callq 0x89de
movq %r14, %rdi
callq 0x2210