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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
uint32_t get_abs_clock_usec_32bit() {
  struct timeval timeval_now;
  struct timezone timezone_now;
  gettimeofday(&timeval_now, &timezone_now);
  uint32_t now_sec = (uint32_t)timeval_now.tv_sec;
  uint32_t now_usec = (uint32_t)timeval_now.tv_usec;
  uint64_t now_ll = now_sec * 1000000LL + now_usec;
  uint64_t now_usec_ll32 = now_ll & 0xFFFFFFFF;
  return (uint32_t)now_usec_ll32;
}


x86 assembly (clang, -O0):
<get_abs_clock_usec_32bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <gettimeofday@plt>
movslq -0x4(%rbp),%rax
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
imul   $0xf4240,-0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_abs_clock_usec_32bit>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <gettimeofday@plt>
imul   $0xf4240,0xc(%rsp),%eax
add    0x8(%rsp),%eax
cltq
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
define i64 @get_abs_clock_usec_32bit() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%9 = load i32, i32* %8
%10 = sext i32 %9 to i64
store i64 %10, i64* %3
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
store i64 %13, i64* %4
%14 = load i64, i64* %3
%15 = mul nsw i64 %14, 1000000
%16 = load i64, i64* %4
%17 = add nsw i64 %15, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = and i32 %19, -1
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
ret i64 %22
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
define i64 @get_abs_clock_usec_32bit() {
%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 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = mul i32 %7, 1000000
%11 = add i32 %10, %9
%12 = sext i32 %11 to i64
ret i64 %12
}