#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 uint8_t;
typedef int uint32_t;
typedef int volatile uint16_t;

/* Variables and functions */
uint16_t EMACPHYRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
                     uint8_t ui8RegAddr) {
  ;
  ;
  while ((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x00000001) {
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000010))) =
      (((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x0000003C) |
       (ui8RegAddr << 6) | (ui8PhyAddr << 11) | 0x00000001);
  while ((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x00000001) {
  }
  return ((*((volatile uint32_t *)(ui32Base + 0x00000014))) & 0x0000FFFF);
}


x86 assembly (clang, -O0):
<EMACPHYRead>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1128 <EMACPHYRead+0x28>
jmp    110d <EMACPHYRead+0xd>
mov    -0x4(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%ecx
and    $0x3c,%ecx
mov    -0xc(%rbp),%eax
shl    $0x6,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%eax
shl    $0xb,%eax
or     %eax,%ecx
or     $0x1,%ecx
mov    -0x4(%rbp),%eax
add    $0x10,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116d <EMACPHYRead+0x6d>
jmp    1152 <EMACPHYRead+0x52>
mov    -0x4(%rbp),%eax
add    $0x14,%eax
cltq
mov    (%rax),%eax
and    $0xffff,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACPHYRead>:
movslq %edi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rax),%ecx
test   $0x1,%cl
jne    1110 <EMACPHYRead+0x10>
mov    0x10(%rax),%ecx
and    $0x3c,%ecx
shl    $0x6,%edx
or     %ecx,%edx
shl    $0xb,%esi
or     %edx,%esi
or     $0x1,%esi
mov    %esi,0x10(%rax)
xchg   %ax,%ax
mov    0x10(%rax),%ecx
test   $0x1,%cl
jne    1130 <EMACPHYRead+0x30>
mov    0x14(%rax),%eax
movzwl %ax,%eax
ret

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

LLVM IR (-O2):
define i32 @EMACPHYRead(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %0, 16
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i32*
br label %7
7: ; preds = %7, %3
%8 = load volatile i32, i32* %6
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = load volatile i32, i32* %6
%13 = and i32 %12, 60
%14 = shl i32 %2, 6
%15 = or i32 %13, %14
%16 = shl i32 %1, 11
%17 = or i32 %16, %15
%18 = or i32 %17, 1
store volatile i32 %18, i32* %6
br label %19
19: ; preds = %19, %11
%20 = load volatile i32, i32* %6
%21 = and i32 %20, 1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %19
23: ; preds = %19
%24 = add nsw i32 %0, 20
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = load volatile i32, i32* %26
%28 = and i32 %27, 65535
ret i32 %28
}