#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 PRCMSlowClkCtrGet();
int /*<<< orphan*/ RTCU16MSecRegWrite(unsigned short);
int /*<<< orphan*/ RTCU32SecRegWrite(unsigned long);
void PRCMRTCSet(unsigned long ulSecs, unsigned short usMsec) {
  unsigned long long ullMsec = 0;
  if (IsRTCUsed()) {
    ullMsec = (((unsigned long long)ulSecs << 10) | (usMsec & 0x3FF)) -
              (PRCMSlowClkCtrGet() >> 5);
    RTCU32SecRegWrite(((unsigned long)(ullMsec >> 10)));
    RTCU16MSecRegWrite(((unsigned short)(ullMsec & 0x3FF)));
  }
  return;
}


x86 assembly (clang, -O0):
<PRCMRTCSet>:
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     11c1 <PRCMRTCSet+0x81>
mov    -0x8(%rbp),%rax
shl    $0xa,%rax
movzwl -0xa(%rbp),%ecx
and    $0x3ff,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <PRCMSlowClkCtrGet@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sar    $0x5,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shr    $0xa,%rdi
call   1050 <RTCU32SecRegWrite@plt>
mov    -0x18(%rbp),%rax
and    $0x3ff,%rax
movzwl %ax,%edi
call   1030 <RTCU16MSecRegWrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMRTCSet>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <IsRTCUsed@plt>
test   %rax,%rax
je     1195 <PRCMRTCSet+0x55>
shl    $0xa,%r14
and    $0x3ff,%r15d
or     %r14,%r15
xor    %eax,%eax
call   1040 <PRCMSlowClkCtrGet@plt>
sar    $0x5,%eax
neg    %eax
movslq %eax,%rbx
add    %r15,%rbx
mov    %rbx,%rdi
shr    $0xa,%rdi
call   1050 <RTCU32SecRegWrite@plt>
and    $0x3ff,%ebx
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <RTCU16MSecRegWrite@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @PRCMRTCSet(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 %27
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
%16 = call i32 (...) @PRCMSlowClkCtrGet()
%17 = ashr i32 %16, 5
%18 = sext i32 %17 to i64
%19 = sub i64 %15, %18
store i64 %19, i64* %5
%20 = load i64, i64* %5
%21 = lshr i64 %20, 10
%22 = call i32 @RTCU32SecRegWrite(i64 %21)
%23 = load i64, i64* %5
%24 = and i64 %23, 1023
%25 = trunc i64 %24 to i16
%26 = call i32 @RTCU16MSecRegWrite(i16 zeroext %25)
br label %27
27: ; preds = %8, %2
ret void
}

LLVM IR (-O2):
define void @PRCMRTCSet(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 = or i64 %6, %8
%10 = tail call i32 (...) @PRCMSlowClkCtrGet()
%11 = ashr i32 %10, 5
%12 = sub nsw i32 0, %11
%13 = sext i32 %12 to i64
%14 = add i64 %9, %13
%15 = lshr i64 %14, 10
%16 = tail call i32 @RTCU32SecRegWrite(i64 %15)
%17 = trunc i64 %14 to i16
%18 = and i16 %17, 1023
%19 = tail call i32 @RTCU16MSecRegWrite(i16 zeroext %18)
br label %20
20: ; preds = %5, %2
ret void
}