#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 EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int getchar();
FILE *create_temporary_file(void) {
  FILE *temporary_file = fopen("/tmp/tail_temporary_file", "w+");
  int character;
  while ((character = getchar()) != EOF)
    (void)fputc(character, temporary_file);
  return temporary_file;
}


x86 assembly (clang, -O0):
<create_temporary_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xed3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     1179 <create_temporary_file+0x49>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
jmp    114f <create_temporary_file+0x1f>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_temporary_file>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
lea    0xed7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e90(%rip),%r14
cmp    (%r14),%eax
je     1176 <create_temporary_file+0x46>
nopl   (%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
jne    1160 <create_temporary_file+0x30>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"/tmp/tail_temporary_file\00"
@.str.1 = [3 x i8] c"w+\00"
@EOF = global i32 0
define i32* @create_temporary_file() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
br label %4
4: ; preds = %8, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i32, i32* %2
%10 = load i32*, i32** %1
%11 = call i32 @fputc(i32 %9, i32* %10)
br label %4
12: ; preds = %4
%13 = load i32*, i32** %1
ret i32* %13
}

LLVM IR (-O2):
@.str = [25 x i8] c"/tmp/tail_temporary_file\00"
@.str.1 = [3 x i8] c"w+\00"
@EOF = global i32 0
define noalias i32* @create_temporary_file() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %8, %5 ], [ %2, %0 ]
%7 = tail call i32 @fputc(i32 %6, i32* %1)
%8 = tail call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %5
11: ; preds = %5, %0
ret i32* %1
}