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

/* Variables and functions */
int /*<<< orphan*/ fatal(char *, char *);
int gettimeofday(struct timeval *, int /*<<< orphan*/);
uint64_t current_time(void) {
  struct timeval tv;
  uint64_t current_time;
  int status;
  status = gettimeofday(&tv, 0);
  if (status == -1)
    fatal("gettimeofday", "Unable to get current time\n");
  current_time = tv.tv_sec * 1000000 + tv.tv_usec;
  return current_time;
}


x86 assembly (clang, -O0):
<current_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1153 <current_time+0x33>
lea    0xeb9(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1040 <fatal@plt>
imul   $0xf4240,-0x10(%rbp),%eax
cltq
add    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<current_time>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    1148 <current_time+0x28>
lea    0xec4(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1040 <fatal@plt>
movslq 0x8(%rsp),%rax
imul   $0xf4240,%rax,%rax
add    0x10(%rsp),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [13 x i8] c"gettimeofday\00"
@.str.1 = [28 x i8] c"Unable to get current time\0A\00"
define i64 @current_time() {
%1 = alloca %struct.timeval
%2 = alloca i64
%3 = alloca i32
%4 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @fatal(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 1000000
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%15 = load i64, i64* %14
%16 = add nsw i64 %13, %15
store i64 %16, i64* %2
%17 = load i64, i64* %2
ret i64 %17
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [13 x i8] c"gettimeofday\00"
@.str.1 = [28 x i8] c"Unable to get current time\0A\00"
define i64 @current_time() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @fatal(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, 1000000
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%13 = load i64, i64* %12
%14 = add nsw i64 %13, %11
ret i64 %14
}