#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ SilentStartVM(char *);
scalar_t__ clock();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
char *readAllText(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage: SilentVM <file name>\n");
    exit(-1);
  }
  char *program = readAllText(argv[1]);
  clock_t start = clock();
  SilentStartVM(program);
  clock_t end = clock();
  double timeSpent = (double)(end - start) / CLOCKS_PER_SEC;
  printf("Time taken: %f seconds\n", timeSpent);
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x38>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <readAllText@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <SilentStartVM@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e1c(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11b9 <main+0x59>
mov    0x8(%rsi),%rdi
call   1030 <readAllText@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <SilentStartVM@plt>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e4b(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Usage: SilentVM <file name>\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [24 x i8] c"Time taken: %f seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i8* @readAllText(i8* %18)
store i8* %19, i8** %6
%20 = call i64 (...) @clock()
store i64 %20, i64* %7
%21 = load i8*, i8** %6
%22 = call i32 @SilentStartVM(i8* %21)
%23 = call i64 (...) @clock()
store i64 %23, i64* %8
%24 = load i64, i64* %8
%25 = load i64, i64* %7
%26 = sub nsw i64 %24, %25
%27 = sitofp i64 %26 to double
%28 = load double, double* @CLOCKS_PER_SEC
%29 = fdiv double %27, %28
store double %29, double* %9
%30 = load double, double* %9
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %30)
ret i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [24 x i8] c"Time taken: %f seconds\0A\00"
@str = [28 x i8] c"Usage: SilentVM <file name>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i8* @readAllText(i8* %9)
%11 = tail call i64 (...) @clock()
%12 = tail call i32 @SilentStartVM(i8* %10)
%13 = tail call i64 (...) @clock()
%14 = sub nsw i64 %13, %11
%15 = sitofp i64 %14 to double
%16 = load double, double* @CLOCKS_PER_SEC
%17 = fdiv double %15, %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %17)
ret i32 0
}