// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
leaq 0x6be0(%rip), %rdi      # 0xd084
callq 0x3280
testq %rax, %rax
je 0x65c3
callq 0x671c
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0xada8(%rip), %rsi      # 0x11270
movq 0xada9(%rip), %rdx      # 0x11278
addq %rsi, %rdx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0xc10e
leaq 0x6b98(%rip), %rsi      # 0xd07e
movq %r14, %rdi
callq 0x3420
movq 0xad5b(%rip), %rsi      # 0x11250
movq 0xad5c(%rip), %rdx      # 0x11258
leaq 0x20(%rsp), %rdi
callq 0x30a0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x652c
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x6533
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x6562
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3210
movq (%rsp), %rdi
leaq 0x6d45(%rip), %rsi      # 0xd2b2
callq 0x3090
movq %rax, (%rbx)
testq %rax, %rax
je 0x6625
movl $0x0, 0xc(%rbx)
movb $0x1, 0x8(%rbx)
movq $0x0, 0x38(%rbx)
movq 0x30(%rbx), %rax
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x3ba6
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x65b6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3210
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, 0x8(%rbx)
movl $0x10, %edi
callq 0x3120
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6aa8(%rip), %rsi      # 0xd08c
leaq 0x6abc(%rip), %rdx      # 0xd0a7
movq %rsp, %rdi
callq 0xc19e
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x32a0
leaq 0xa758(%rip), %rax      # 0x10d60
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xa724(%rip), %rsi      # 0x10d38
movq 0xa99d(%rip), %rdx      # 0x10fb8
movq %r14, %rdi
callq 0x33c0
jmp 0x6683
movb $0x0, 0x8(%rbx)
movl $0x10, %edi
callq 0x3120
movq %rax, %r14
leaq 0x20(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x6c6f(%rip), %rsi      # 0xd2b4
leaq 0x6c8b(%rip), %rdx      # 0xd2d7
callq 0xc19e
movb $0x1, %bpl
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x32a0
leaq 0xa6f8(%rip), %rax      # 0x10d60
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xa6c4(%rip), %rsi      # 0x10d38
movq 0xa93d(%rip), %rdx      # 0x10fb8
movq %r14, %rdi
callq 0x33c0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x66a5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3210
jmp 0x66a5
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x66e7
movq %r14, %rdi
callq 0x3190
jmp 0x66e7
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x66d5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3210
jmp 0x66d5
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x6713
movq %r14, %rdi
callq 0x3190
jmp 0x6713
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x6713
movq 0x10(%rsp), %rsi
jmp 0x670b
jmp 0x66f9
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x6713
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x33f0
nop