#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*/ free(char *);
char *get_input();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long, long);
int /*<<< orphan*/ process_input(struct lsm_tree *, char *);
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
void interactive(struct lsm_tree *tree) {
  char *input;
  struct timeval tval_before, tval_after, tval_result;
  while (1) {
    input = get_input();
    gettimeofday(&tval_before, NULL);
    process_input(tree, input);
    free(input);
    gettimeofday(&tval_after, NULL);
    timersub(&tval_after, &tval_before, &tval_result);
    printf("Time elapsed: %ld.%06ld\n", (long)tval_result.tv_sec,
           (long)tval_result.tv_usec);
  }
}


x86 assembly (clang, -O0):
<interactive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <get_input@plt>
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <process_input@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <timersub@plt>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
jmp    116c <interactive+0xc>

x86 assembly (clang, -O2):
<interactive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
lea    0x28(%rsp),%r15
lea    0x18(%rsp),%rbx
lea    0x8(%rsp),%r12
lea    0xe79(%rip),%r13
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <get_input@plt>
mov    %rax,%rbp
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <process_input@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <timersub@plt>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rsi
mov    %r13,%rdi
call   1040 <printf@plt>
jmp    1190 <interactive+0x30>

LLVM IR (-O0):
%struct.lsm_tree = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [25 x i8] c"Time elapsed: %ld.%06ld\0A\00"
define void @interactive(%struct.lsm_tree* %0) {
%2 = alloca %struct.lsm_tree*
%3 = alloca i8*
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
store %struct.lsm_tree* %0, %struct.lsm_tree** %2
br label %7
7: ; preds = %1, %7
%8 = call i8* (...) @get_input()
store i8* %8, i8** %3
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%10 = load %struct.lsm_tree*, %struct.lsm_tree** %2
%11 = load i8*, i8** %3
%12 = call i32 @process_input(%struct.lsm_tree* %10, i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%16 = call i32 @timersub(%struct.timeval* %5, %struct.timeval* %4, %struct.timeval* %6)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%18 = load i64, i64* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%20 = load i64, i64* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %20)
br label %7
}

LLVM IR (-O2):
%struct.lsm_tree = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [25 x i8] c"Time elapsed: %ld.%06ld\0A\00"
define void @interactive(%struct.lsm_tree* %0) {
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
br label %10
10: ; preds = %10, %1
%11 = call i8* (...) @get_input()
%12 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%13 = call i32 @process_input(%struct.lsm_tree* %0, i8* %11)
%14 = call i32 @free(i8* %11)
%15 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%16 = call i32 @timersub(%struct.timeval* %3, %struct.timeval* %2, %struct.timeval* %4)
%17 = load i64, i64* %8
%18 = load i64, i64* %9
%19 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %18)
br label %10
}