#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 off_t;
typedef int clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int clock();
scalar_t__ file_is_readable(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int get_file_size(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  const char msg[] = "Hello world!";
  off_t file_size;
  clock_t t0, t1;
  if (argc <= 1) {
    printf("Usage: %s [arguments]\n", argv[0]);
    return EXIT_FAILURE;
  }
  t0 = clock();
  fprintf(stdout, "%s\n", msg);
  if (file_is_readable(argv[1])) {
    printf("Input File = '%s'\n", argv[1]);
    file_size = get_file_size(argv[1]);
    if (file_size == -1) {
      printf("Failed to obtain file size\n");
    } else {
      printf("File size is %lld bytes\n", file_size);
    }
  } else {
    printf(
        "Input File = '%s' (file does not exist or read permissions absent)\n",
        argv[1]);
  }
  t1 = clock();
  printf("Time elapsed = %f (ms)\n", (t1 - t0) * 1000 / (double)CLOCKS_PER_SEC);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xe91(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe8c(%rip),%al
mov    %al,-0x11(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11b3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <main+0x150>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    -0x1d(%rbp),%rdx
lea    0xe53(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <file_is_readable@plt>
cmp    $0x0,%rax
je     1246 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <get_file_size@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1230 <main+0xe0>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1241 <main+0xf1>
mov    -0x24(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x28(%rbp),%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    0x2d6b(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movabs $0x21646c726f7720,%rax
mov    %rax,0xd(%rsp)
movabs $0x6f77206f6c6c6548,%rax
20 77 6f
mov    %rax,0x8(%rsp)
cmp    $0x1,%edi
jg     11a9 <main+0x49>
mov    (%rbx),%rsi
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e34(%rip),%rax
jmp    1260 <main+0x100>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %eax,%ebp
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1060 <fprintf@plt>
mov    0x8(%rbx),%rdi
call   1080 <file_is_readable@plt>
mov    0x8(%rbx),%rsi
test   %rax,%rax
je     120c <main+0xac>
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
call   1070 <get_file_size@plt>
cmp    $0xffffffff,%eax
je     121c <main+0xbc>
lea    0xe3a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1228 <main+0xc8>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1228 <main+0xc8>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %ebp,%eax
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    0x2da6(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.msg = [13 x i8] c"Hello world!\00"
@.str = [23 x i8] c"Usage: %s [arguments]\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [19 x i8] c"Input File = '%s'\0A\00"
@.str.3 = [28 x i8] c"Failed to obtain file size\0A\00"
@.str.4 = [25 x i8] c"File size is %lld bytes\0A\00"
@.str.5 = [68 x i8] c"Input File = '%s' (file does not exist or read permissions absent)\0A\00"
@.str.6 = [24 x i8] c"Time elapsed = %f (ms)\0A\00"
@CLOCKS_PER_SEC = global i64 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [13 x i8]* %6 to i8*
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %63
19: ; preds = %2
%20 = call i32 (...) @clock()
store i32 %20, i32* %8
%21 = load i32, i32* @stdout
%22 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @file_is_readable(i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @get_file_size(i8* %36)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %45
42: ; preds = %29
%43 = load i32, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %40
br label %51
46: ; preds = %19
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %46, %45
%52 = call i32 (...) @clock()
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = load i32, i32* %8
%55 = sub nsw i32 %53, %54
%56 = mul nsw i32 %55, 1000
%57 = sitofp i32 %56 to double
%58 = load i64, i64* @CLOCKS_PER_SEC
%59 = sitofp i64 %58 to double
%60 = fdiv double %57, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %60)
%62 = load i32, i32* @EXIT_SUCCESS
store i32 %62, i32* %3
br label %63
63: ; preds = %51, %13
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@__const.main.msg = [13 x i8] c"Hello world!\00"
@.str = [23 x i8] c"Usage: %s [arguments]\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [19 x i8] c"Input File = '%s'\0A\00"
@.str.4 = [25 x i8] c"File size is %lld bytes\0A\00"
@.str.5 = [68 x i8] c"Input File = '%s' (file does not exist or read permissions absent)\0A\00"
@.str.6 = [24 x i8] c"Time elapsed = %f (ms)\0A\00"
@CLOCKS_PER_SEC = global i64 0
@EXIT_SUCCESS = global i32 0
@str = [27 x i8] c"Failed to obtain file size\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %38
9: ; preds = %2
%10 = tail call i32 (...) @clock()
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @file_is_readable(i8* %14)
%16 = icmp eq i64 %15, 0
%17 = load i8*, i8** %13
br i1 %16, label %27, label %18
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%20 = load i8*, i8** %13
%21 = call i32 @get_file_size(i8* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %29
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %29
27: ; preds = %9
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %29
29: ; preds = %23, %25, %27
%30 = call i32 (...) @clock()
%31 = sub nsw i32 %30, %10
%32 = mul nsw i32 %31, 1000
%33 = sitofp i32 %32 to double
%34 = load i64, i64* @CLOCKS_PER_SEC
%35 = sitofp i64 %34 to double
%36 = fdiv double %33, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %36)
br label %38
38: ; preds = %29, %6
%39 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %29 ]
%40 = load i32, i32* %39
ret i32 %40
}