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

/* Variables and functions */
void BFD_LONGUS2TIMEVAL(unsigned long long int *pus, struct timeval *ptv) {
  if (pus && ptv) {
    ptv->tv_sec = (*pus) / (1000000);
    ptv->tv_usec = (*pus) % (1000000);
  }
}


x86 assembly (clang, -O0):
<BFD_LONGUS2TIMEVAL>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <BFD_LONGUS2TIMEVAL+0x56>
cmpq   $0x0,-0x10(%rbp)
je     1156 <BFD_LONGUS2TIMEVAL+0x56>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %rcx
mov    -0x10(%rbp),%rax
mov    %rdx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<BFD_LONGUS2TIMEVAL>:
test   %rdi,%rdi
je     113c <BFD_LONGUS2TIMEVAL+0x3c>
test   %rsi,%rsi
je     113c <BFD_LONGUS2TIMEVAL+0x3c>
movabs $0x431bde82d7b634db,%rcx
de 1b 43
mov    %rcx,%rax
mulq   (%rdi)
shr    $0x12,%rdx
mov    %rdx,(%rsi)
mov    (%rdi),%rdi
mov    %rdi,%rax
mul    %rcx
shr    $0x12,%rdx
imul   $0xf4240,%rdx,%rax
sub    %rax,%rdi
mov    %rdi,0x8(%rsi)
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define void @BFD_LONGUS2TIMEVAL(i64* %0, %struct.timeval* %1) {
%3 = alloca i64*
%4 = alloca %struct.timeval*
store i64* %0, i64** %3
store %struct.timeval* %1, %struct.timeval** %4
%5 = load i64*, i64** %3
%6 = icmp ne i64* %5, null
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = load %struct.timeval*, %struct.timeval** %4
%9 = icmp ne %struct.timeval* %8, null
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i64*, i64** %3
%12 = load i64, i64* %11
%13 = udiv i64 %12, 1000000
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i64 %13, i64* %15
%16 = load i64*, i64** %3
%17 = load i64, i64* %16
%18 = urem i64 %17, 1000000
%19 = load %struct.timeval*, %struct.timeval** %4
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
store i64 %18, i64* %20
br label %21
21: ; preds = %10, %7, %2
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @BFD_LONGUS2TIMEVAL(i64* %0, %struct.timeval* writeonly %1) {
%3 = icmp ne i64* %0, null
%4 = icmp ne %struct.timeval* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i64, i64* %0
%8 = udiv i64 %7, 1000000
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i64 %8, i64* %9
%10 = load i64, i64* %0
%11 = urem i64 %10, 1000000
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i64 %11, i64* %12
br label %13
13: ; preds = %6, %2
ret void
}