#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 */

/* Variables and functions */
unsigned int phy_read(unsigned char *, unsigned int, int);
int /*<<< orphan*/ phy_write(unsigned char *, unsigned int, int, int);
unsigned int phy_read_mmd(unsigned char *mdio, unsigned int devad,
                          unsigned int phyad, unsigned int reg) {
  phy_write(mdio, phyad, 0x0D, devad);
  phy_write(mdio, phyad, 0x0E, reg);
  phy_write(mdio, phyad, 0x0D, (1 << 14) | devad);
  return phy_read(mdio, phyad, 0x0E);
}


x86 assembly (clang, -O0):
<phy_read_mmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    $0xd,%edx
call   1030 <phy_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    $0xe,%edx
call   1030 <phy_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%ecx
or     $0x4000,%ecx
mov    $0xd,%edx
call   1030 <phy_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    $0xe,%edx
call   1040 <phy_read@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phy_read_mmd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%rbp
mov    %edx,%esi
mov    $0xd,%edx
mov    %ebx,%ecx
call   1030 <phy_write@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    $0xe,%edx
mov    %r14d,%ecx
call   1030 <phy_write@plt>
or     $0x4000,%ebx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    $0xd,%edx
mov    %ebx,%ecx
call   1030 <phy_write@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    $0xe,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <phy_read@plt>

LLVM IR (-O0):
define i32 @phy_read_mmd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = call i32 @phy_write(i8* %9, i32 %10, i32 13, i32 %11)
%13 = load i8*, i8** %5
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 @phy_write(i8* %13, i32 %14, i32 14, i32 %15)
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = or i32 16384, %19
%21 = call i32 @phy_write(i8* %17, i32 %18, i32 13, i32 %20)
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = call i32 @phy_read(i8* %22, i32 %23, i32 14)
ret i32 %24
}

LLVM IR (-O2):
define i32 @phy_read_mmd(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @phy_write(i8* %0, i32 %2, i32 13, i32 %1)
%6 = tail call i32 @phy_write(i8* %0, i32 %2, i32 14, i32 %3)
%7 = or i32 %1, 16384
%8 = tail call i32 @phy_write(i8* %0, i32 %2, i32 13, i32 %7)
%9 = tail call i32 @phy_read(i8* %0, i32 %2, i32 14)
ret i32 %9
}