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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
void EMACTimestampSysTimeUpdate(uint32_t ui32Base, uint32_t ui32Seconds,
                                uint32_t ui32SubSeconds, bool bInc) {
  ASSERT(ui32Base == 0x400EC000);
  (*((volatile uint32_t *)(ui32Base + 0x00000710))) = ui32Seconds;
  (*((volatile uint32_t *)(ui32Base + 0x00000714))) =
      ui32SubSeconds | (bInc ? 0 : 0x80000000);
  while ((*((volatile uint32_t *)(ui32Base + 0x00000700))) & 0x00000008) {
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000700))) |= 0x00000008;
}


x86 assembly (clang, -O0):
<EMACTimestampSysTimeUpdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x400ec000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x710,%eax
cltq
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%esi
mov    $0x80000000,%eax
xor    %edx,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
or     %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x714,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x700,%eax
cltq
mov    (%rax),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1185 <EMACTimestampSysTimeUpdate+0x75>
jmp    1168 <EMACTimestampSysTimeUpdate+0x58>
mov    -0x4(%rbp),%eax
add    $0x700,%eax
cltq
mov    (%rax),%ecx
or     $0x8,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACTimestampSysTimeUpdate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x400ec000,%ebx
sete   %dil
call   1030 <ASSERT@plt>
movslq %ebx,%rax
mov    %ebp,0x710(%rax)
xor    %ecx,%ecx
test   %r15d,%r15d
sete   %cl
shl    $0x1f,%ecx
or     %r14d,%ecx
mov    %ecx,0x714(%rax)
nop
testl  $0x8,0x700(%rax)
jne    1150 <EMACTimestampSysTimeUpdate+0x40>
orl    $0x8,0x700(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @EMACTimestampSysTimeUpdate(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1074708480
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1808
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store volatile i32 %13, i32* %17
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 0, i32 -2147483648
%23 = or i32 %18, %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1812
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
store volatile i32 %23, i32* %27
br label %28
28: ; preds = %36, %4
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1792
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = load volatile i32, i32* %32
%34 = and i32 %33, 8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %28
br label %28
37: ; preds = %28
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1792
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i32*
%42 = load volatile i32, i32* %41
%43 = or i32 %42, 8
store volatile i32 %43, i32* %41
ret void
}

LLVM IR (-O2):
define void @EMACTimestampSysTimeUpdate(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %0, 1074708480
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = add nsw i32 %0, 1808
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
store volatile i32 %1, i32* %10
%11 = icmp eq i32 %3, 0
%12 = select i1 %11, i32 -2147483648, i32 0
%13 = or i32 %12, %2
%14 = add nsw i32 %0, 1812
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store volatile i32 %13, i32* %16
%17 = add nsw i32 %0, 1792
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
br label %20
20: ; preds = %20, %4
%21 = load volatile i32, i32* %19
%22 = and i32 %21, 8
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %20
24: ; preds = %20
%25 = load volatile i32, i32* %19
%26 = or i32 %25, 8
store volatile i32 %26, i32* %19
ret void
}