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

/* Variables and functions */
void rtime_to_atime(struct timeval *basetime, struct timeval *rtime,
                    struct timeval *atime) {
  long long btime, r, a;
  btime = (long long)basetime->tv_sec;
  btime = btime * 1000000 + (long long)basetime->tv_usec;
  r = (long long)rtime->tv_sec;
  r = r * 1000000 + (long long)rtime->tv_usec;
  a = btime + r;
  atime->tv_usec = (long)(a % 1000000);
  atime->tv_sec = (long)((a - atime->tv_usec) / 1000000);
}


x86 assembly (clang, -O0):
<rtime_to_atime>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
imul   $0xf4240,-0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    0x8(%rcx),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
imul   $0xf4240,-0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    0x8(%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    -0x18(%rbp),%rax
mov    %rdx,0x8(%rax)
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    0x8(%rcx),%rax
mov    $0xf4240,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtime_to_atime>:
mov    %rdx,%rcx
mov    (%rsi),%rax
add    (%rdi),%rax
mov    0x8(%rsi),%rsi
imul   $0xf4240,%rax,%rax
add    0x8(%rdi),%rsi
add    %rax,%rsi
movabs $0x431bde82d7b634db,%rdx
de 1b 43
mov    %rsi,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x12,%rdx
add    %rax,%rdx
imul   $0xf4240,%rdx,%rax
sub    %rax,%rsi
mov    %rsi,0x8(%rcx)
mov    %rdx,(%rcx)
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @rtime_to_atime(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%10 = load %struct.timeval*, %struct.timeval** %4
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load i64, i64* %11
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = mul nsw i64 %13, 1000000
%15 = load %struct.timeval*, %struct.timeval** %4
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = add nsw i64 %14, %17
store i64 %18, i64* %7
%19 = load %struct.timeval*, %struct.timeval** %5
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%21 = load i64, i64* %20
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = mul nsw i64 %22, 1000000
%24 = load %struct.timeval*, %struct.timeval** %5
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%26 = load i64, i64* %25
%27 = add nsw i64 %23, %26
store i64 %27, i64* %8
%28 = load i64, i64* %7
%29 = load i64, i64* %8
%30 = add nsw i64 %28, %29
store i64 %30, i64* %9
%31 = load i64, i64* %9
%32 = srem i64 %31, 1000000
%33 = load %struct.timeval*, %struct.timeval** %6
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 1
store i64 %32, i64* %34
%35 = load i64, i64* %9
%36 = load %struct.timeval*, %struct.timeval** %6
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %36, i32 0, i32 1
%38 = load i64, i64* %37
%39 = sub nsw i64 %35, %38
%40 = sdiv i64 %39, 1000000
%41 = load %struct.timeval*, %struct.timeval** %6
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %41, i32 0, i32 0
store i64 %40, i64* %42
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @rtime_to_atime(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture writeonly %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%7 = load i64, i64* %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%11 = load i64, i64* %10
%12 = add i64 %9, %5
%13 = mul i64 %12, 1000000
%14 = add i64 %11, %7
%15 = add i64 %14, %13
%16 = srem i64 %15, 1000000
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
store i64 %16, i64* %17
%18 = sdiv i64 %15, 1000000
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
store i64 %18, i64* %19
ret void
}