#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 tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
int get_uetime(struct timeval the_time[]) {
  struct timeval *curr_time = &the_time[0];
  struct timeval *prev_time = &the_time[1];
  struct timeval e_time;
  gettimeofday(curr_time, NULL);
  timersub(curr_time, prev_time, &e_time);
  prev_time->tv_sec = curr_time->tv_sec;
  prev_time->tv_usec = curr_time->tv_usec;
  return (e_time.tv_sec * 1000000 + e_time.tv_usec);
}


x86 assembly (clang, -O0):
<get_uetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <timersub@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
imul   $0xf4240,-0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_uetime>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x8(%rdi),%r14
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <timersub@plt>
mov    (%rbx),%rax
mov    %rax,0x8(%rbx)
imul   $0xf4240,(%rsp),%eax
add    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i32 @get_uetime(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %2
%6 = load %struct.timeval*, %struct.timeval** %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0
store %struct.timeval* %7, %struct.timeval** %3
%8 = load %struct.timeval*, %struct.timeval** %2
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 1
store %struct.timeval* %9, %struct.timeval** %4
%10 = load %struct.timeval*, %struct.timeval** %3
%11 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%12 = load %struct.timeval*, %struct.timeval** %3
%13 = load %struct.timeval*, %struct.timeval** %4
%14 = call i32 @timersub(%struct.timeval* %12, %struct.timeval* %13, %struct.timeval* %5)
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load %struct.timeval*, %struct.timeval** %4
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
store i32 %17, i32* %19
%20 = load %struct.timeval*, %struct.timeval** %3
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load %struct.timeval*, %struct.timeval** %4
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
store i32 %22, i32* %24
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%26 = load i32, i32* %25
%27 = mul nsw i32 %26, 1000000
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%29 = load i32, i32* %28
%30 = add nsw i32 %27, %29
ret i32 %30
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i32 @get_uetime(%struct.timeval* %0) {
%2 = alloca %struct.timeval
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 1
%4 = bitcast %struct.timeval* %2 to i8*
%5 = tail call i32 @gettimeofday(%struct.timeval* %0, i32* null)
%6 = call i32 @timersub(%struct.timeval* %0, %struct.timeval* %3, %struct.timeval* %2)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 1, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%14 = load i32, i32* %13
%15 = mul nsw i32 %14, 1000000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%17 = load i32, i32* %16
%18 = add nsw i32 %15, %17
ret i32 %18
}