// File: /workspace/github_cpp_makefile_star2_O3/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), %xmm1
subq %rax, %rcx
sarq $0x5, %rcx
cmpq $0x2, %rcx
jb 0x35f9
decq %rcx
addq $0x38, %rax
movapd %xmm1, %xmm3
movsd (%rax), %xmm4
movapd %xmm4, %xmm2
minsd %xmm1, %xmm2
maxsd %xmm3, %xmm4
addq $0x20, %rax
movapd %xmm2, %xmm1
movapd %xmm4, %xmm3
decq %rcx
jne 0x35d6
jmp 0x3601
movapd %xmm1, %xmm4
movapd %xmm1, %xmm2
movsd 0x79ff(%rip), %xmm1     # 0xb008
divsd %xmm2, %xmm1
movsd %xmm4, -0x28(%rbp)
divsd %xmm4, %xmm0
movsd %xmm1, -0x50(%rbp)
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x2100
movapd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x794a
movq %r15, %xmm0
punpckldq 0x7a0b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7a13(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x79af(%rip), %xmm1     # 0xb020
movapd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, -0x40(%rbp)
movsd 0x7981(%rip), %xmm0     # 0xb008
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
testq %r14, %r14
je 0x371e
movapd 0x79ee(%rip), %xmm0     # 0xb090
xorpd -0x40(%rbp), %xmm0
movapd %xmm0, -0x60(%rbp)
xorl %r12d, %r12d
leaq -0x30(%rbp), %r15
movq %r12, %xmm1
punpckldq 0x79a0(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x79a8(%rip), %xmm1     # 0xb070
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd -0x60(%rbp), %xmm0
callq 0x2240
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x371e
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x370b
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x3716
movq %rbx, %rdi
movq %r15, %rdx
callq 0x95d8
incq %r12
cmpq %r12, %r14
jne 0x36b3
movq 0x8(%rbx), %r12
subq (%rbx), %r12
sarq $0x3, %r12
cmpq %r14, %r12
jae 0x37c8
movq %r12, %xmm0
punpckldq 0x7921(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x7929(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, -0x50(%rbp)
leaq -0x30(%rbp), %r15
movq %r12, %xmm0
punpckldq 0x78f7(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x78ff(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
subsd -0x50(%rbp), %xmm1
mulsd -0x40(%rbp), %xmm1
addsd 0x7879(%rip), %xmm1     # 0xb008
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x37b5
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x37c0
movq %rbx, %rdi
movq %r15, %rdx
callq 0x95d8
incq %r12
cmpq %r12, %r14
jne 0x375c
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37dc
jmp 0x37dc
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x37f3
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2170
movq %r14, %rdi
callq 0x2230