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

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int EMACPHYRead(int, int, int);
int /*<<< orphan*/ EMACPHYWrite(int, int, int, int);
uint16_t EMACPHYExtendedRead(uint32_t ui32Base, uint8_t ui8PhyAddr,
                             uint16_t ui16RegAddr) {
  ASSERT(ui8PhyAddr < 32);
  ASSERT(ui32Base == 0x400EC000);
  EMACPHYWrite(0x400EC000, ui8PhyAddr, 0x0000000D, 0x001F);
  EMACPHYWrite(0x400EC000, ui8PhyAddr, 0x0000000E, ui16RegAddr);
  EMACPHYWrite(0x400EC000, ui8PhyAddr, 0x0000000D, 0x401F);
  return (EMACPHYRead(0x400EC000, ui8PhyAddr, 0x0000000E));
}


x86 assembly (clang, -O0):
<EMACPHYExtendedRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x20,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
cmpl   $0x400ec000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <ASSERT@plt>
mov    -0x8(%rbp),%esi
mov    $0x400ec000,%edi
mov    $0xd,%edx
mov    $0x1f,%ecx
call   1050 <EMACPHYWrite@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    $0x400ec000,%edi
mov    $0xe,%edx
call   1050 <EMACPHYWrite@plt>
mov    -0x8(%rbp),%esi
mov    $0x400ec000,%edi
mov    $0xd,%edx
mov    $0x401f,%ecx
call   1050 <EMACPHYWrite@plt>
mov    -0x8(%rbp),%esi
mov    $0x400ec000,%edi
mov    $0xe,%edx
call   1030 <EMACPHYRead@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACPHYExtendedRead>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x20,%esi
setl   %dil
call   1040 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x400ec000,%ebp
sete   %dil
call   1040 <ASSERT@plt>
mov    $0x400ec000,%edi
mov    %ebx,%esi
mov    $0xd,%edx
mov    $0x1f,%ecx
call   1050 <EMACPHYWrite@plt>
mov    $0x400ec000,%edi
mov    %ebx,%esi
mov    $0xe,%edx
mov    %r14d,%ecx
call   1050 <EMACPHYWrite@plt>
mov    $0x400ec000,%edi
mov    %ebx,%esi
mov    $0xd,%edx
mov    $0x401f,%ecx
call   1050 <EMACPHYWrite@plt>
mov    $0x400ec000,%edi
mov    %ebx,%esi
mov    $0xe,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <EMACPHYRead@plt>

LLVM IR (-O0):
define i32 @EMACPHYExtendedRead(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
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 32
%9 = zext i1 %8 to i32
%10 = call i32 @ASSERT(i32 %9)
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1074708480
%13 = zext i1 %12 to i32
%14 = call i32 @ASSERT(i32 %13)
%15 = load i32, i32* %5
%16 = call i32 @EMACPHYWrite(i32 1074708480, i32 %15, i32 13, i32 31)
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @EMACPHYWrite(i32 1074708480, i32 %17, i32 14, i32 %18)
%20 = load i32, i32* %5
%21 = call i32 @EMACPHYWrite(i32 1074708480, i32 %20, i32 13, i32 16415)
%22 = load i32, i32* %5
%23 = call i32 @EMACPHYRead(i32 1074708480, i32 %22, i32 14)
ret i32 %23
}

LLVM IR (-O2):
define i32 @EMACPHYExtendedRead(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 32
%5 = zext i1 %4 to i32
%6 = tail call i32 @ASSERT(i32 %5)
%7 = icmp eq i32 %0, 1074708480
%8 = zext i1 %7 to i32
%9 = tail call i32 @ASSERT(i32 %8)
%10 = tail call i32 @EMACPHYWrite(i32 1074708480, i32 %1, i32 13, i32 31)
%11 = tail call i32 @EMACPHYWrite(i32 1074708480, i32 %1, i32 14, i32 %2)
%12 = tail call i32 @EMACPHYWrite(i32 1074708480, i32 %1, i32 13, i32 16415)
%13 = tail call i32 @EMACPHYRead(i32 1074708480, i32 %1, i32 14)
ret i32 %13
}