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

/* Variables and functions */
int /*<<< orphan*/ append2File(char *, void *, int);
int /*<<< orphan*/ createFile(char *);
int /*<<< orphan*/ deleteFile(char *);
int /*<<< orphan*/ deleteLast(char *, int);
int getFileSize(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char *testFile = "./test.bin";
  createFile(testFile);
  int test = getFileSize(testFile);
  printf("the size (in bytes) of %s is: %d\n", testFile, test);
  int therealdata = 65;
  char *data = (char *)(&therealdata);
  append2File(testFile, (void *)data, sizeof(therealdata));
  test = getFileSize(testFile);
  printf("the size (in bytes) of %s is: %d\n", testFile, test);
  therealdata = 67;
  data = (char *)(&therealdata);
  append2File(testFile, (void *)data, sizeof(therealdata));
  test = getFileSize(testFile);
  printf("the size (in bytes) of %s is: %d\n", testFile, test);
  deleteLast(testFile, sizeof(therealdata));
  test = getFileSize(testFile);
  printf("the size (in bytes) of %s is: %d\n", testFile, test);
  deleteFile(testFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <createFile@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getFileSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x41,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1050 <append2File@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getFileSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x43,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1050 <append2File@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getFileSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1080 <deleteLast@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getFileSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xdc1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <deleteFile@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rbx
mov    %rbx,%rdi
call   1060 <createFile@plt>
mov    %rbx,%rdi
call   1040 <getFileSize@plt>
lea    0xe84(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
movl   $0x41,0xc(%rsp)
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <append2File@plt>
mov    %rbx,%rdi
call   1040 <getFileSize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
movl   $0x43,0xc(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <append2File@plt>
mov    %rbx,%rdi
call   1040 <getFileSize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <deleteLast@plt>
mov    %rbx,%rdi
call   1040 <getFileSize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <deleteFile@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"./test.bin\00"
@.str.1 = [34 x i8] c"the size (in bytes) of %s is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @createFile(i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 @getFileSize(i8* %8)
store i32 %9, i32* %3
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11)
store i32 65, i32* %4
%13 = bitcast i32* %4 to i8*
store i8* %13, i8** %5
%14 = load i8*, i8** %2
%15 = load i8*, i8** %5
%16 = call i32 @append2File(i8* %14, i8* %15, i32 4)
%17 = load i8*, i8** %2
%18 = call i32 @getFileSize(i8* %17)
store i32 %18, i32* %3
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 %20)
store i32 67, i32* %4
%22 = bitcast i32* %4 to i8*
store i8* %22, i8** %5
%23 = load i8*, i8** %2
%24 = load i8*, i8** %5
%25 = call i32 @append2File(i8* %23, i8* %24, i32 4)
%26 = load i8*, i8** %2
%27 = call i32 @getFileSize(i8* %26)
store i32 %27, i32* %3
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %28, i32 %29)
%31 = load i8*, i8** %2
%32 = call i32 @deleteLast(i8* %31, i32 4)
%33 = load i8*, i8** %2
%34 = call i32 @getFileSize(i8* %33)
store i32 %34, i32* %3
%35 = load i8*, i8** %2
%36 = load i32, i32* %3
%37 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %35, i32 %36)
%38 = load i8*, i8** %2
%39 = call i32 @deleteFile(i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"./test.bin\00"
@.str.1 = [34 x i8] c"the size (in bytes) of %s is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @createFile(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @getFileSize(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = bitcast i32* %1 to i8*
store i32 65, i32* %1
%6 = call i32 @append2File(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, i32 4)
%7 = call i32 @getFileSize(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 67, i32* %1
%9 = call i32 @append2File(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, i32 4)
%10 = call i32 @getFileSize(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @deleteLast(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4)
%13 = call i32 @getFileSize(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @deleteFile(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
ret i32 0
}