#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int L_tmpnam;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ *tmpfile();
char *tmpnam(char *);
int main(int argc, char *argv[]) {
  char file[L_tmpnam];
  char line[1024];
  FILE *fp;
  printf("%s\n", tmpnam(NULL));
  tmpnam(file);
  printf("%s\n", file);
  if ((fp = tmpfile()) == NULL) {
    perror("tmpfile");
    return -1;
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x438(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <tmpnam@plt>
mov    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x438(%rbp),%rdi
call   1070 <tmpnam@plt>
mov    -0x438(%rbp),%rsi
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <tmpfile@plt>
mov    %rax,-0x428(%rbp)
cmp    $0x0,%rax
jne    1209 <main+0xb9>
lea    0xe16(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x42c(%rbp)
jmp    1226 <main+0xd6>
mov    -0x428(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x42c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %r14d,%r14d
xor    %edi,%edi
call   1070 <tmpnam@plt>
lea    0xe7b(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <tmpnam@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <tmpfile@plt>
test   %rax,%rax
je     11c5 <main+0x75>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe38(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%r14d
jmp    11b7 <main+0x67>

LLVM IR (-O0):
@L_tmpnam = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [8 x i8] c"tmpfile\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [1024 x i8]
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @L_tmpnam
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = call i8* @tmpnam(i8* null)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i8* @tmpnam(i8* %14)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%19 = call i32* (...) @tmpfile()
store i32* %19, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %10
br label %26
23: ; preds = %2
%24 = load i32*, i32** %9
%25 = call i32 @fclose(i32* %24)
store i32 0, i32* %3
store i32 1, i32* %10
br label %26
26: ; preds = %23, %21
%27 = load i8*, i8** %6
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@L_tmpnam = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [8 x i8] c"tmpfile\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @L_tmpnam
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i8* @tmpnam(i8* null)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* @tmpnam(i8* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = call i32* (...) @tmpfile()
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %2
%15 = call i32 @fclose(i32* %10)
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ -1, %12 ], [ 0, %14 ]
ret i32 %17
}