#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 timezone {
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ die();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
unsigned long long get_time(void) {
  struct timeval tv;
  struct timezone tz = {0, 0};
  if (gettimeofday(&tv, &tz)) {
    fprintf(stderr, "Can't getttimeofday.\n");
    perror("");
    die();
  }
  return ((unsigned long long)tv.tv_sec) * 1000000 +
         ((unsigned long long)tv.tv_usec);
}


x86 assembly (clang, -O0):
<get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
je     11a7 <get_time+0x57>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe7a(%rip),%rdi
call   1070 <perror@plt>
mov    $0x0,%al
call   1060 <die@plt>
imul   $0xf4240,-0x8(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
sub    $0x18,%rsp
movq   $0x0,(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <gettimeofday@plt>
test   %rax,%rax
jne    1171 <get_time+0x31>
imul   $0xf4240,0x10(%rsp),%rax
add    0x8(%rsp),%rax
add    $0x18,%rsp
ret
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
call   1050 <die@plt>
jmp    115e <get_time+0x1e>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Can't getttimeofday.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i64 @get_time() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = bitcast %struct.timezone* %2 to i8*
%4 = call i64 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @die()
br label %11
11: ; preds = %6, %0
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%13 = load i64, i64* %12
%14 = mul i64 %13, 1000000
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%16 = load i64, i64* %15
%17 = add i64 %14, %16
ret i64 %17
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"Can't getttimeofday.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i64 @get_time() {
%1 = alloca %struct.timeval
%2 = alloca i64
%3 = bitcast i64* %2 to %struct.timezone*
%4 = bitcast %struct.timeval* %1 to i8*
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%6 = call i64 @gettimeofday(%struct.timeval* %1, %struct.timezone* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 (...) @die()
br label %13
13: ; preds = %8, %0
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%15 = load i64, i64* %14
%16 = mul i64 %15, 1000000
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%18 = load i64, i64* %17
%19 = add i64 %16, %18
ret i64 %19
}