#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;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
uint64_t NRF_802154_US_TO_RTC_TICKS(uint64_t time) {
  uint64_t t1, u1;
  uint64_t result;
  t1 = ((time >> 13) * 0x8637bd0) >> 28;
  result = t1 * 512;
  t1 = time - t1 * 15625;
  assert(t1 <= 1453125);
  u1 = (t1 * 0x431bde82d7b);
  u1 += 0x7fffffffffff;
  u1 >>= 47;
  result += u1;
  return result;
}


x86 assembly (clang, -O0):
<NRF_802154_US_TO_RTC_TICKS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0xd,%eax
imul   $0x8637bd0,%eax,%eax
sar    $0x1c,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x9,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   $0x3d09,-0x8(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x162c45,-0x8(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0x8(%rbp),%rax
movabs $0x431bde82d7b,%rcx
imul   %rcx,%rax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movabs $0x7fffffffffff,%rcx
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2f,%ecx
sar    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NRF_802154_US_TO_RTC_TICKS>:
mov    %edi,%eax
sar    $0xd,%eax
imul   $0x8637bd0,%eax,%eax
sar    $0x1c,%eax
imul   $0xffffc2f7,%eax,%eax
add    %edi,%eax
xor    %edi,%edi
cmp    $0x162c46,%eax
setl   %dil
jmp    1030 <assert@plt>

LLVM IR (-O0):
define i32 @NRF_802154_US_TO_RTC_TICKS(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = ashr i32 %6, 13
%8 = mul nsw i32 %7, 140737488
%9 = ashr i32 %8, 28
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = mul nsw i32 %10, 512
store i32 %11, i32* %5
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 15625
%15 = sub nsw i32 %12, %14
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 1453125
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = mul nsw i64 %21, 4611686018427
%23 = trunc i64 %22 to i32
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, 140737488355327
%27 = trunc i64 %26 to i32
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = ashr i32 %28, 47
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = add nsw i32 %31, %30
store i32 %32, i32* %5
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @NRF_802154_US_TO_RTC_TICKS(i32 %0) {
%2 = ashr i32 %0, 13
%3 = mul nsw i32 %2, 140737488
%4 = ashr i32 %3, 28
%5 = mul nsw i32 %4, -15625
%6 = add i32 %5, %0
%7 = icmp slt i32 %6, 1453126
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
ret i32 poison
}