#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 */
struct timeval {
  long long tv_sec;
  int tv_usec;
};

/* Variables and functions */
int HexMage_compile(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long long);
int main(int argc, char **argv) {
  struct timeval start, end;
  gettimeofday(&start, 0);
  int result = HexMage_compile("test_files/test01.hm");
  gettimeofday(&end, 0);
  long long elapsed_ms =
      ((end.tv_sec - start.tv_sec) * 1000000LL + end.tv_usec - start.tv_usec) /
      1000;
  printf("Compile time: %lld ms\n", elapsed_ms);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0xea8(%rip),%rdi
call   1050 <HexMage_compile@plt>
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
imul   $0xf4240,%rax,%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0xeb8(%rip),%rdi
call   1050 <HexMage_compile@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%rax
sub    0x10(%rsp),%rax
imul   $0xf4240,%rax,%rcx
movslq 0x8(%rsp),%rax
add    %rcx,%rax
movslq 0x18(%rsp),%rcx
sub    %rcx,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
imul   %rcx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x7,%rdx
add    %rdx,%rsi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
@.str = [21 x i8] c"test_files/test01.hm\00"
@.str.1 = [23 x i8] c"Compile time: %lld ms\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%11 = call i32 @HexMage_compile(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %8
%12 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%16 = load i64, i64* %15
%17 = sub nsw i64 %14, %16
%18 = mul nsw i64 %17, 1000000
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = add nsw i64 %18, %21
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = sub nsw i64 %22, %25
%27 = sdiv i64 %26, 1000
store i64 %27, i64* %9
%28 = load i64, i64* %9
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %28)
%30 = load i32, i32* %8
ret i32 %30
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
@.str = [21 x i8] c"test_files/test01.hm\00"
@.str.1 = [23 x i8] c"Compile time: %lld ms\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%8 = call i32 @HexMage_compile(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%13 = load i64, i64* %12
%14 = sub nsw i64 %11, %13
%15 = mul nsw i64 %14, 1000000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = add nsw i64 %15, %18
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = sub i64 %19, %22
%24 = sdiv i64 %23, 1000
%25 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %24)
ret i32 %8
}