// File: /workspace/github_cpp_makefile_star2_O3/ArashPartow[P]exprtk-extras/exprtk_nqueens_problem.cpp
// Function: void sudoku_solver<double>()
void sudoku_solver()
{
   typedef exprtk::symbol_table<T>         symbol_table_t;
   typedef exprtk::expression<T>           expression_t;
   typedef exprtk::parser<T>               parser_t;
   typedef exprtk::function_compositor<T>  compositor_t;
   typedef typename compositor_t::function function_t;

   const T n = T(15);
   std::vector<T> board(static_cast<std::size_t>(n), T(- 1));

   exprtk::rtl::io::package<T> io_package;

   symbol_table_t symbol_table;
   symbol_table.add_constant("n"     , n    );
   symbol_table.add_vector  ("board" , board);
   symbol_table.add_package (io_package);

   compositor_t compositor(symbol_table);

   compositor.load_variables(true);
   compositor.load_vectors  (true);

   compositor.add(
      function_t("display_board")
      .expression
      (
         " for (var row := 0; row < n; row += 1)             "
         " {                                                 "
         "    for (var col := 0; col < n; col += 1)          "
         "    {                                              "
         "       print((board[row] == col) ? ' Q ' : ' . '); "
         "    };                                             "
         "                                                   "
         "    println('');                                   "
         " }                                                 "
      ));

   compositor.add(
      function_t("is_valid")
      .vars("row", "col")
      .expression
      (
         " for (var i := 0; i < row; i += 1)             "
         " {                                             "
         "    if (                                       "
         "         (board[i] == col) or                  "
         "         (abs(board[i] - col) == abs(i - row)) "
         "       )                                       "
         "    {                                          "
         "       return [false];                         "
         "    }                                          "
         " };                                            "
         "                                               "
         " return [true];                                "
      ));

   compositor.add(
      function_t("solve_nqueens")
      .var("row")
      .expression
      (
         " if (row == n)                         "
         " {                                     "
         "     return [true];                    "
         " };                                    "
         "                                       "
         " for (var col := 0; col < n; col += 1) "
         " {                                     "
         "    if (is_valid(row, col))            "
         "    {                                  "
         "       board[row] := col;              "
         "                                       "
         "       if (solve_nqueens(row + 1))     "
         "       {                               "
         "           return [true];              "
         "       }                               "
         "    }                                  "
         " };                                    "
         "                                       "
         " return [false];                       "
      ));

   const std::string sudoku_solver_program =
      " if (solve_nqueens(0))                                  "
      " {                                                      "
      "    println('N-Queens Puzzle Solved!');                 "
      " }                                                      "
      " else                                                   "
      " {                                                      "
      "    println('Error: Failed to solve n-queens puzzle.'); "
      " };                                                     "
      "                                                        "
      " display_board();                                       ";

   expression_t expression;
   expression.register_symbol_table(symbol_table);

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

   expression.value();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x15b8, %rsp           # imm = 0x15B8
movabsq $0x402e000000000000, %rax # imm = 0x402E000000000000
movq %rax, 0x60(%rsp)
movl $0x78, %edi
callq 0x1170c0
movq %rax, 0x48(%rsp)
movq %rax, %rcx
addq $0x78, %rcx
movq %rcx, 0x58(%rsp)
xorl %edx, %edx
movdqa 0x192b36(%rip), %xmm0   # 0x2ad010
movdqa 0x192b3e(%rip), %xmm1   # 0x2ad020
movdqa 0x192b46(%rip), %xmm2   # 0x2ad030
pshufd $0xf5, %xmm2, %xmm3     # xmm3 = xmm2[1,1,3,3]
movabsq $-0x4010000000000000, %rsi # imm = 0xBFF0000000000000
movq %rdx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm0, %xmm4
pxor %xmm1, %xmm4
movdqa %xmm2, %xmm5
pcmpgtd %xmm4, %xmm5
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pcmpeqd %xmm3, %xmm4
pand %xmm5, %xmm4
movd %xmm4, %edi
testb $0x1, %dil
je 0x11a52e
movq %rsi, (%rax,%rdx,8)
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0x11a53e
movq %rsi, 0x8(%rax,%rdx,8)
addq $0x2, %rdx
cmpq $0x10, %rdx
jne 0x11a4f9
movq %rcx, 0x50(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x11b1d6
movq %rsp, %rdi
movl $0x1, %esi
callq 0x11b2b6
leaq 0xbe0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1972b6(%rip), %rsi    # 0x2b1830
leaq 0x1972b0(%rip), %rdx    # 0x2b1831
leaq 0xbd0(%rsp), %rdi
callq 0x11b01e
movq %rsp, %rdi
leaq 0xbd0(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x11b2fe
movq 0xbd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x11a5c0
movq 0xbe0(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0xbd0(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x19739b(%rip), %rsi    # 0x2b196d
leaq 0x197399(%rip), %rdx    # 0x2b1972
callq 0x11b01e
movq %rsp, %rdi
leaq 0xbd0(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x11b428
movq 0xbd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x11a610
movq 0xbe0(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x1d8(%rsp), %rdi
movq %rsp, %rsi
callq 0x11fda2
leaq 0xbd0(%rsp), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0x11b608
movw $0x101, 0x15b0(%rsp)    # imm = 0x101
leaq 0x98(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x197315(%rip), %rsi    # 0x2b1965
leaq 0x19731b(%rip), %rdx    # 0x2b1972
leaq 0x88(%rsp), %rdi
callq 0x11b01e
leaq 0x2a8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x11b790
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1972ea(%rip), %rsi    # 0x2b1973
leaq 0x1974ae(%rip), %rdx    # 0x2b1b3e
leaq 0x8(%rsp), %rdi
callq 0x11b01e
leaq 0x2c8(%rsp), %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x117520
leaq 0x1500(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0x122000
leaq 0x2e8(%rsp), %r15
leaq 0x1508(%rsp), %rcx
cmpq %rax, %rcx
jne 0x11a78b
leaq 0xbd0(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x120d66
testb %al, %al
je 0x11a78b
leaq 0x2a8(%rsp), %rsi
movq 0x88(%rsi), %rax
movq %rax, %rcx
subq 0x68(%rsi), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq 0x60(%rsi), %rax
movq 0x70(%rsi), %rdx
subq 0x78(%rsi), %rdx
subq 0x50(%rsi), %rax
sarq $0x5, %rdx
sarq $0x5, %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x8, %rcx
addq 0x1530(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
addq %rcx, %rdi
callq 0x121c24
movq (%rax), %r12
leaq 0x2a8(%rsp), %rsi
leaq 0x1500(%rsp), %rdi
callq 0x121f84
movq %r12, %rdi
movq %rax, %rsi
callq 0x121ca0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11a7a2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x117090
movq %r15, %rdi
callq 0x128f44
leaq 0x2d8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11a7cb
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x2b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11a7ec
movq 0x2b8(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x11a809
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x88(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x197324(%rip), %rsi    # 0x2b1b3f
leaq 0x197325(%rip), %rdx    # 0x2b1b47
callq 0x11b01e
leaq 0x2a8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x11b790
leaq 0x8(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x1972fd(%rip), %rsi    # 0x2b1b48
leaq 0x1972f9(%rip), %rdx    # 0x2b1b4b
callq 0x11b01e
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1972e5(%rip), %rsi    # 0x2b1b4c
leaq 0x1972e1(%rip), %rdx    # 0x2b1b4f
leaq 0x28(%rsp), %rdi
callq 0x11b01e
leaq 0x2e8(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x1290f0
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x1290f0
leaq 0x78(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x1972a6(%rip), %rsi    # 0x2b1b50
leaq 0x1974d3(%rip), %rdx    # 0x2b1d84
leaq 0x68(%rsp), %rdi
callq 0x11b01e
leaq 0x2c8(%rsp), %r12
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0x117520
leaq 0x2a8(%rsp), %rsi
leaq 0x1500(%rsp), %rdi
callq 0x122000
leaq 0x1508(%rsp), %rcx
cmpq %rax, %rcx
jne 0x11a9a4
leaq 0xbd0(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x120d66
testb %al, %al
je 0x11a9a4
leaq 0x2a8(%rsp), %rsi
movq 0x88(%rsi), %rax
movq %rax, %rcx
subq 0x68(%rsi), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq 0x60(%rsi), %rax
movq 0x70(%rsi), %rdx
subq 0x78(%rsi), %rdx
subq 0x50(%rsi), %rax
sarq $0x5, %rdx
sarq $0x5, %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x8, %rcx
addq 0x1530(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
addq %rcx, %rdi
callq 0x121c24
movq (%rax), %r12
leaq 0x2a8(%rsp), %rsi
leaq 0x1500(%rsp), %rdi
callq 0x121f84
movq %r12, %rdi
movq %rax, %rsi
callq 0x121ca0
movq 0x68(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11a9bb
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
leaq 0x18(%rsp), %rbp
je 0x11a9d7
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11a9ee
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x117090
movq %r15, %rdi
callq 0x128f44
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x11aa1b
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x2a8(%rsp), %rdi
leaq 0x2b8(%rsp), %rax
cmpq %rax, %rdi
je 0x11aa40
movq 0x2b8(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x11aa5d
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x88(%rsp), %rdi
movq %r14, (%rdi)
leaq 0x197316(%rip), %rsi    # 0x2b1d85
leaq 0x19731c(%rip), %rdx    # 0x2b1d92
callq 0x11b01e
leaq 0x2a8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x11b790
leaq 0x8(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x1970a9(%rip), %rsi    # 0x2b1b48
leaq 0x1970a5(%rip), %rdx    # 0x2b1b4b
callq 0x11b01e
leaq 0x2e8(%rsp), %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x1290f0
leaq 0x28(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x1972c4(%rip), %rsi    # 0x2b1d93
leaq 0x1975a2(%rip), %rdx    # 0x2b2078
callq 0x11b01e
leaq 0x2c8(%rsp), %r12
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x117520
leaq 0x2a8(%rsp), %rsi
leaq 0x1500(%rsp), %rdi
callq 0x122000
leaq 0x1508(%rsp), %rcx
cmpq %rax, %rcx
jne 0x11abc4
leaq 0xbd0(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x120d66
testb %al, %al
je 0x11abc4
leaq 0x2a8(%rsp), %rsi
movq 0x88(%rsi), %rax
movq %rax, %rcx
subq 0x68(%rsi), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq 0x60(%rsi), %rax
movq 0x70(%rsi), %rdx
subq 0x78(%rsi), %rdx
subq 0x50(%rsi), %rax
sarq $0x5, %rdx
sarq $0x5, %rax
leaq (%rcx,%rcx,2), %rcx
shlq $0x8, %rcx
addq 0x1530(%rsp), %rcx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
addq %rcx, %rdi
callq 0x121c24
movq (%rax), %r12
leaq 0x2a8(%rsp), %rsi
leaq 0x1500(%rsp), %rdi
callq 0x121f84
movq %r12, %rdi
movq %rax, %rsi
callq 0x121ca0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11abdb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11abf2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x117090
movq %r15, %rdi
callq 0x128f44
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x11ac1f
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x2a8(%rsp), %rdi
leaq 0x2b8(%rsp), %rax
cmpq %rax, %rdi
je 0x11ac44
movq 0x2b8(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x11ac61
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x8(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x197409(%rip), %rsi    # 0x2b2079
leaq 0x197632(%rip), %rdx    # 0x2b22a9
callq 0x11b01e
leaq 0x28(%rsp), %rdi
callq 0x11b86a
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
je 0x11acb8
sarq $0x3, %rcx
movq (%rsp), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
cmpq %rbx, %rax
je 0x11acc5
cmpq (%rax), %rdx
je 0x11acc5
addq $0x8, %rax
decq %rcx
jne 0x11aca5
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x129464
leaq 0x88(%rsp), %rdi
movl $0x7f, %esi
callq 0x11b8f6
leaq 0x2a8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x11b9f6
leaq 0x188(%rsp), %rdi
callq 0x12964a
leaq 0x158(%rsp), %rdi
callq 0x12964a
leaq 0x128(%rsp), %rdi
callq 0x12964a
leaq 0xf8(%rsp), %rdi
callq 0x12964a
leaq 0xc8(%rsp), %rdi
callq 0x12964a
leaq 0x98(%rsp), %rdi
callq 0x12964a
leaq 0x2a8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x11c21a
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
leaq 0x2a8(%rsp), %rdi
callq 0x11cdb6
leaq 0x28(%rsp), %rdi
callq 0x11d078
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11ad8e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0xbd0(%rsp), %rdi
callq 0x11d0c6
movq %rsp, %rdi
callq 0x11d128
leaq 0x298(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11adc4
movq 0x298(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x28f9bd(%rip), %rbx    # 0x3aa788
leaq 0x270(%rsp), %rax
movq %rbx, -0x30(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11adf0
movq 0x270(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x230(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11ae11
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x208(%rsp), %rax
movq %rbx, -0x30(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11ae36
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11ae4d
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x117090
addq $0x15b8, %rsp           # imm = 0x15B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11ae76
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x11c1d2
jmp 0x11af16
movq %rax, %rbx
jmp 0x11af16
movq %rax, %rbx
jmp 0x11af20
jmp 0x11aeb5
jmp 0x11ae97
jmp 0x11ae97
jmp 0x11aea5
jmp 0x11aead
jmp 0x11aeb5
jmp 0x11af38
movq %rax, %rbx
jmp 0x11af52
jmp 0x11aea5
jmp 0x11aead
jmp 0x11aeb5
movq %rax, %rbx
jmp 0x11af6e
movq %rax, %rbx
jmp 0x11af7b
movq %rax, %rbx
jmp 0x11af98
jmp 0x11aeee
jmp 0x11aeee
jmp 0x11aec5
jmp 0x11aeee
movq %rax, %rbx
movq 0xbd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x11afa5
movq 0xbe0(%rsp), %rsi
incq %rsi
callq 0x117090
jmp 0x11afa5
movq %rax, %rbx
jmp 0x11afa5
movq %rax, %rbx
jmp 0x11afad
movq %rax, %rbx
jmp 0x11afba
movq %rax, %rbx
leaq 0x2a8(%rsp), %rdi
callq 0x11cdb6
leaq 0x28(%rsp), %rdi
callq 0x11d078
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11af98
movq 0x18(%rsp), %rsi
jmp 0x11af90
jmp 0x11af38
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11af52
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x117090
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11af6e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0x2a8(%rsp), %rdi
callq 0x11b82a
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x11af98
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x117090
leaq 0xbd0(%rsp), %rdi
callq 0x11d0c6
movq %rsp, %rdi
callq 0x11d128
leaq 0x1d8(%rsp), %rdi
callq 0x11d1be
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x11afd1
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x117090
movq %rbx, %rdi
callq 0x1172e0
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11af3b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x117090
jmp 0x11af3b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x11af61
jmp 0x11af6e