// File: /workspace/github_cpp_makefile_star2_O2/orbitcowboy[P]gnuplot-cpp/./gnuplot_i.hpp
// Function: Gnuplot::init()
void Gnuplot::init(void)
{
    // char * getenv ( const char * name );  get value of environment variable
    // Retrieves a C string containing the value of the environment variable
    // whose name is specified as argument.  If the requested variable is not
    // part of the environment list, the function returns a NULL pointer.
#if ( defined(unix) || defined(__unix) || defined(__unix__) ) && !defined(__APPLE__)
    if (getenv("DISPLAY") == nullptr)
    {
        valid = false;
        throw GnuplotException("Can't find DISPLAY variable");
    }
#endif

    // if gnuplot not available
    if (!Gnuplot::get_program_path())
    {
        valid = false;
        throw GnuplotException("Can't find gnuplot");
    }

    // open pipe
    std::string tmp = Gnuplot::m_sGNUPlotPath + "/" +
                      Gnuplot::m_sGNUPlotFileName;

    // FILE *popen(const char *command, const char *mode);
    // The popen() function shall execute the command specified by the string
    // command, create a pipe between the calling program and the executed
    // command, and return a pointer to a stream that can be used to either read
    // from or write to the pipe.
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
    gnucmd = _popen(tmp.c_str(), "w");
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    gnucmd = popen(tmp.c_str(), "w");
#endif

    // popen() shall return a pointer to an open stream that can be used to read
    // or write to the pipe.  Otherwise, it shall return a null pointer and may
    // set errno to indicate the error.
    if (!gnucmd)
    {
        valid = false;
        throw GnuplotException("Couldn't open connection to gnuplot");
    }

    nplots = 0;
    valid = true;
    smooth.clear();

    //set terminal type
    showonscreen();

    return;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0x4a42(%rip), %rdi      # 0xa084
callq 0x3260
testq %rax, %rax
je 0x56d6
callq 0x57d4
leaq 0x9c14(%rip), %rsi      # 0xf270
leaq 0x4a1b(%rip), %rdx      # 0xa07e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x7d24
leaq 0x9bd9(%rip), %rdx      # 0xf250
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x7d05
leaq 0x10(%rsp), %rdi
callq 0x3448
movq 0x30(%rsp), %rdi
leaq 0x4c18(%rip), %rsi      # 0xa2b2
callq 0x3090
movq %rax, (%rbx)
testq %rax, %rax
je 0x5725
andl $0x0, 0xc(%rbx)
movb $0x1, 0x8(%rbx)
andq $0x0, 0x38(%rbx)
movq 0x30(%rbx), %rax
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x3960
leaq 0x30(%rsp), %rdi
callq 0x3448
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movb $0x0, 0x8(%rbx)
pushq $0x10
popq %rdi
callq 0x3110
movq %rax, %r14
leaq 0x49a0(%rip), %rsi      # 0xa08c
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x7cca
movb $0x1, %bpl
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x7d5c
xorl %ebp, %ebp
leaq 0x9634(%rip), %rsi      # 0xed48
movq 0x989d(%rip), %rdx      # 0xefb8
movq %r14, %rdi
callq 0x3390
jmp 0x5772
movb $0x0, 0x8(%rbx)
pushq $0x10
popq %rdi
callq 0x3110
movq %rax, %r14
leaq 0x4b79(%rip), %rsi      # 0xa2b4
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x7cca
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x7d5c
xorl %ebp, %ebp
leaq 0x95e5(%rip), %rsi      # 0xed48
movq 0x984e(%rip), %rdx      # 0xefb8
movq %r14, %rdi
callq 0x3390
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3448
testb %bpl, %bpl
jne 0x5789
jmp 0x57b7
movq %rax, %rbx
movq %r14, %rdi
callq 0x3190
jmp 0x57b7
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3448
testb %bpl, %bpl
jne 0x57aa
jmp 0x57cb
movq %rax, %rbx
movq %r14, %rdi
callq 0x3190
jmp 0x57cb
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x57c6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3448
movq %rbx, %rdi
callq 0x33b0
nop