// File: /workspace/github_c_makefile_star2_O0/msteveb[P]autosetup/./jimsh0.c
// Function: Jim_MakeTempFile
int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template, int unlink_file)
{
    int fd;
    mode_t mask;
    Jim_Obj *filenameObj;

    if (filename_template == NULL) {
        const char *tmpdir = getenv("TMPDIR");
        if (tmpdir == NULL || *tmpdir == '\0' || access(tmpdir, W_OK) != 0) {
            tmpdir = "/tmp/";
        }
        filenameObj = Jim_NewStringObj(interp, tmpdir, -1);
        if (tmpdir[0] && tmpdir[strlen(tmpdir) - 1] != '/') {
            Jim_AppendString(interp, filenameObj, "/", 1);
        }
        Jim_AppendString(interp, filenameObj, "tcl.tmp.XXXXXX", -1);
    }
    else {
        filenameObj = Jim_NewStringObj(interp, filename_template, -1);
    }


#ifdef HAVE_UMASK
    mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
#endif
#ifdef HAVE_MKSTEMP
    fd = mkstemp(filenameObj->bytes);
#else
    if (mktemp(filenameObj->bytes) == NULL) {
        fd = -1;
    }
    else {
        fd = open(filenameObj->bytes, O_RDWR | O_CREAT | O_TRUNC);
    }
#endif
#ifdef HAVE_UMASK
    umask(mask);
#endif
    if (fd < 0) {
        Jim_SetResultErrno(interp, Jim_String(filenameObj));
        Jim_FreeNewObj(interp, filenameObj);
        return -1;
    }
    if (unlink_file) {
        remove(Jim_String(filenameObj));
    }

    Jim_SetResult(interp, filenameObj);
    return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1674a
leaq 0x24dca(%rip), %rdi     # 0x3b45f
callq 0x6030
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x166c4
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x166c4
movq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x6440
cmpl $0x0, %eax
je 0x166cf
leaq 0x24d9b(%rip), %rax     # 0x3b466
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1672f
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x6190
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0x1672f
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x24d45(%rip), %rdx     # 0x3b46a
movl $0x1, %ecx
callq 0x8db0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x24d2e(%rip), %rdx     # 0x3b46c
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x8db0
jmp 0x16760
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7990
movq %rax, -0x30(%rbp)
movl $0x7f, %edi
callq 0x6320
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x62d0
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %edi
callq 0x6320
cmpl $0x0, -0x20(%rbp)
jge 0x167bd
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7960
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x16620
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x7a10
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16821
cmpl $0x0, -0x1c(%rbp)
je 0x167d4
movq -0x30(%rbp), %rdi
callq 0x7960
movq %rax, %rdi
callq 0x60a0
jmp 0x167d6
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl 0x10(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x10(%rcx)
cmpl $0x0, %eax
jg 0x16810
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7a10
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)