#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 EMACIntClear(uint32_t ui32Base, uint32_t ui32IntFlags) {
  ASSERT(ui32Base == 0x400EC000);
  if (ui32IntFlags & (0x00000001 | 0x00000040 | 0x00004000 | 0x00000004)) {
    ui32IntFlags |= 0x00010000;
  }
  if (ui32IntFlags &
      (0x00000002 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000080 |
       0x00000100 | 0x00000200 | 0x00000400 | 0x00002000)) {
    ui32IntFlags |= 0x00008000;
  }
  if (ui32IntFlags & ~0x80000000) {
    (*((volatile uint32_t *)(ui32Base + 0x00000C14))) =
        (ui32IntFlags & ~0x80000000);
  }
  if (ui32IntFlags & 0x80000000) {
    (*((volatile uint32_t *)(ui32Base + 0x00000FD8))) |= 0x00000001;
  }
}


x86 assembly (clang, -O0):
<EMACIntClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x400ec000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%eax
and    $0x4045,%eax
cmp    $0x0,%eax
je     114e <EMACIntClear+0x3e>
mov    -0x8(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x27ba,%eax
cmp    $0x0,%eax
je     116a <EMACIntClear+0x5a>
mov    -0x8(%rbp),%eax
or     $0x8000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7fffffff,%eax
cmp    $0x0,%eax
je     1190 <EMACIntClear+0x80>
mov    -0x8(%rbp),%ecx
and    $0x7fffffff,%ecx
mov    -0x4(%rbp),%eax
add    $0xc14,%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     11b2 <EMACIntClear+0xa2>
mov    -0x4(%rbp),%eax
add    $0xfd8,%eax
cltq
mov    (%rax),%ecx
or     $0x1,%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACIntClear>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x400ec000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
mov    %ebx,%ecx
or     $0x10000,%ecx
test   $0x4045,%ebx
cmove  %ebx,%ecx
mov    %ecx,%eax
or     $0x8000,%eax
test   $0x27ba,%ecx
cmove  %ecx,%eax
mov    %eax,%edx
movslq %ebp,%rcx
and    $0x7fffffff,%edx
je     115c <EMACIntClear+0x4c>
mov    %edx,0xc14(%rcx)
test   %eax,%eax
jns    1167 <EMACIntClear+0x57>
orl    $0x1,0xfd8(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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