// File: /workspace/github_cpp_makefile_star2_O1/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 0x3735
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 0x3712
jmp 0x373d
movapd %xmm1, %xmm4
movapd %xmm1, %xmm2
movsd 0x78c3(%rip), %xmm1     # 0xb008
divsd %xmm2, %xmm1
movsd %xmm4, -0x28(%rbp)
divsd %xmm4, %xmm0
movsd %xmm1, -0x50(%rbp)
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x2110
movapd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8080
movq %r15, %xmm0
punpckldq 0x78cf(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x78d7(%rip), %xmm0     # 0xb070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x7873(%rip), %xmm1     # 0xb020
movapd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, -0x40(%rbp)
movsd 0x7845(%rip), %xmm0     # 0xb008
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
testq %r14, %r14
je 0x385a
movapd 0x78b2(%rip), %xmm0     # 0xb090
xorpd -0x40(%rbp), %xmm0
movapd %xmm0, -0x60(%rbp)
xorl %r12d, %r12d
leaq -0x30(%rbp), %r15
movq %r12, %xmm1
punpckldq 0x7864(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x786c(%rip), %xmm1     # 0xb070
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd -0x60(%rbp), %xmm0
callq 0x2250
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x385a
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3847
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x3852
movq %rbx, %rdi
movq %r15, %rdx
callq 0x9c9e
incq %r12
cmpq %r12, %r14
jne 0x37ef
movq 0x8(%rbx), %r12
subq (%rbx), %r12
sarq $0x3, %r12
cmpq %r14, %r12
jae 0x3904
movq %r12, %xmm0
punpckldq 0x77e5(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x77ed(%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 0x77bb(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x77c3(%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 0x773d(%rip), %xmm1     # 0xb008
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x38f1
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x38fc
movq %rbx, %rdi
movq %r15, %rdx
callq 0x9c9e
incq %r12
cmpq %r12, %r14
jne 0x3898
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3918
jmp 0x3918
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x392f
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r14, %rdi
callq 0x2240