#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int asprintf(char **, char *, char const *, char const *);
int /*<<< orphan*/ close(int);
int mkstemp(char *);
int smf_core_gen_queue_file(const char *queue_dir, char **tempname,
                            const char *sid) {
  int fd;
  if (asprintf(&(*tempname), "%s/%s.XXXXXX", queue_dir, sid) == -1)
    return -1;
  if ((fd = mkstemp(*tempname)) == -1)
    return -1;
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<smf_core_gen_queue_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xea9(%rip),%rsi
call   1050 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    1171 <smf_core_gen_queue_file+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <smf_core_gen_queue_file+0x74>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <mkstemp@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1195 <smf_core_gen_queue_file+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <smf_core_gen_queue_file+0x74>
mov    -0x24(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smf_core_gen_queue_file>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rcx
mov    %rsi,%rbx
mov    %rdi,%rdx
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1050 <asprintf@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     116b <smf_core_gen_queue_file+0x3b>
mov    (%rbx),%rdi
call   1040 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     116b <smf_core_gen_queue_file+0x3b>
mov    %eax,%edi
call   1030 <close@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s/%s.XXXXXX\00"
define i32 @smf_core_gen_queue_file(i8* %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
%9 = load i8**, i8*** %6
%10 = load i8*, i8** %5
%11 = load i8*, i8** %7
%12 = call i32 @asprintf(i8** %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %24
15: ; preds = %3
%16 = load i8**, i8*** %6
%17 = load i8*, i8** %16
%18 = call i32 @mkstemp(i8* %17)
store i32 %18, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %4
br label %24
21: ; preds = %15
%22 = load i32, i32* %8
%23 = call i32 @close(i32 %22)
store i32 0, i32* %4
br label %24
24: ; preds = %21, %20, %14
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s/%s.XXXXXX\00"
define i32 @smf_core_gen_queue_file(i8* %0, i8** %1, i8* %2) {
%4 = tail call i32 @asprintf(i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = load i8*, i8** %1
%8 = tail call i32 @mkstemp(i8* %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @close(i32 %8)
br label %12
12: ; preds = %6, %3, %10
%13 = phi i32 [ 0, %10 ], [ -1, %3 ], [ -1, %6 ]
ret i32 %13
}