// File: redpony[P]libpopt/optimize.cc
// Function: RPropOptimizer::OptimizeImpl(double const&, std::vector<double, std::allocator<double>> const&, std::vector<double, std::allocator<double>>*)
void RPropOptimizer::OptimizeImpl(const double& obj,
                              const vector<double>& g,
                              vector<double>* x) {
  for (int i = 0; i < g.size(); ++i) {
    const double g_i = g[i];
    const double sign_i = (signbit(g_i) ? -1.0 : 1.0);
    const double prod = g_i * prev_g_[i];
    if (prod > 0.0) {
      const double dij = min(delta_ij_[i] * eta_plus_, delta_max_);
      (*x)[i] -= dij * sign_i;
      delta_ij_[i] = dij;
      prev_g_[i] = g_i;
    } else if (prod < 0.0) {
      delta_ij_[i] = max(delta_ij_[i] * eta_minus_, delta_min_);
      prev_g_[i] = 0.0;
    } else {
      (*x)[i] -= delta_ij_[i] * sign_i;
      prev_g_[i] = g_i;
    }
  }
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0xa4(%rsp)
movslq 0xa4(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x52d0
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jae 0x7727
movq 0xb0(%rsp), %rdi
movslq 0xa4(%rsp), %rsi
callq 0x55a0
movsd (%rax), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x98(%rsp), %xmm0
callq 0x7c70
movsd 0x6f56(%rip), %xmm0     # 0xe398
movsd 0x6c16(%rip), %xmm1     # 0xe060
movsd %xmm1, 0x50(%rsp)
testb $0x1, %al
movsd %xmm0, 0x58(%rsp)
jne 0x7466
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x68(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
addq $0x10, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x48(%rsp), %xmm0
mulsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x75d1
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movq 0x68(%rsp), %rsi
movsd (%rax), %xmm0
mulsd 0x40(%rsi), %xmm0
movsd %xmm0, 0x78(%rsp)
addq $0x50, %rsi
leaq 0x78(%rsp), %rdi
callq 0x7c90
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x28(%rsp), %xmm0
movsd 0x30(%rsp), %xmm2
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0x28, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x38(%rsp), %xmm0
movq 0x68(%rsp), %rdi
movsd %xmm0, (%rax)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
addq $0x10, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x770f
xorps %xmm0, %xmm0
ucomisd 0x88(%rsp), %xmm0
jbe 0x7667
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movq 0x68(%rsp), %rsi
movsd (%rax), %xmm0
mulsd 0x48(%rsi), %xmm0
movsd %xmm0, 0x70(%rsp)
addq $0x58, %rsi
leaq 0x70(%rsp), %rdi
callq 0x5cb0
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x28, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x20(%rsp), %xmm0
movq 0x68(%rsp), %rdi
movsd %xmm0, (%rax)
addq $0x10, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x770d
movq 0x68(%rsp), %rdi
addq $0x28, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm2
movq 0x68(%rsp), %rdi
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x10, %rdi
movslq 0xa4(%rsp), %rsi
callq 0x46b0
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x770f
jmp 0x7711
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x73df
addq $0xc8, %rsp
retq
nop