#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
void printWelcomeMessage(void) {
  FILE *fp;
  fp = fopen("welcomeMessage.txt", "r");
  char *buffer = (char *)malloc(300 * sizeof(char));
  if (fp == NULL) {
    perror("ERROR in opening file");
    exit(EXIT_FAILURE);
  }
  while (!feof(fp)) {
    memset(buffer, 0, ((sizeof(char)) * 300));
    fgets(buffer, 300, fp);
    printf("%s", buffer);
  }
}


x86 assembly (clang, -O0):
<printWelcomeMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe71(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    $0x12c,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11d2 <printWelcomeMessage+0x52>
lea    0xe56(%rip),%rdi
call   1090 <perror@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    11d7 <printWelcomeMessage+0x57>
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f5 <printWelcomeMessage+0x75>
jmp    122c <printWelcomeMessage+0xac>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x12c,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <printWelcomeMessage+0x57>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printWelcomeMessage>:
push   %r15
push   %r14
push   %rbx
lea    0xe74(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    $0x12c,%edi
call   1070 <malloc@plt>
test   %r14,%r14
je     11fc <printWelcomeMessage+0x7c>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11f6 <printWelcomeMessage+0x76>
lea    0xe6b(%rip),%r15
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11c0 <printWelcomeMessage+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe12(%rip),%rdi
call   1090 <perror@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"welcomeMessage.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"ERROR in opening file\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @printWelcomeMessage() {
%1 = alloca i32*
%2 = alloca i8*
%3 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = call i64 @malloc(i32 300)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %2
%6 = load i32*, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
br label %13
13: ; preds = %18, %12
%14 = load i32*, i32** %1
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @memset(i8* %19, i32 0, i32 300)
%21 = load i8*, i8** %2
%22 = load i32*, i32** %1
%23 = call i32 @fgets(i8* %21, i32 300, i32* %22)
%24 = load i8*, i8** %2
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %13
26: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"welcomeMessage.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"ERROR in opening file\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @printWelcomeMessage() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @malloc(i32 300)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i32* %1, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i32 @feof(i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %18
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %5, %12
%13 = tail call i32 @memset(i8* %3, i32 0, i32 300)
%14 = tail call i32 @fgets(i8* %3, i32 300, i32* %1)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%16 = tail call i32 @feof(i32* %1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %5
ret void
}