#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 timezone {
  int dummy;
};
struct timeval {
  long long tv_usec;
  long long tv_sec;
};
struct timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
void _PyThread_cond_after(long long us, struct timespec *abs) {
  struct timespec ts;
  do {
    struct timeval tv;
    gettimeofday(&tv, (struct timezone *)NULL);
    tv.tv_usec += us % 1000000;
    tv.tv_sec += us / 1000000;
    tv.tv_sec += tv.tv_usec / 1000000;
    tv.tv_usec %= 1000000;
    ts.tv_sec = tv.tv_sec;
    ts.tv_nsec = tv.tv_usec * 1000;
  } while (0);
  *abs = ts;
}


x86 assembly (clang, -O0):
<_PyThread_cond_after>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x8(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
add    -0x28(%rbp),%rdx
mov    %rdx,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x18(%rbp)
imul   $0x3e8,-0x28(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_PyThread_cond_after>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movabs $0x431bde82d7b634db,%rsi
de 1b 43
mov    %rbx,%rax
imul   %rsi
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rcx
add    %rax,%rcx
imul   $0xf4240,%rcx,%rax
sub    %rax,%rbx
add    0x8(%rsp),%rbx
add    0x10(%rsp),%ecx
mov    %rbx,%rax
imul   %rsi
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x12,%rdx
add    %eax,%edx
add    %edx,%ecx
imul   $0xf4240,%edx,%eax
sub    %eax,%ebx
imul   $0x3e8,%ebx,%eax
mov    %ecx,(%r14)
mov    %eax,0x4(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32 }
define void @_PyThread_cond_after(i64 %0, %struct.timespec* %1) {
%3 = alloca i64
%4 = alloca %struct.timespec*
%5 = alloca %struct.timespec
%6 = alloca %struct.timeval
store i64 %0, i64* %3
store %struct.timespec* %1, %struct.timespec** %4
br label %7
7: ; preds = %2
%8 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* null)
%9 = load i64, i64* %3
%10 = srem i64 %9, 1000000
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%12 = load i64, i64* %11
%13 = add nsw i64 %12, %10
store i64 %13, i64* %11
%14 = load i64, i64* %3
%15 = sdiv i64 %14, 1000000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%17 = load i64, i64* %16
%18 = add nsw i64 %17, %15
store i64 %18, i64* %16
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%20 = load i64, i64* %19
%21 = sdiv i64 %20, 1000000
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%23 = load i64, i64* %22
%24 = add nsw i64 %23, %21
store i64 %24, i64* %22
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%26 = load i64, i64* %25
%27 = srem i64 %26, 1000000
store i64 %27, i64* %25
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
store i32 %30, i32* %31
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%33 = load i64, i64* %32
%34 = mul nsw i64 %33, 1000
%35 = trunc i64 %34 to i32
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i32 %35, i32* %36
br label %37
37: ; preds = %7
%38 = load %struct.timespec*, %struct.timespec** %4
%39 = bitcast %struct.timespec* %38 to i8*
%40 = bitcast %struct.timespec* %5 to i8*
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32 }
define void @_PyThread_cond_after(i64 %0, %struct.timespec* nocapture writeonly %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, %struct.timezone* null)
%6 = srem i64 %0, 1000000
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%8 = load i64, i64* %7
%9 = add nsw i64 %8, %6
%10 = sdiv i64 %0, 1000000
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%12 = load i64, i64* %11
%13 = add nsw i64 %12, %10
%14 = sdiv i64 %9, 1000000
%15 = add nsw i64 %13, %14
%16 = srem i64 %9, 1000000
%17 = trunc i64 %15 to i32
%18 = trunc i64 %16 to i32
%19 = mul nsw i32 %18, 1000
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 %17, i32* %20
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i32 %19, i32* %21
ret void
}