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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int time_after(struct timeval oldtime, uint32_t delta_ms) {
  uint64_t oldtime_ms = (oldtime.tv_sec * 1000) + (oldtime.tv_usec / 1000);
  oldtime_ms += delta_ms;
  struct timeval nowtime;
  gettimeofday(&nowtime, 0);
  uint64_t nowtime_ms = (nowtime.tv_sec * 1000) + (nowtime.tv_usec / 1000);
  return nowtime_ms > oldtime_ms;
}


x86 assembly (clang, -O0):
<time_after>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
imul   $0x3e8,-0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,-0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
setg   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_after>:
push   %rbx
sub    $0x10,%rsp
imul   $0x3e8,%edi,%eax
sar    $0x20,%rdi
imul   $0x10624dd3,%rdi,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rbx
add    %rsi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movslq 0x8(%rsp),%rax
imul   $0x3e8,%rax,%rax
movslq 0xc(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
add    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setl   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i32 @time_after(i64 %0, i64 %1) {
%3 = alloca %struct.timeval
%4 = alloca i64
%5 = alloca i64
%6 = alloca %struct.timeval
%7 = alloca i64
%8 = bitcast %struct.timeval* %3 to i64*
store i64 %0, i64* %8
store i64 %1, i64* %4
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 1000
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%13 = load i32, i32* %12
%14 = sdiv i32 %13, 1000
%15 = add nsw i32 %11, %14
%16 = sext i32 %15 to i64
store i64 %16, i64* %5
%17 = load i64, i64* %4
%18 = load i64, i64* %5
%19 = add nsw i64 %18, %17
store i64 %19, i64* %5
%20 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%22 = load i32, i32* %21
%23 = mul nsw i32 %22, 1000
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1000
%27 = add nsw i32 %23, %26
%28 = sext i32 %27 to i64
store i64 %28, i64* %7
%29 = load i64, i64* %7
%30 = load i64, i64* %5
%31 = icmp sgt i64 %29, %30
%32 = zext i1 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i32 @time_after(i64 %0, i64 %1) {
%3 = alloca %struct.timeval
%4 = trunc i64 %0 to i32
%5 = lshr i64 %0, 32
%6 = trunc i64 %5 to i32
%7 = mul nsw i32 %4, 1000
%8 = sdiv i32 %6, 1000
%9 = add nsw i32 %8, %7
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %1
%12 = bitcast %struct.timeval* %3 to i8*
%13 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, 1000
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = sdiv i32 %18, 1000
%20 = add nsw i32 %19, %16
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %11, %21
%23 = zext i1 %22 to i32
ret i32 %23
}