#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_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ calloc(long, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ terminate(char *);
char *read_tmp_email_file() {
  FILE *recv_file = fopen("pymail_cli_recv.tmp", "r");
  if (recv_file == NULL) {
    terminate("Error opening file.");
  }
  char *recv_file_buffer;
  long file_length;
  fseek(recv_file, 0, SEEK_END);
  file_length = ftell(recv_file);
  fseek(recv_file, 0, SEEK_SET);
  recv_file_buffer = (char *)calloc(file_length, sizeof(char));
  fread(recv_file_buffer, sizeof(char), file_length, recv_file);
  fclose(recv_file);
  return recv_file_buffer;
}


x86 assembly (clang, -O0):
<read_tmp_email_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe81(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a6 <read_tmp_email_file+0x36>
lea    0xe75(%rip),%rdi
call   1070 <terminate@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_tmp_email_file>:
push   %r15
push   %r14
push   %rbx
lea    0xe84(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    119c <read_tmp_email_file+0x2c>
lea    0xe7f(%rip),%rdi
call   1070 <terminate@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %rax,%r14
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"pymail_cli_recv.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening file.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8* @read_tmp_email_file() {
%1 = alloca i32*
%2 = alloca i8*
%3 = alloca i64
%4 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @terminate(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32*, i32** %1
%11 = load i32, i32* @SEEK_END
%12 = call i32 @fseek(i32* %10, i32 0, i32 %11)
%13 = load i32*, i32** %1
%14 = call i64 @ftell(i32* %13)
store i64 %14, i64* %3
%15 = load i32*, i32** %1
%16 = load i32, i32* @SEEK_SET
%17 = call i32 @fseek(i32* %15, i32 0, i32 %16)
%18 = load i64, i64* %3
%19 = call i64 @calloc(i64 %18, i32 1)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %2
%21 = load i8*, i8** %2
%22 = load i64, i64* %3
%23 = load i32*, i32** %1
%24 = call i32 @fread(i8* %21, i32 1, i64 %22, i32* %23)
%25 = load i32*, i32** %1
%26 = call i32 @fclose(i32* %25)
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@.str = [20 x i8] c"pymail_cli_recv.tmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Error opening file.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i8* @read_tmp_email_file() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @terminate(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %1, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %1)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %1, i32 0, i32 %9)
%11 = tail call i64 @calloc(i64 %8, i32 1)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @fread(i8* %12, i32 1, i64 %8, i32* %1)
%14 = tail call i32 @fclose(i32* %1)
ret i8* %12
}