#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*/ get_file_size(char const *);
int /*<<< orphan*/ make_file(char const *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ truncate(char const *, int);
int main() {
  const char *pfile = "temp-file.x";
  make_file(pfile);
  printf("file size : [%lu]\n", get_file_size(pfile));
  truncate(pfile, 1000);
  printf("file size : [%lu]\n", get_file_size(pfile));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <make_file@plt>
mov    -0x10(%rbp),%rdi
call   1050 <get_file_size@plt>
mov    %eax,%esi
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <truncate@plt>
mov    -0x10(%rbp),%rdi
call   1050 <get_file_size@plt>
mov    %eax,%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
call   1060 <make_file@plt>
mov    %rbx,%rdi
call   1050 <get_file_size@plt>
lea    0xeaa(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <truncate@plt>
mov    %rbx,%rdi
call   1050 <get_file_size@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"temp-file.x\00"
@.str.1 = [19 x i8] c"file size : [%lu]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @make_file(i8* %3)
%5 = load i8*, i8** %2
%6 = call i32 @get_file_size(i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i8*, i8** %2
%9 = call i32 @truncate(i8* %8, i32 1000)
%10 = load i8*, i8** %2
%11 = call i32 @get_file_size(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"temp-file.x\00"
@.str.1 = [19 x i8] c"file size : [%lu]\0A\00"
define i32 @main() {
%1 = tail call i32 @make_file(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @get_file_size(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = tail call i32 @truncate(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 1000)
%5 = tail call i32 @get_file_size(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %5)
ret i32 0
}