#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 _error(char const *, char *, int);
char *mktemp(char *);
int /*<<< orphan*/ printf(char *, char const *);
int _mktemp(char const *progname) {
  char buf[] = "/tmp/stdlib.XXXXXX";
  printf("%s: Testing mktemp()\n", progname);
  return (mktemp(buf) == buf) ? 0 : _error(progname, "mktemp", 1);
}


x86 assembly (clang, -O0):
<_mktemp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xeaf(%rip),%al
mov    %al,-0xe(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <mktemp@plt>
lea    -0x20(%rbp),%rcx
cmp    %rcx,%rax
jne    1196 <_mktemp+0x66>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11ae <_mktemp+0x7e>
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x1,%edx
call   1040 <_error@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mktemp>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x585858,0xf(%rsp)
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <mktemp@plt>
cmp    %r14,%rax
je     1182 <_mktemp+0x52>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1040 <_error@plt>
jmp    1184 <_mktemp+0x54>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const._mktemp.buf = [19 x i8] c"/tmp/stdlib.XXXXXX\00"
@.str = [22 x i8] c"%s: Testing mktemp()\0A\00"
@.str.1 = [7 x i8] c"mktemp\00"
define i32 @_mktemp(i8* %0) {
%2 = alloca i8*
%3 = alloca [19 x i8]
store i8* %0, i8** %2
%4 = bitcast [19 x i8]* %3 to i8*
%5 = load i8*, i8** %2
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%8 = call i8* @mktemp(i8* %7)
%9 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%10 = icmp eq i8* %8, %9
br i1 %10, label %11, label %12
11: ; preds = %1
br label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @_error(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %15
15: ; preds = %12, %11
%16 = phi i32 [ 0, %11 ], [ %14, %12 ]
ret i32 %16
}

LLVM IR (-O2):
@__const._mktemp.buf = [19 x i8] c"/tmp/stdlib.XXXXXX\00"
@.str = [22 x i8] c"%s: Testing mktemp()\0A\00"
@.str.1 = [7 x i8] c"mktemp\00"
define i32 @_mktemp(i8* %0) {
%2 = alloca [19 x i8]
%3 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i8* @mktemp(i8* %3)
%6 = icmp eq i8* %5, %3
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @_error(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %9
9: ; preds = %1, %7
%10 = phi i32 [ %8, %7 ], [ 0, %1 ]
ret i32 %10
}