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

   const std::string fileio_program =
      " var file_name := 'file.txt';                          "
      " var stream    := null;                                "
      "                                                       "
      " if (stream := open(file_name,'w'))                    "
      "    println('Successfully opened file: ' + file_name); "
      " else                                                  "
      " {                                                     "
      "    println('Failed to open file: ' + file_name);      "
      "    return [false];                                    "
      " };                                                    "
      "                                                       "
      " var s := 'Hello world...\n';                          "
      "                                                       "
      " for (var i := 0; i < 10; i += 1)                      "
      " {                                                     "
      "    write(stream,s);                                   "
      " };                                                    "
      "                                                       "
      " if (close(stream))                                    "
      "    println('Sucessfully closed file: ' + file_name);  "
      " else                                                  "
      " {                                                     "
      "    println('Failed to close file: ' + file_name);     "
      "    return [false];                                    "
      " }                                                     ";

   exprtk::rtl::io::file::package<T> fileio_package;
   exprtk::rtl::io::println<T>       println;

   symbol_table_t symbol_table;
   symbol_table.add_function("println",println);
   symbol_table.add_package (fileio_package   );

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   printf("Result %10.3f\n",expression.value());
}

// Assembly:
pushq %rbx
subq $0xca0, %rsp            # imm = 0xCA0
leaq 0x12bd7f(%rip), %rsi    # 0x23d121
leaq 0x30(%rsp), %rdi
leaq 0x378(%rsp), %rdx
callq 0x111358
leaq 0x208(%rsp), %rdi
callq 0x111668
leaq 0x12c2b8(%rip), %rsi    # 0x23d680
leaq 0x378(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x111358
leaq 0x50(%rsp), %rdi
leaq 0x378(%rsp), %rsi
callq 0x11172e
leaq 0x378(%rsp), %rdi
callq 0x10f658
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x1117c0
leaq 0x12c277(%rip), %rsi    # 0x23d687
leaq 0x378(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x111358
leaq 0x8(%rsp), %rdi
leaq 0x378(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x1117e4
leaq 0x378(%rsp), %rdi
callq 0x10f658
leaq 0x208(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x114842
leaq 0x10(%rsp), %rdi
callq 0x1118ac
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x11190c
leaq 0xb8(%rsp), %rdi
pushq $0x7f
popq %rsi
callq 0x111968
leaq 0x378(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x111a78
leaq 0xb8(%rsp), %rdi
callq 0x112090
leaq 0x378(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1120d8
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x12c1bc(%rip), %rdi    # 0x23d68f
movb $0x1, %al
callq 0x10f070
leaq 0x378(%rsp), %rdi
callq 0x11255a
leaq 0x10(%rsp), %rdi
callq 0x112694
leaq 0x8(%rsp), %rdi
callq 0x1126aa
leaq 0x50(%rsp), %rdi
callq 0x1126ec
leaq 0x208(%rsp), %rdi
callq 0x112702
leaq 0x30(%rsp), %rdi
callq 0x10f658
addq $0xca0, %rsp            # imm = 0xCA0
popq %rbx
retq
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x112090
jmp 0x11158a
jmp 0x111539
movq %rax, %rbx
jmp 0x11158a
jmp 0x111554
jmp 0x111554
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x10f658
jmp 0x111594
movq %rax, %rbx
jmp 0x111594
movq %rax, %rbx
jmp 0x11159e
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x10f658
jmp 0x1115a8
movq %rax, %rbx
jmp 0x1115a8
movq %rax, %rbx
jmp 0x1115b5
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x11255a
leaq 0x10(%rsp), %rdi
callq 0x112694
leaq 0x8(%rsp), %rdi
callq 0x1126aa
leaq 0x50(%rsp), %rdi
callq 0x1126ec
leaq 0x208(%rsp), %rdi
callq 0x112702
leaq 0x30(%rsp), %rdi
callq 0x10f658
movq %rbx, %rdi
callq 0x10f390