#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*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ *tmpnam(char *);
int main(int argc, char *argv[]) {
  char tmp_pathname[L_tmpnam];
  FILE *in;
  if (tmpnam(tmp_pathname) == NULL) {
    perror(tmp_pathname);
    return 0;
  }
  printf("Using temp file '%s' \n", tmp_pathname);
  if ((in = fopen(tmp_pathname, "r")) == NULL) {
    perror(tmp_pathname);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
call   1060 <tmpnam@plt>
cmp    $0x0,%rax
jne    11ad <main+0x6d>
mov    -0x38(%rbp),%rdi
call   1050 <perror@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1205 <main+0xc5>
mov    -0x38(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11f7 <main+0xb7>
mov    -0x38(%rbp),%rdi
call   1050 <perror@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1205 <main+0xc5>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%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   %rbx
push   %rax
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1060 <tmpnam@plt>
test   %rax,%rax
je     1199 <main+0x59>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <fopen@plt>
test   %rax,%rax
je     1199 <main+0x59>
xor    %eax,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1050 <perror@plt>
jmp    1190 <main+0x50>

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

LLVM IR (-O2):
@L_tmpnam = global i32 0
@.str = [23 x i8] c"Using temp file '%s' \0A\00"
@.str.1 = [2 x i8] c"r\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 = call i32* @tmpnam(i8* %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %8, %2
%13 = call i32 @perror(i8* %5)
br label %14
14: ; preds = %12, %8
ret i32 0
}