#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 */

/* Variables and functions */
scalar_t__ IsRTCUsed();
int /*<<< orphan*/ PRCMSlowClkCtrMatchSet(unsigned long long);
int RTCU16MSecRegRead();
scalar_t__ RTCU32SecRegRead();
void PRCMRTCMatchSet(unsigned long ulSecs, unsigned short usMsec) {
  unsigned long long ullMsec = 0;
  if (IsRTCUsed()) {
    ullMsec = (((unsigned long long)ulSecs << 10) | (usMsec & 0x3FF));
    ullMsec -= (((unsigned long long)RTCU32SecRegRead() << 10) |
                (RTCU16MSecRegRead() & 0x3FF));
    (PRCMSlowClkCtrMatchSet((ullMsec & 0x3ffffffffff) << 5));
  }
  return;
}


x86 assembly (clang, -O0):
<PRCMRTCMatchSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <IsRTCUsed@plt>
cmp    $0x0,%rax
je     11ce <PRCMRTCMatchSet+0x8e>
mov    -0x8(%rbp),%rax
shl    $0xa,%rax
movzwl -0xa(%rbp),%ecx
and    $0x3ff,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <RTCU32SecRegRead@plt>
shl    $0xa,%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <RTCU16MSecRegRead@plt>
mov    -0x20(%rbp),%rcx
and    $0x3ff,%eax
cltq
or     %rax,%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
movabs $0x3ffffffffff,%rdi
and    -0x18(%rbp),%rdi
shl    $0x5,%rdi
call   1050 <PRCMSlowClkCtrMatchSet@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMRTCMatchSet>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <IsRTCUsed@plt>
test   %rax,%rax
je     119c <PRCMRTCMatchSet+0x5c>
shl    $0xa,%r14
and    $0x3ff,%ebx
or     %r14,%rbx
xor    %eax,%eax
call   1040 <RTCU32SecRegRead@plt>
shl    $0xa,%rax
sub    %rax,%rbx
xor    %eax,%eax
call   1030 <RTCU16MSecRegRead@plt>
and    $0x3ff,%eax
sub    %rax,%rbx
shl    $0x5,%rbx
movabs $0x7fffffffffe0,%rdi
and    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <PRCMSlowClkCtrMatchSet@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @PRCMRTCMatchSet(i64 %0, i16 zeroext %1) {
%3 = alloca i64
%4 = alloca i16
%5 = alloca i64
store i64 %0, i64* %3
store i16 %1, i16* %4
store i64 0, i64* %5
%6 = call i64 (...) @IsRTCUsed()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %2
%9 = load i64, i64* %3
%10 = shl i64 %9, 10
%11 = load i16, i16* %4
%12 = zext i16 %11 to i32
%13 = and i32 %12, 1023
%14 = sext i32 %13 to i64
%15 = or i64 %10, %14
store i64 %15, i64* %5
%16 = call i64 (...) @RTCU32SecRegRead()
%17 = shl i64 %16, 10
%18 = call i32 (...) @RTCU16MSecRegRead()
%19 = and i32 %18, 1023
%20 = sext i32 %19 to i64
%21 = or i64 %17, %20
%22 = load i64, i64* %5
%23 = sub i64 %22, %21
store i64 %23, i64* %5
%24 = load i64, i64* %5
%25 = and i64 %24, 4398046511103
%26 = shl i64 %25, 5
%27 = call i32 @PRCMSlowClkCtrMatchSet(i64 %26)
br label %28
28: ; preds = %8, %2
ret void
}

LLVM IR (-O2):
define void @PRCMRTCMatchSet(i64 %0, i16 zeroext %1) {
%3 = tail call i64 (...) @IsRTCUsed()
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = shl i64 %0, 10
%7 = and i16 %1, 1023
%8 = zext i16 %7 to i64
%9 = tail call i64 (...) @RTCU32SecRegRead()
%10 = mul i64 %9, -1024
%11 = tail call i32 (...) @RTCU16MSecRegRead()
%12 = and i32 %11, 1023
%13 = zext i32 %12 to i64
%14 = or i64 %6, %8
%15 = add i64 %14, %10
%16 = sub i64 %15, %13
%17 = shl i64 %16, 5
%18 = and i64 %17, 140737488355296
%19 = tail call i32 @PRCMSlowClkCtrMatchSet(i64 %18)
br label %20
20: ; preds = %5, %2
ret void
}