#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct lsm_tree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ free(size_t *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct lsm_tree *init(char *, int, int, size_t *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
struct lsm_tree *lsm_tree_default_init(void) {
  size_t *sizes = (size_t *)malloc(4 * sizeof(size_t));
  sizes[0] = 8192;
  sizes[1] = 1048576;
  sizes[2] = 16384;
  sizes[3] = 65536;
  struct timeval tval_before, tval_after, tval_result;
  printf("Initializing LSM Tree... ");
  fflush(stdout);
  gettimeofday(&tval_before, NULL);
  struct lsm_tree *tree = init("my-lsm", 2, 1, sizes);
  gettimeofday(&tval_after, NULL);
  timersub(&tval_after, &tval_before, &tval_result);
  printf("done.\n");
  printf("Time elapsed: %ld.%06ld\n", (long)tval_result.tv_sec,
         (long)tval_result.tv_usec);
  free(sizes);
  return tree;
}


x86 assembly (clang, -O0):
<lsm_tree_default_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x20,%edi
call   1070 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movq   $0x2000,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x100000,0x8(%rax)
mov    -0x8(%rbp),%rax
movq   $0x4000,0x10(%rax)
mov    -0x8(%rbp),%rax
movq   $0x10000,0x18(%rax)
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x8(%rbp),%rcx
lea    0xe31(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1060 <init@plt>
mov    %rax,-0x40(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1090 <timersub@plt>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lsm_tree_default_init>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x20,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
movaps 0xe61(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe67(%rip),%xmm0
movups %xmm0,0x10(%rax)
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    0x28(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0xe5b(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <init@plt>
mov    %rax,%r14
lea    0x18(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   10a0 <timersub@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rsi
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.lsm_tree = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [26 x i8] c"Initializing LSM Tree... \00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"my-lsm\00"
@.str.2 = [7 x i8] c"done.\0A\00"
@.str.3 = [25 x i8] c"Time elapsed: %ld.%06ld\0A\00"
define %struct.lsm_tree* @lsm_tree_default_init() {
%1 = alloca i64*
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.lsm_tree*
%6 = call i64 @malloc(i32 32)
%7 = inttoptr i64 %6 to i64*
store i64* %7, i64** %1
%8 = load i64*, i64** %1
%9 = getelementptr inbounds i64, i64* %8, i64 0
store i64 8192, i64* %9
%10 = load i64*, i64** %1
%11 = getelementptr inbounds i64, i64* %10, i64 1
store i64 1048576, i64* %11
%12 = load i64*, i64** %1
%13 = getelementptr inbounds i64, i64* %12, i64 2
store i64 16384, i64* %13
%14 = load i64*, i64** %1
%15 = getelementptr inbounds i64, i64* %14, i64 3
store i64 65536, i64* %15
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%20 = load i64*, i64** %1
%21 = call %struct.lsm_tree* @init(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 1, i64* %20)
store %struct.lsm_tree* %21, %struct.lsm_tree** %5
%22 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%23 = call i32 @timersub(%struct.timeval* %3, %struct.timeval* %2, %struct.timeval* %4)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%28 = load i64, i64* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %26, i64 %28)
%30 = load i64*, i64** %1
%31 = call i32 @free(i64* %30)
%32 = load %struct.lsm_tree*, %struct.lsm_tree** %5
ret %struct.lsm_tree* %32
}

LLVM IR (-O2):
%struct.lsm_tree = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [26 x i8] c"Initializing LSM Tree... \00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"my-lsm\00"
@.str.3 = [25 x i8] c"Time elapsed: %ld.%06ld\0A\00"
@str = [6 x i8] c"done.\00"
define %struct.lsm_tree* @lsm_tree_default_init() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = tail call i64 @malloc(i32 32)
%5 = inttoptr i64 %4 to i64*
%6 = inttoptr i64 %4 to <2 x i64>*
store <2 x i64> <i64 8192, i64 1048576>, <2 x i64>* %6
%7 = getelementptr inbounds i64, i64* %5, i64 2
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> <i64 16384, i64 65536>, <2 x i64>* %8
%9 = bitcast %struct.timeval* %1 to i8*
%10 = bitcast %struct.timeval* %2 to i8*
%11 = bitcast %struct.timeval* %3 to i8*
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%16 = tail call %struct.lsm_tree* @init(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 1, i64* %5)
%17 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%18 = call i32 @timersub(%struct.timeval* %2, %struct.timeval* %1, %struct.timeval* %3)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%21 = load i64, i64* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%23 = load i64, i64* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 %21, i64 %23)
%25 = call i32 @free(i64* %5)
ret %struct.lsm_tree* %16
}