// File: /workspace/github_cpp_makefile_star2_O1/orbitcowboy[P]gnuplot-cpp/./gnuplot_i.hpp
// Function: Gnuplot::create_tmpfile[abi:cxx11](std::basic_ofstream<char, std::char_traits<char>>&)
std::string Gnuplot::create_tmpfile(std::ofstream &tmp)
{
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
    char name[15] = {'g', 'n', 'u', 'p', 'l', 'o', 't', 'i', 'X', 'X', 'X', 'X', 'X', 'X', '\0'}; //tmp file in working directory
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    char name[20] = {'/', 't', 'm', 'p', '/', 'g', 'n', 'u', 'p', 'l', 'o', 't', 'i', 'X', 'X', 'X', 'X', 'X', 'X', '\0'}; // tmp file in /tmp
#endif

    //
    // check if maximum number of temporary files reached
    //
    if (Gnuplot::tmpfile_num == GP_MAX_TMP_FILES - 1)
    {
        std::ostringstream except;
        except << "Maximum number of temporary files reached ("
               << GP_MAX_TMP_FILES << "): cannot open more files" << std::endl;

        throw GnuplotException( except.str() );
    }

    // int mkstemp(char *name);
    // shall replace the contents of the string pointed to by "name" by a unique
    // filename, and return a file descriptor for the file open for reading and
    // writing.  Otherwise, -1 shall be returned if no suitable file could be
    // created.  The string in template should look like a filename with six
    // trailing 'X' s; mkstemp() replaces each 'X' with a character from the
    // portable filename character set.  The characters are chosen such that the
    // resulting name does not duplicate the name of an existing file at the
    // time of a call to mkstemp()


    //
    // open temporary files for output
    //
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__)
    if (_mktemp(name) == nullptr)
#elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    int tmpfd;
    if ((tmpfd = mkstemp(name)) == -1)
#endif
    {
        std::ostringstream except;
        except << "Cannot create temporary file \"" << name << "\"";
        throw GnuplotException(except.str());
    }
#if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
    (void)close(tmpfd);
#endif

    tmp.open(name);
    if (tmp.bad())
    {
        std::ostringstream except;
        except << "Cannot create temporary file \"" << name << "\"";
        throw GnuplotException(except.str());
    }

    //
    // Save the temporary filename
    //
    tmpfile_list.push_back(name);
    Gnuplot::tmpfile_num++;

    return name;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movaps 0x78ea(%rip), %xmm0     # 0xda20
movaps %xmm0, (%rsp)
movl $0x585858, 0x10(%rsp)   # imm = 0x585858
cmpl $0x3f, 0xb103(%rip)     # 0x1124c
je 0x621b
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %rdi
callq 0x30b0
cmpl $-0x1, %eax
je 0x62bd
movl %eax, %edi
callq 0x3430
movq %rsp, %rsi
movq %r15, %rdi
movl $0x10, %edx
callq 0x3040
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x1, 0x20(%r15,%rax)
jne 0x6362
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rsp, %r15
movq %r15, %rdi
callq 0x3100
leaq (%rsp,%rax), %rdx
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0xc19e
addq $0x50, %r14
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0xc22e
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x61e1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3210
incl 0xb065(%rip)            # 0x1124c
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq %rsp, %r14
movq %r14, %rdi
callq 0x3100
leaq (%rsp,%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc19e
movq %rbx, %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x32b0
leaq 0x7176(%rip), %rsi      # 0xd3a5
movl $0x2b, %edx
movq %rbx, %rdi
callq 0x3250
leaq 0x38(%rsp), %rdi
movl $0x40, %esi
callq 0x33d0
movq %rax, %rbx
leaq 0x717c(%rip), %rsi      # 0xd3d1
movl $0x19, %edx
movq %rax, %rdi
callq 0x3250
movq %rbx, %rdi
callq 0x3110
movl $0x10, %edi
callq 0x3120
movq %rax, %r14
leaq 0x40(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0x3340
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x32a0
leaq 0xaac3(%rip), %rax      # 0x10d60
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xaa8f(%rip), %rsi      # 0x10d38
movq 0xad08(%rip), %rdx      # 0x10fb8
movq %r14, %rdi
callq 0x33c0
jmp 0x6402
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x32b0
leaq 0x711a(%rip), %rsi      # 0xd3eb
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x3250
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x3100
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3250
leaq 0x7092(%rip), %rsi      # 0xd392
leaq 0x38(%rsp), %rdi
movl $0x1, %edx
callq 0x3250
movl $0x10, %edi
callq 0x3120
movq %rax, %r14
leaq 0x40(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0x3340
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x32a0
leaq 0xaa1e(%rip), %rax      # 0x10d60
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xa9ea(%rip), %rsi      # 0x10d38
movq 0xac63(%rip), %rdx      # 0x10fb8
movq %r14, %rdi
callq 0x33c0
jmp 0x6402
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x32b0
leaq 0x7075(%rip), %rsi      # 0xd3eb
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x3250
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x3100
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3250
leaq 0x6fed(%rip), %rsi      # 0xd392
leaq 0x38(%rsp), %rdi
movl $0x1, %edx
callq 0x3250
movl $0x10, %edi
callq 0x3120
movq %rax, %r14
leaq 0x40(%rsp), %rsi
leaq 0x18(%rsp), %rdi
callq 0x3340
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x32a0
leaq 0xa979(%rip), %rax      # 0x10d60
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xa945(%rip), %rsi      # 0x10d38
movq 0xabbe(%rip), %rdx      # 0x10fb8
movq %r14, %rdi
callq 0x33c0
jmp 0x640a
jmp 0x642a
jmp 0x640a
jmp 0x642a
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6430
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3210
jmp 0x6430
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x6446
movq %r14, %rdi
callq 0x3190
jmp 0x6446
jmp 0x6443
jmp 0x6443
movq %rax, %rbx
movq 0xab63(%rip), %rsi      # 0x10fb0
leaq 0x38(%rsp), %rdi
callq 0x3140
leaq 0xa8(%rsp), %rdi
callq 0x30c0
jmp 0x6485
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x6485
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3210
jmp 0x6485
movq %rax, %rbx
movq %rbx, %rdi
callq 0x33f0
nop