#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ readFile();
scalar_t__ writeFile();
int main() {
  printf("Hello World\n");
  if (writeFile() == 0)
    printf("Writing to file was successful\n");
  else {
    printf("Writing to file failed\n");
    exit(1);
  }
  if (readFile() == 0)
    printf("Reading from file was successful\n");
  else {
    printf("Reading from file failed\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <writeFile@plt>
cmp    $0x0,%rax
jne    117d <main+0x3d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <main+0x53>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    $0x0,%al
call   1060 <readFile@plt>
cmp    $0x0,%rax
jne    11b5 <main+0x75>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <main+0x8b>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <writeFile@plt>
test   %rax,%rax
jne    1181 <main+0x41>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <readFile@plt>
test   %rax,%rax
jne    118a <main+0x4a>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe84(%rip),%rdi
jmp    1191 <main+0x51>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Hello World\0A\00"
@.str.1 = [32 x i8] c"Writing to file was successful\0A\00"
@.str.2 = [24 x i8] c"Writing to file failed\0A\00"
@.str.3 = [34 x i8] c"Reading from file was successful\0A\00"
@.str.4 = [26 x i8] c"Reading from file failed\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = call i64 (...) @writeFile()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %10
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = call i64 (...) @readFile()
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %18
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@str = [12 x i8] c"Hello World\00"
@str.5 = [23 x i8] c"Writing to file failed\00"
@str.6 = [31 x i8] c"Writing to file was successful\00"
@str.7 = [25 x i8] c"Reading from file failed\00"
@str.8 = [33 x i8] c"Reading from file was successful\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 (...) @writeFile()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.6, i64 0, i64 0))
%6 = tail call i64 (...) @readFile()
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %13
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
ret i32 0
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
}