// File: ArashPartow[P]exprtk/exprtk_simple_example_19.cpp
// Function: void vector_randu<double>()
void vector_randu()
{
   typedef exprtk::symbol_table<T> symbol_table_t;
   typedef exprtk::expression<T>   expression_t;
   typedef exprtk::parser<T>       parser_t;

   const std::string vecrandu_program =
      " var noise[6] := [0];                          "
      "                                               "
      " if (randu(noise, 0, 5) == false)              "
      " {                                             "
      "    println('Failed to generate noise');       "
      "    return [false];                            "
      " };                                            "
      "                                               "
      " var noisy[noise[]] := signal + (noise - 1/2); "
      "                                               "
      " for (var i := 0; i < noisy[]; i += 1)         "
      " {                                             "
      "    println('noisy[',i,'] = ', noisy[i]);      "
      " };                                            "
      "                                               "
      " println('avg: ', avg(noisy));                 "
      "                                               ";

   T signal[] = { T(1.1), T(2.2), T(3.3), T(4.4), T(5.5), T(6.6), T(7.7) };

   exprtk::rtl::io::println<T> println;
   randu<T>                    randu;

   symbol_table_t symbol_table;
   symbol_table.add_vector  ("signal" , signal );
   symbol_table.add_function("println", println);
   symbol_table.add_function("randu"  , randu  );

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;
   parser.compile(vecrandu_program,expression);

   expression.value();
}

// Assembly:
subq $0xc98, %rsp            # imm = 0xC98
leaq 0xc77(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x111660
movq 0x28(%rsp), %rdx
leaq 0x331cd0(%rip), %rsi    # 0x44a545
leaq 0xc78(%rsp), %rdi
callq 0x118790
jmp 0x118884
leaq 0xc77(%rsp), %rdi
callq 0x1117b0
movabsq $0x401ecccccccccccd, %rax # imm = 0x401ECCCCCCCCCCCD
movq %rax, 0xc50(%rsp)
movaps 0x336b26(%rip), %xmm0   # 0x44f3d0
movaps %xmm0, 0xc40(%rsp)
movaps 0x336b07(%rip), %xmm0   # 0x44f3c0
movaps %xmm0, 0xc30(%rsp)
movaps 0x336ae8(%rip), %xmm0   # 0x44f3b0
movaps %xmm0, 0xc20(%rsp)
leaq 0xb97(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x111660
movq 0x20(%rsp), %rdx
leaq 0x331f77(%rip), %rsi    # 0x44a865
leaq 0xb98(%rsp), %rdi
callq 0x118790
jmp 0x1188fd
leaq 0xbb8(%rsp), %rdi
leaq 0xb98(%rsp), %rsi
callq 0x119030
jmp 0x118914
leaq 0xb98(%rsp), %rdi
callq 0x1117c8
leaq 0xb97(%rsp), %rdi
callq 0x1117b0
leaq 0xb48(%rsp), %rdi
callq 0x119140
jmp 0x11893d
leaq 0xb40(%rsp), %rdi
movl $0x1, %esi
callq 0x119210
jmp 0x118951
leaq 0xb1f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x111660
movq 0x18(%rsp), %rdx
leaq 0x331efd(%rip), %rsi    # 0x44a86c
leaq 0xb20(%rsp), %rdi
callq 0x118790
jmp 0x11897e
leaq 0xb40(%rsp), %rdi
leaq 0xb20(%rsp), %rsi
leaq 0xc20(%rsp), %rdx
callq 0x119250
jmp 0x11899d
leaq 0xb20(%rsp), %rdi
callq 0x1117c8
leaq 0xb1f(%rsp), %rdi
callq 0x1117b0
leaq 0xaf7(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x111660
movq 0x10(%rsp), %rdx
leaq 0x331e9e(%rip), %rsi    # 0x44a873
leaq 0xaf8(%rsp), %rdi
callq 0x118790
jmp 0x1189e4
leaq 0xb40(%rsp), %rdi
leaq 0xaf8(%rsp), %rsi
leaq 0xbb8(%rsp), %rdx
callq 0x1192f0
jmp 0x118a03
leaq 0xaf8(%rsp), %rdi
callq 0x1117c8
leaq 0xaf7(%rsp), %rdi
callq 0x1117b0
leaq 0xacf(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x111660
movq 0x8(%rsp), %rdx
leaq 0x331e40(%rip), %rsi    # 0x44a87b
leaq 0xad0(%rsp), %rdi
callq 0x118790
jmp 0x118a4a
leaq 0xb40(%rsp), %rdi
leaq 0xad0(%rsp), %rsi
leaq 0xb48(%rsp), %rdx
callq 0x1192f0
jmp 0x118a69
leaq 0xad0(%rsp), %rdi
callq 0x1117c8
leaq 0xacf(%rsp), %rdi
callq 0x1117b0
leaq 0xaa8(%rsp), %rdi
callq 0x1194f0
jmp 0x118a92
leaq 0xaa8(%rsp), %rdi
leaq 0xb40(%rsp), %rsi
callq 0x1195a0
jmp 0x118aa9
leaq 0x30(%rsp), %rdi
movl $0x7f, %esi
callq 0x119650
jmp 0x118aba
leaq 0x180(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x119780
jmp 0x118ace
leaq 0x30(%rsp), %rdi
callq 0x119fb0
leaq 0x180(%rsp), %rdi
leaq 0xc78(%rsp), %rsi
leaq 0xaa8(%rsp), %rdx
callq 0x11a020
jmp 0x118af7
leaq 0xaa8(%rsp), %rdi
callq 0x11a8b0
jmp 0x118b06
leaq 0x180(%rsp), %rdi
callq 0x11a8d0
leaq 0xaa8(%rsp), %rdi
callq 0x11aad0
leaq 0xb40(%rsp), %rdi
callq 0x11ab10
leaq 0xb48(%rsp), %rdi
callq 0x11ab90
leaq 0xbb8(%rsp), %rdi
callq 0x11aba0
leaq 0xc78(%rsp), %rdi
callq 0x1117c8
addq $0xc98, %rsp            # imm = 0xC98
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0xc77(%rsp), %rdi
callq 0x1117b0
jmp 0x118d83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118bb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0xb98(%rsp), %rdi
callq 0x1117c8
leaq 0xb97(%rsp), %rdi
callq 0x1117b0
jmp 0x118d76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118d69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118d5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118c34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0xb20(%rsp), %rdi
callq 0x1117c8
leaq 0xb1f(%rsp), %rdi
callq 0x1117b0
jmp 0x118d4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118c7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0xaf8(%rsp), %rdi
callq 0x1117c8
leaq 0xaf7(%rsp), %rdi
callq 0x1117b0
jmp 0x118d4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118cc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0xad0(%rsp), %rdi
callq 0x1117c8
leaq 0xacf(%rsp), %rdi
callq 0x1117b0
jmp 0x118d4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118d4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
jmp 0x118d42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x119fb0
jmp 0x118d42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc68(%rsp)
movl %eax, 0xc64(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x11a8d0
leaq 0xaa8(%rsp), %rdi
callq 0x11aad0
leaq 0xb40(%rsp), %rdi
callq 0x11ab10
leaq 0xb48(%rsp), %rdi
callq 0x11ab90
leaq 0xbb8(%rsp), %rdi
callq 0x11aba0
leaq 0xc78(%rsp), %rdi
callq 0x1117c8
movq 0xc68(%rsp), %rdi
callq 0x111450