// File: 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:
subq $0xde8, %rsp            # imm = 0xDE8
movq %rdi, 0xdd8(%rsp)
movq %rsi, 0xdd0(%rsp)
movq %rdx, 0xdc8(%rsp)
movq $0x0, 0xdc0(%rsp)
leaq 0xdb8(%rsp), %rdi
movq %rdi, 0x58(%rsp)
movl $0x1, %esi
callq 0x11ad50
movq 0x58(%rsp), %rdi
callq 0x11ad90
jmp 0x11a1fe
leaq 0xd87(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x1116c0
movq 0x50(%rsp), %rdx
leaq 0x3302b5(%rip), %rsi    # 0x44a4d1
leaq 0xd88(%rsp), %rdi
callq 0x118c30
jmp 0x11a22b
leaq 0xdb8(%rsp), %rdi
leaq 0xd88(%rsp), %rsi
leaq 0xdc0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x11adf0
jmp 0x11a24c
leaq 0xd88(%rsp), %rdi
callq 0x111818
leaq 0xd87(%rsp), %rdi
callq 0x111800
leaq 0xd60(%rsp), %rdi
callq 0x11aea0
jmp 0x11a275
leaq 0xd60(%rsp), %rdi
leaq 0xdb8(%rsp), %rsi
callq 0x11af50
jmp 0x11a28c
leaq 0x2e8(%rsp), %rdi
movl $0x7f, %esi
callq 0x11b000
jmp 0x11a2a0
leaq 0x438(%rsp), %rdi
leaq 0x2e8(%rsp), %rsi
callq 0x11b130
jmp 0x11a2b7
leaq 0x2e8(%rsp), %rdi
callq 0x11b960
movq 0xdc8(%rsp), %rsi
addq $0x20, %rsi
leaq 0x438(%rsp), %rdi
leaq 0xd60(%rsp), %rdx
callq 0x11b9d0
movb %al, 0x4f(%rsp)
jmp 0x11a2eb
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x11a3cb
jmp 0x11a2f9
movb $0x0, 0xde7(%rsp)
movl $0x1, 0x2e4(%rsp)
jmp 0x11a7e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a361
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
leaq 0xd88(%rsp), %rdi
callq 0x111818
leaq 0xd87(%rsp), %rdi
callq 0x111800
jmp 0x11a833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
leaq 0x2e8(%rsp), %rdi
callq 0x11b960
jmp 0x11a826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a819
leaq 0x29f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x1116c0
movq 0x40(%rsp), %rdx
leaq 0x334d96(%rip), %rsi    # 0x44f17f
leaq 0x2a0(%rsp), %rdi
callq 0x118c30
jmp 0x11a3f8
movl 0xdd0(%rsp), %eax
addl $0x30, %eax
movsbl %al, %edx
leaq 0x2c0(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x11c260
jmp 0x11a41c
leaq 0x2a0(%rsp), %rdi
callq 0x111818
leaq 0x29f(%rsp), %rdi
callq 0x111800
leaq 0x2c0(%rsp), %rdi
callq 0x111100
movq %rax, %rsi
leaq 0x98(%rsp), %rdi
movl $0x10, %edx
callq 0x111280
jmp 0x11a45a
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x98(%rsp,%rax), %rdi
callq 0x111060
movb %al, 0x3f(%rsp)
jmp 0x11a479
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x11a486
jmp 0x11a526
movb $0x0, 0xde7(%rsp)
movl $0x1, 0x2e4(%rsp)
jmp 0x11a7b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a4d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0x111818
leaq 0x29f(%rsp), %rdi
callq 0x111800
jmp 0x11a819
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
jmp 0x11a7d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xdb0(%rsp)
movl %eax, 0xdac(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x111520
jmp 0x11a7d2
callq 0x11c2b0
movq 0xdc8(%rsp), %rax
movsd %xmm0, 0x50(%rax)
callq 0x11c2b0
movaps 0x32ab9c(%rip), %xmm1   # 0x4450e0
pxor %xmm1, %xmm0
movq 0xdc8(%rsp), %rax
movlpd %xmm0, 0x58(%rax)
movl $0xa, %edi
callq 0x11c2c0
movl %eax, 0x38(%rsp)
jmp 0x11a565
movl 0x38(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %esi
leaq 0x98(%rsp), %rdi
callq 0x1110d0
jmp 0x11a586
movabsq $0x3f0a36e2eb1c432d, %rax # imm = 0x3F0A36E2EB1C432D
movq %rax, 0x80(%rsp)
movq 0xdc8(%rsp), %rax
movsd 0x40(%rax), %xmm1
movsd 0x48(%rax), %xmm0
subsd %xmm1, %xmm0
callq 0x11c320
movsd %xmm0, 0x30(%rsp)
jmp 0x11a5bb
movsd 0x30(%rsp), %xmm0
movsd 0x32aa4f(%rip), %xmm1   # 0x445018
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x11c2e0
movq %rax, 0x28(%rsp)
jmp 0x11a5ec
movq 0x28(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0xdc8(%rsp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, 0xdc0(%rsp)
movsd 0xdc0(%rsp), %xmm1
movq 0xdc8(%rsp), %rax
movsd 0x48(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11a72e
leaq 0xd60(%rsp), %rdi
callq 0x11c340
movsd %xmm0, 0x20(%rsp)
jmp 0x11a649
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x70(%rsp), %xmm1
movq 0xdc8(%rsp), %rax
movsd 0x50(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x11a683
movsd 0x70(%rsp), %xmm0
movq 0xdc8(%rsp), %rax
movsd %xmm0, 0x50(%rax)
jmp 0x11a6ad
movsd 0x70(%rsp), %xmm0
movq 0xdc8(%rsp), %rax
ucomisd 0x58(%rax), %xmm0
jbe 0x11a6ab
movsd 0x70(%rsp), %xmm0
movq 0xdc8(%rsp), %rax
movsd %xmm0, 0x58(%rax)
jmp 0x11a6ad
movsd 0xdc0(%rsp), %xmm0
leaq 0x98(%rsp), %rdi
callq 0x111590
movq %rax, 0x18(%rsp)
jmp 0x11a6ca
movq 0x18(%rsp), %rdi
leaq 0x32ff1c(%rip), %rsi    # 0x44a5f2
callq 0x111430
movq %rax, 0x10(%rsp)
jmp 0x11a6e2
movq 0x10(%rsp), %rdi
movsd 0x70(%rsp), %xmm0
callq 0x111590
movq %rax, 0x8(%rsp)
jmp 0x11a6f9
movq 0x8(%rsp), %rdi
leaq 0x334a36(%rip), %rsi    # 0x44f13b
callq 0x111430
jmp 0x11a70c
jmp 0x11a70e
movsd 0x88(%rsp), %xmm0
addsd 0xdc0(%rsp), %xmm0
movsd %xmm0, 0xdc0(%rsp)
jmp 0x11a614
movq 0xdc8(%rsp), %rax
movsd 0x50(%rax), %xmm1
movsd 0x58(%rax), %xmm0
subsd %xmm1, %xmm0
callq 0x11c320
movsd %xmm0, (%rsp)
jmp 0x11a750
movsd (%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x32a8bd(%rip), %xmm0   # 0x445020
mulsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x60(%rsp), %xmm1
movq 0xdc8(%rsp), %rax
movsd 0x50(%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rax)
movsd 0x60(%rsp), %xmm0
movq 0xdc8(%rsp), %rax
addsd 0x58(%rax), %xmm0
movsd %xmm0, 0x58(%rax)
movb $0x1, 0xde7(%rsp)
movl $0x1, 0x2e4(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x111520
leaq 0x2c0(%rsp), %rdi
callq 0x111818
jmp 0x11a7e1
leaq 0x2c0(%rsp), %rdi
callq 0x111818
jmp 0x11a819
leaq 0x438(%rsp), %rdi
callq 0x11c360
leaq 0xd60(%rsp), %rdi
callq 0x11c560
leaq 0xdb8(%rsp), %rdi
callq 0x11c5a0
movb 0xde7(%rsp), %al
andb $0x1, %al
addq $0xde8, %rsp            # imm = 0xDE8
retq
leaq 0x438(%rsp), %rdi
callq 0x11c360
leaq 0xd60(%rsp), %rdi
callq 0x11c560
leaq 0xdb8(%rsp), %rdi
callq 0x11c5a0
movq 0xdb0(%rsp), %rdi
callq 0x111490
nopl (%rax)