#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*/ Close(int);
int /*<<< orphan*/ Halt();
int Open(char *);
int /*<<< orphan*/ Print(char *);
int /*<<< orphan*/ Read(char *, int, int);
int /*<<< orphan*/ Write(char *, int, int);
void main() {
  int file;
  char buf[500];
  Print("=== Test program initiated ===\n");
  file = Open("abc.txt");
  Read(buf, 500, file);
  Write("Hello World!\n", 13, file);
  Close(file);
  Print(buf);
  Print("Test program terminated!\n");
  Halt();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
lea    0xe8e(%rip),%rdi
call   1070 <Print@plt>
lea    0xea2(%rip),%rdi
call   1030 <Open@plt>
mov    %eax,-0x4(%rbp)
lea    -0x200(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0x1f4,%esi
call   1040 <Read@plt>
mov    -0x4(%rbp),%edx
lea    0xe84(%rip),%rdi
mov    $0xd,%esi
call   1050 <Write@plt>
mov    -0x4(%rbp),%edi
call   1060 <Close@plt>
lea    -0x200(%rbp),%rdi
call   1070 <Print@plt>
lea    0xe6d(%rip),%rdi
call   1070 <Print@plt>
mov    $0x0,%al
call   1080 <Halt@plt>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1f8,%rsp
lea    0xe8f(%rip),%rdi
call   1070 <Print@plt>
lea    0xea3(%rip),%rdi
call   1030 <Open@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1f4,%esi
mov    %eax,%edx
call   1040 <Read@plt>
lea    0xe8b(%rip),%rdi
mov    $0xd,%esi
mov    %ebx,%edx
call   1050 <Write@plt>
mov    %ebx,%edi
call   1060 <Close@plt>
mov    %r14,%rdi
call   1070 <Print@plt>
lea    0xe77(%rip),%rdi
call   1070 <Print@plt>
xor    %eax,%eax
call   1080 <Halt@plt>
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"=== Test program initiated ===\0A\00"
@.str.1 = [8 x i8] c"abc.txt\00"
@.str.2 = [14 x i8] c"Hello World!\0A\00"
@.str.3 = [26 x i8] c"Test program terminated!\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = call i32 @Print(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @Open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 %4, i32* %1
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* %1
%7 = call i32 @Read(i8* %5, i32 500, i32 %6)
%8 = load i32, i32* %1
%9 = call i32 @Write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13, i32 %8)
%10 = load i32, i32* %1
%11 = call i32 @Close(i32 %10)
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%13 = call i32 @Print(i8* %12)
%14 = call i32 @Print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (...) @Halt()
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"=== Test program initiated ===\0A\00"
@.str.1 = [8 x i8] c"abc.txt\00"
@.str.2 = [14 x i8] c"Hello World!\0A\00"
@.str.3 = [26 x i8] c"Test program terminated!\0A\00"
define void @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @Print(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @Open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @Read(i8* %2, i32 500, i32 %4)
%6 = call i32 @Write(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13, i32 %4)
%7 = call i32 @Close(i32 %4)
%8 = call i32 @Print(i8* %2)
%9 = call i32 @Print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (...) @Halt()
ret void
}