#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ cal_avg();
int /*<<< orphan*/ caltv(struct timeval *, struct timeval *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pr_tv(struct timeval *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep_us(int);
int main() {
  struct timeval stv, etv;
  cal_avg();
  printf("Start Main:\n");
  gettimeofday(&stv, NULL);
  pr_tv(&stv);
  sleep_us(1000 * 10);
  gettimeofday(&etv, NULL);
  pr_tv(&etv);
  printf("Elapsed Time:%ld\n", caltv(&stv, &etv));
  printf("End Main:\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <cal_avg@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
call   1040 <pr_tv@plt>
mov    $0x2710,%edi
call   1070 <sleep_us@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
lea    -0x10(%rbp),%rdi
call   1040 <pr_tv@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <caltv@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <cal_avg@plt>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    %r14,%rdi
call   1050 <pr_tv@plt>
mov    $0x2710,%edi
call   1080 <sleep_us@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    %rbx,%rdi
call   1050 <pr_tv@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <caltv@plt>
lea    0xe2c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [13 x i8] c"Start Main:\0A\00"
@.str.1 = [18 x i8] c"Elapsed Time:%ld\0A\00"
@.str.2 = [11 x i8] c"End Main:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
store i32 0, i32* %1
%4 = call i32 (...) @cal_avg()
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = call i32 @pr_tv(%struct.timeval* %2)
%8 = call i32 @sleep_us(i32 10000)
%9 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%10 = call i32 @pr_tv(%struct.timeval* %3)
%11 = call i32 @caltv(%struct.timeval* %2, %struct.timeval* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str.1 = [18 x i8] c"Elapsed Time:%ld\0A\00"
@str = [12 x i8] c"Start Main:\00"
@str.3 = [10 x i8] c"End Main:\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = tail call i32 (...) @cal_avg()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%7 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%8 = call i32 @pr_tv(%struct.timeval* %1)
%9 = call i32 @sleep_us(i32 10000)
%10 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%11 = call i32 @pr_tv(%struct.timeval* %2)
%12 = call i32 @caltv(%struct.timeval* %1, %struct.timeval* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}