#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 */
void EMACPHYWrite(uint32_t ui32Base, uint8_t ui8PhyAddr, uint8_t ui8RegAddr,
                  uint16_t ui16Data) {
  ;
  ;
  while ((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x00000001) {
  }
  (*((volatile uint32_t *)(ui32Base + 0x00000014))) = ui16Data;
  (*((volatile uint32_t *)(ui32Base + 0x00000010))) =
      (((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x0000003C) |
       (ui8RegAddr << 6) | (ui8PhyAddr << 11) | 0x00000002 | 0x00000001);
  while ((*((volatile uint32_t *)(ui32Base + 0x00000010))) & 0x00000001) {
  }
}


x86 assembly (clang, -O0):
<EMACPHYWrite>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%eax
cltq
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     112b <EMACPHYWrite+0x2b>
jmp    1110 <EMACPHYWrite+0x10>
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x14,%eax
cltq
mov    %ecx,(%rax)
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     $0x2,%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     1180 <EMACPHYWrite+0x80>
jmp    1165 <EMACPHYWrite+0x65>
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACPHYWrite>:
movslq %edi,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rax),%edi
test   $0x1,%dil
jne    1110 <EMACPHYWrite+0x10>
mov    %ecx,0x14(%rax)
mov    0x10(%rax),%ecx
and    $0x3c,%ecx
shl    $0x6,%edx
or     %ecx,%edx
shl    $0xb,%esi
or     %edx,%esi
or     $0x3,%esi
mov    %esi,0x10(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rax),%ecx
test   $0x1,%cl
jne    1140 <EMACPHYWrite+0x40>
ret

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

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