// File: /workspace/github_cpp_makefile_star2_O2/ArashPartow[P]exprtk-extras/exprtk_gnuplot_multi.cpp
// Function: exprtk_gnuplot_fx::generate_data(unsigned long, exprtk_fx_curve&)
bool generate_data(const std::size_t index, exprtk_fx_curve& curve)
   {
      typedef exprtk::symbol_table<double> symbol_table_t;
      typedef exprtk::expression<double>   expression_t;
      typedef exprtk::parser<double>       parser_t;

      double x = 0.0;

      symbol_table_t symbol_table;
      symbol_table.add_constants();
      symbol_table.add_variable("x",x);

      expression_t expression;
      expression.register_symbol_table(symbol_table);

      parser_t parser;

      if (!parser.compile(curve.expression_,expression))
      {
         return false;
      }

      const std::string file_name = std::string("data.dat") + (char)('0' + index);

      std::ofstream stream(file_name.c_str());

      if (!stream)
      {
         return false;
      }

      curve.min_y_ = +std::numeric_limits<double>::max();
      curve.max_y_ = -std::numeric_limits<double>::max();

      stream << std::setprecision(10);

      const double increment = std::min(0.00005,std::abs(curve.max_x_ - curve.min_x_) / 1000.0);

      for (x = curve.min_x_; x <= curve.max_x_; x += increment)
      {
         const double y = expression.value();

              if (y < curve.min_y_) curve.min_y_ = y;
         else if (y > curve.max_y_) curve.max_y_ = y;

         stream << x << "\t" << y << "\n";
      }

      const double diff_y  = std::abs(curve.max_y_ - curve.min_y_);
      const double perc7_5 = diff_y * 0.075; //7.5%

      curve.min_y_ -= perc7_5;
      curve.max_y_ += perc7_5;

      return true;
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xba8, %rsp            # imm = 0xBA8
movq %rdx, %rbx
movq %rsi, %r14
andq $0x0, 0x18(%rsp)
leaq 0x10(%rsp), %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x1110fc
movq %r15, %rdi
callq 0x111120
leaq 0x12a54d(%rip), %rsi    # 0x23b0a1
leaq 0x280(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x11058a
leaq 0x10(%rsp), %rdi
leaq 0x280(%rsp), %rsi
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x111146
leaq 0x280(%rsp), %rdi
callq 0x10e628
leaq 0x30(%rsp), %rdi
callq 0x1111b2
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x111212
leaq 0x80(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x11126e
leaq 0x280(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x11137e
leaq 0x80(%rsp), %rdi
callq 0x111996
leaq 0x20(%rbx), %rsi
leaq 0x280(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x1119de
testb %al, %al
je 0x110d68
leaq 0x12f13b(%rip), %rsi    # 0x23fd3a
leaq 0x80(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x11058a
addb $0x30, %r14b
movsbl %r14b, %edx
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x111e60
leaq 0x80(%rsp), %rdi
callq 0x10e628
movq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x10e170
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0xa0(%rsp,%rcx)
sete %bpl
jne 0x110da6
movl %ebp, 0x24(%rsp)
leaq 0x50(%rbx), %r13
movaps 0x1253a6(%rip), %xmm0   # 0x236020
movups %xmm0, 0x50(%rbx)
movq -0x18(%rax), %rax
movq $0xa, 0x88(%rsp,%rax)
movsd 0x40(%rbx), %xmm0
movsd 0x48(%rbx), %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
andpd 0x125388(%rip), %xmm2   # 0x236030
divsd 0x1253e0(%rip), %xmm2   # 0x236090
minsd 0x1253e0(%rip), %xmm2   # 0x236098
movapd %xmm2, 0x50(%rsp)
leaq 0x58(%rbx), %rbp
leaq 0x80(%rsp), %r14
leaq 0x12a51b(%rip), %r15    # 0x23b1ec
leaq 0x12f01e(%rip), %r12    # 0x23fcf6
movsd %xmm0, 0x18(%rsp)
ucomisd %xmm0, %xmm1
jb 0x110d6c
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movsd %xmm0, 0x28(%rsp)
movsd (%r13), %xmm0
movsd 0x28(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq %r13, %rax
ja 0x110d1c
ucomisd (%rbp), %xmm1
movq %rbp, %rax
jbe 0x110d20
movsd %xmm1, (%rax)
movsd 0x18(%rsp), %xmm0
movq %r14, %rdi
callq 0x10e3b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x10e2e0
movq %rax, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x10e3b0
movq %rax, %rdi
movq %r12, %rsi
callq 0x10e2e0
movsd 0x18(%rsp), %xmm0
addsd 0x50(%rsp), %xmm0
movsd 0x48(%rbx), %xmm1
jmp 0x110cd8
xorl %ebp, %ebp
jmp 0x110dbd
movsd (%rbp), %xmm0
movsd (%r13), %xmm1
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
andpd 0x1252a9(%rip), %xmm2   # 0x236030
mulsd 0x125311(%rip), %xmm2   # 0x2360a0
subsd %xmm2, %xmm1
movsd %xmm1, (%r13)
addsd %xmm0, %xmm2
movsd %xmm2, (%rbp)
movl 0x24(%rsp), %ebp
leaq 0x80(%rsp), %rdi
callq 0x10e3d0
leaq 0x60(%rsp), %rdi
callq 0x10e628
leaq 0x280(%rsp), %rdi
callq 0x111e82
leaq 0x30(%rsp), %rdi
callq 0x111fbc
leaq 0x10(%rsp), %rdi
callq 0x111fd2
movl %ebp, %eax
addq $0xba8, %rsp            # imm = 0xBA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x110e4f
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x110e54
jmp 0x110e06
movq %rax, %rbx
jmp 0x110e59
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x111996
jmp 0x110e66
jmp 0x110e1f
movq %rax, %rbx
jmp 0x110e66
jmp 0x110e3a
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x10e628
jmp 0x110e70
jmp 0x110e3a
movq %rax, %rbx
jmp 0x110e70
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x10e3d0
leaq 0x60(%rsp), %rdi
callq 0x10e628
leaq 0x280(%rsp), %rdi
callq 0x111e82
leaq 0x30(%rsp), %rdi
callq 0x111fbc
leaq 0x10(%rsp), %rdi
callq 0x111fd2
movq %rbx, %rdi
callq 0x10e340