// File: /workspace/github_cpp_makefile_star2_O2/orbitcowboy[P]gnuplot-cpp/./gnuplot_i.hpp
// Function: Gnuplot::get_program_path()
bool Gnuplot::get_program_path(void)
{
    //
    // first look in m_sGNUPlotPath for Gnuplot
    //
    std::string tmp = Gnuplot::m_sGNUPlotPath + "/" +
                      Gnuplot::m_sGNUPlotFileName;

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
    if ( Gnuplot::file_exists(tmp, 0) ) // check existence
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    if ( Gnuplot::file_exists(tmp, 1) ) // check existence and execution permission
#endif
    {
        return true;
    }


    //
    // second look in PATH for Gnuplot
    // Retrieves a C string containing the value of environment variable PATH
    const char * const path = getenv("PATH");

    if (path == nullptr)
    {
        throw GnuplotException("Path is not set");
    }
    std::list<std::string> ls;

    //split path (one long string) into list ls of strings
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
    stringtok(ls, path, ";");
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    stringtok(ls, path, ":");
#endif

    // scan list for Gnuplot program files
    for (std::list<std::string>::const_iterator i = ls.cbegin();
            i != ls.cend(); ++i)
    {
        tmp = (*i) + "/" + Gnuplot::m_sGNUPlotFileName;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
        if ( Gnuplot::file_exists(tmp, 0) ) // check existence
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
        if ( Gnuplot::file_exists(tmp, 1) ) // check existence and execution permission
#endif
        {
            Gnuplot::m_sGNUPlotPath = *i; // set m_sGNUPlotPath
            return true;
        }
    }

    tmp = "Can't find gnuplot neither in PATH nor in \"" +
          Gnuplot::m_sGNUPlotPath + "\"";
    throw GnuplotException(tmp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq 0x9a87(%rip), %rsi      # 0xf270
leaq 0x488e(%rip), %rdx      # 0xa07e
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x7d24
leaq 0x9a4e(%rip), %rdx      # 0xf250
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x7d05
movq %rsp, %rdi
callq 0x3448
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x36ae
testb %al, %al
jne 0x5909
leaq 0x4aa5(%rip), %rdi      # 0xa2d8
callq 0x3260
testq %rax, %rax
je 0x59a3
leaq 0x60(%rsp), %rcx
movq %rcx, 0x8(%rcx)
movq %rcx, (%rcx)
andq $0x0, 0x10(%rcx)
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
movq %rax, %rsi
callq 0x7cca
leaq 0x4989(%rip), %rdx      # 0xa1f2
leaq 0x60(%rsp), %r13
movq %rsp, %rsi
movq %r13, %rdi
callq 0x7e1d
movq %rsp, %r14
movq %r14, %rdi
callq 0x3448
leaq 0x20(%rsp), %r12
leaq 0x40(%rsp), %rbp
movq %r13, %rbx
movq (%r13), %r13
cmpq %rbx, %r13
je 0x5924
leaq 0x10(%r13), %r15
movq %r12, %rdi
movq %r15, %rsi
leaq 0x47cf(%rip), %rdx      # 0xa07e
callq 0x7d24
movq %r14, %rdi
movq %r12, %rsi
leaq 0x998f(%rip), %rdx      # 0xf250
callq 0x7d05
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3270
movq %r14, %rdi
callq 0x3448
movq %r12, %rdi
callq 0x3448
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0x36ae
testb %al, %al
je 0x5891
leaq 0x9979(%rip), %rdi      # 0xf270
movq %r15, %rsi
callq 0x3140
leaq 0x60(%rsp), %rdi
callq 0x8cf0
leaq 0x40(%rsp), %rdi
callq 0x3448
movb $0x1, %al
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x49c2(%rip), %rsi      # 0xa2ed
leaq 0x993e(%rip), %rdx      # 0xf270
leaq 0x20(%rsp), %rdi
callq 0x7da7
leaq 0x4a4f(%rip), %rdx      # 0xa392
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x7ef7
leaq 0x40(%rsp), %rbx
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3270
movq %r14, %rdi
callq 0x3448
leaq 0x20(%rsp), %rdi
callq 0x3448
pushq $0x10
popq %rdi
callq 0x3110
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x7d5c
leaq 0x93b6(%rip), %rsi      # 0xed48
movq 0x961f(%rip), %rdx      # 0xefb8
movq %r14, %rdi
callq 0x3390
jmp 0x59e8
pushq $0x10
popq %rdi
callq 0x3110
movq %rax, %r14
leaq 0x4928(%rip), %rsi      # 0xa2dd
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x7cca
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x7d5c
xorl %ebp, %ebp
leaq 0x936f(%rip), %rsi      # 0xed48
movq 0x95d8(%rip), %rdx      # 0xefb8
movq %r14, %rdi
callq 0x3390
movq %rax, %rbx
movq %rsp, %rdi
callq 0x3448
testb %bpl, %bpl
jne 0x59fd
jmp 0x5a51
movq %rax, %rbx
movq %r14, %rdi
callq 0x3190
jmp 0x5a51
jmp 0x5a44
movq %rax, %rbx
movq %rsp, %rdi
jmp 0x5a3d
jmp 0x5a44
movq %rax, %rbx
jmp 0x5a51
movq %rax, %rbx
movq %rsp, %rdi
jmp 0x5a56
jmp 0x5a44
movq %rax, %rbx
movq %r14, %rdi
callq 0x3190
jmp 0x5a47
jmp 0x5a35
jmp 0x5a44
jmp 0x5a44
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3448
jmp 0x5a47
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x8cf0
leaq 0x40(%rsp), %rdi
callq 0x3448
movq %rbx, %rdi
callq 0x33b0
nop