#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 /*<<< orphan*/ uint32_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
int /*<<< orphan*/ EMACPHYWrite(int /*<<< orphan*/, int, int, int);
void EMACPHYMMDWrite(uint32_t ui32Base, uint8_t ui8PhyAddr,
                     uint16_t ui16RegAddr, uint16_t ui16Data) {
  ASSERT(ui8PhyAddr < 32);
  EMACPHYWrite(ui32Base, ui8PhyAddr, 0x0000000D,
               ((ui16RegAddr & 0xF000) >> 12));
  EMACPHYWrite(ui32Base, ui8PhyAddr, 0x0000000E, ((ui16RegAddr & 0x0FFF)));
  EMACPHYWrite(ui32Base, ui8PhyAddr, 0x0000000D,
               (0x4000 | ((ui16RegAddr & 0xF000) >> 12)));
  EMACPHYWrite(ui32Base, ui8PhyAddr, 0x0000000D, ui16Data);
}


x86 assembly (clang, -O0):
<EMACPHYMMDWrite>:
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   $0x20,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
and    $0xf000,%ecx
sar    $0xc,%ecx
mov    $0xd,%edx
call   1040 <EMACPHYWrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
and    $0xfff,%ecx
mov    $0xe,%edx
call   1040 <EMACPHYWrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
and    $0xf000,%ecx
sar    $0xc,%ecx
or     $0x4000,%ecx
mov    $0xd,%edx
call   1040 <EMACPHYWrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%ecx
mov    $0xd,%edx
call   1040 <EMACPHYWrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACPHYMMDWrite>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r15d
xor    %edi,%edi
cmp    $0x20,%esi
setl   %dil
call   1030 <ASSERT@plt>
mov    %ebp,%ebx
shr    $0xc,%ebx
and    $0xf,%ebx
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0xd,%edx
mov    %ebx,%ecx
call   1040 <EMACPHYWrite@plt>
and    $0xfff,%ebp
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0xe,%edx
mov    %ebp,%ecx
call   1040 <EMACPHYWrite@plt>
or     $0x4000,%ebx
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0xd,%edx
mov    %ebx,%ecx
call   1040 <EMACPHYWrite@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    $0xd,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <EMACPHYWrite@plt>

LLVM IR (-O0):
define void @EMACPHYMMDWrite(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* %6
%10 = icmp slt i32 %9, 32
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = and i32 %15, 61440
%17 = ashr i32 %16, 12
%18 = call i32 @EMACPHYWrite(i32 %13, i32 %14, i32 13, i32 %17)
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = and i32 %21, 4095
%23 = call i32 @EMACPHYWrite(i32 %19, i32 %20, i32 14, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = and i32 %26, 61440
%28 = ashr i32 %27, 12
%29 = or i32 16384, %28
%30 = call i32 @EMACPHYWrite(i32 %24, i32 %25, i32 13, i32 %29)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = call i32 @EMACPHYWrite(i32 %31, i32 %32, i32 13, i32 %33)
ret void
}

LLVM IR (-O2):
define void @EMACPHYMMDWrite(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %1, 32
%6 = zext i1 %5 to i32
%7 = tail call i32 @ASSERT(i32 %6)
%8 = lshr i32 %2, 12
%9 = and i32 %8, 15
%10 = tail call i32 @EMACPHYWrite(i32 %0, i32 %1, i32 13, i32 %9)
%11 = and i32 %2, 4095
%12 = tail call i32 @EMACPHYWrite(i32 %0, i32 %1, i32 14, i32 %11)
%13 = or i32 %9, 16384
%14 = tail call i32 @EMACPHYWrite(i32 %0, i32 %1, i32 13, i32 %13)
%15 = tail call i32 @EMACPHYWrite(i32 %0, i32 %1, i32 13, i32 %3)
ret void
}