#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);
uint32_t EMACIntStatus(uint32_t ui32Base, bool bMasked) {
  uint32_t ui32Val, ui32PHYStat;
  ASSERT(ui32Base == 0x400EC000);
  ui32Val = (*((volatile uint32_t *)(ui32Base + 0x00000C14)));
  ui32Val &= ~(0x03800000 | 0x00700000 | 0x000E0000);
  if (bMasked) {
    ui32Val &= ((0x40000000 | 0x20000000 | 0x10000000 | 0x08000000) |
                (*((volatile uint32_t *)(ui32Base + 0x00000C1C))));
  }
  if (bMasked) {
    ui32PHYStat = (*((volatile uint32_t *)(ui32Base + 0x00000FD8)));
  } else {
    ui32PHYStat = (*((volatile uint32_t *)(ui32Base + 0x00000FD0)));
  }
  if (ui32PHYStat & 0x00000001) {
    ui32Val |= 0x80000000;
  }
  return (ui32Val);
}


x86 assembly (clang, -O0):
<EMACIntStatus>:
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    -0x4(%rbp),%eax
add    $0xc14,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfc01ffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     116d <EMACIntStatus+0x5d>
mov    -0x4(%rbp),%eax
add    $0xc1c,%eax
cltq
mov    (%rax),%eax
or     $0x78000000,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     118b <EMACIntStatus+0x7b>
mov    -0x4(%rbp),%eax
add    $0xfd8,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    119a <EMACIntStatus+0x8a>
mov    -0x4(%rbp),%eax
add    $0xfd0,%eax
cltq
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11b4 <EMACIntStatus+0xa4>
mov    -0xc(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACIntStatus>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x400ec000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
movslq %ebp,%rax
mov    $0xfc01ffff,%ecx
and    0xc14(%rax),%ecx
test   %ebx,%ebx
je     114e <EMACIntStatus+0x3e>
mov    $0x78000000,%edx
or     0xc1c(%rax),%edx
and    %edx,%ecx
mov    $0xfd8,%edx
jmp    1153 <EMACIntStatus+0x43>
mov    $0xfd0,%edx
mov    %edx,%edx
mov    (%rdx,%rax,1),%eax
shl    $0x1f,%eax
or     %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @EMACIntStatus(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 1074708480
%4 = zext i1 %3 to i32
%5 = tail call i32 @ASSERT(i32 %4)
%6 = add nsw i32 %0, 3092
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i32*
%9 = load volatile i32, i32* %8
%10 = and i32 %9, -66977793
%11 = icmp eq i32 %1, 0
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = add nsw i32 %0, 3100
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
%17 = or i32 %16, 2013265920
%18 = and i32 %17, %10
br label %19
19: ; preds = %12, %2
%20 = phi i32 [ 4056, %12 ], [ 4048, %2 ]
%21 = phi i32 [ %18, %12 ], [ %10, %2 ]
%22 = add nsw i32 %20, %0
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
%25 = load volatile i32, i32* %24
%26 = shl i32 %25, 31
%27 = or i32 %26, %21
ret i32 %27
}