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

/* Variables and functions */
int /*<<< orphan*/ bzero(struct timezone *, int);
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;
  bzero(&tz, sizeof(tz));
  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
mov    $0x4,%esi
call   1070 <bzero@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <gettimeofday@plt>
cmp    $0x0,%rax
je     11a5 <get_time+0x55>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe7c(%rip),%rdi
call   1060 <perror@plt>
mov    $0x0,%al
call   1050 <die@plt>
imul   $0xf4240,-0x8(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
push   %rbx
sub    $0x20,%rsp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <bzero@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <gettimeofday@plt>
test   %rax,%rax
jne    118d <get_time+0x3d>
imul   $0xf4240,0x18(%rsp),%rax
add    0x10(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe6c(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
call   1050 <die@plt>
jmp    1179 <get_time+0x29>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { 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 = call i32 @bzero(%struct.timezone* %2, i32 4)
%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 }
@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.timeval* %1 to i8*
%4 = bitcast %struct.timezone* %2 to i8*
%5 = call i32 @bzero(%struct.timezone* %2, i32 4)
%6 = call i64 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%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
}