#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 /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ *tmpfile();
void tmpfile_method(void) {
  printf("Entered tmpfile_method()\n");
  FILE *tmp_file = tmpfile();
  if (tmp_file == NULL) {
    perror("Couldn't create temporary file");
  } else {
    printf("Created temporary file\n");
  }
  printf("Leaving tmpfile_method()\n");
}


x86 assembly (clang, -O0):
<tmpfile_method>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <tmpfile@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116b <tmpfile_method+0x3b>
lea    0xeb9(%rip),%rdi
call   1050 <perror@plt>
jmp    1177 <tmpfile_method+0x47>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tmpfile_method>:
push   %rax
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tmpfile@plt>
test   %rax,%rax
je     1162 <tmpfile_method+0x32>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe97(%rip),%rdi
call   1050 <perror@plt>
jmp    1155 <tmpfile_method+0x25>

LLVM IR (-O0):
@.str = [26 x i8] c"Entered tmpfile_method()\0A\00"
@.str.1 = [31 x i8] c"Couldn't create temporary file\00"
@.str.2 = [24 x i8] c"Created temporary file\0A\00"
@.str.3 = [26 x i8] c"Leaving tmpfile_method()\0A\00"
define void @tmpfile_method() {
%1 = alloca i32*
%2 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%3 = call i32* (...) @tmpfile()
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Couldn't create temporary file\00"
@str = [25 x i8] c"Entered tmpfile_method()\00"
@str.4 = [23 x i8] c"Created temporary file\00"
@str.5 = [25 x i8] c"Leaving tmpfile_method()\00"
define void @tmpfile_method() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* (...) @tmpfile()
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
ret void
}