#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*/ SEEK_SET;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *tmpfile();
FILE *createTemporaryFile(char **line_buffer, size_t *length_of_line_buffer) {
  FILE *temporaryFile;
  temporaryFile = tmpfile();
  if (temporaryFile) {
    while (getline(line_buffer, length_of_line_buffer, stdin) != -1) {
      fprintf(temporaryFile, "%s", *line_buffer);
    }
    if (fseek(temporaryFile, 0, SEEK_SET) != 0) {
      return NULL;
    }
  }
  return temporaryFile;
}


x86 assembly (clang, -O0):
<createTemporaryFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <tmpfile@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d6 <createTemporaryFile+0x96>
jmp    116b <createTemporaryFile+0x2b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11a6 <createTemporaryFile+0x66>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
jmp    116b <createTemporaryFile+0x2b>
mov    -0x20(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     11d1 <createTemporaryFile+0x91>
movq   $0x0,-0x8(%rbp)
jmp    11de <createTemporaryFile+0x9e>
jmp    11d6 <createTemporaryFile+0x96>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createTemporaryFile>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <tmpfile@plt>
mov    %rax,%r15
test   %rax,%rax
je     11ac <createTemporaryFile+0x6c>
mov    0x2e84(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     1191 <createTemporaryFile+0x51>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
jmp    1170 <createTemporaryFile+0x30>
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
test   %rax,%rax
je     11ac <createTemporaryFile+0x6c>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@SEEK_SET = global i32 0
define i32* @createTemporaryFile(i8** %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i32*
store i8** %0, i8*** %4
store i64* %1, i64** %5
%7 = call i32* (...) @tmpfile()
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %29
10: ; preds = %2
br label %11
11: ; preds = %17, %10
%12 = load i8**, i8*** %4
%13 = load i64*, i64** %5
%14 = load i32, i32* @stdin
%15 = call i32 @getline(i8** %12, i64* %13, i32 %14)
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = load i8**, i8*** %4
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %11
22: ; preds = %11
%23 = load i32*, i32** %6
%24 = load i32, i32* @SEEK_SET
%25 = call i64 @fseek(i32* %23, i32 0, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32* null, i32** %3
br label %31
28: ; preds = %22
br label %29
29: ; preds = %28, %2
%30 = load i32*, i32** %6
store i32* %30, i32** %3
br label %31
31: ; preds = %29, %27
%32 = load i32*, i32** %3
ret i32* %32
}

LLVM IR (-O2):
@stdin = global i32 0
@SEEK_SET = global i32 0
define noalias i32* @createTemporaryFile(i8** %0, i64* %1) {
%3 = tail call i32* (...) @tmpfile()
%4 = icmp eq i32* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = load i32, i32* @stdin
%7 = tail call i32 @getline(i8** %0, i64* %1, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %15, label %9
9: ; preds = %5, %9
%10 = load i8*, i8** %0
%11 = tail call i32 @fputs(i8* %10, i32* %3)
%12 = load i32, i32* @stdin
%13 = tail call i32 @getline(i8** %0, i64* %1, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %9
15: ; preds = %9, %5
%16 = load i32, i32* @SEEK_SET
%17 = tail call i64 @fseek(i32* %3, i32 0, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %2
br label %20
20: ; preds = %15, %19
%21 = phi i32* [ %3, %19 ], [ null, %15 ]
ret i32* %21
}