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

/* Variables and functions */
int /*<<< orphan*/ EMACReset(int);
int /*<<< orphan*/ SysCtlDelay(int);
int /*<<< orphan*/ SysCtlPeripheralReady(int);
int /*<<< orphan*/ SysCtlPeripheralReset(int);
void EMACPHYConfigSet(uint32_t ui32Base, uint32_t ui32Config) {
  (*((volatile uint32_t *)(ui32Base + 0x00000FC4))) = ui32Config;
  if ((ui32Config & 0xC0000000) == 0x00000000) {
    SysCtlPeripheralReset(0xf0003000);
    while (!SysCtlPeripheralReady(0xf0003000)) {
    }
    SysCtlDelay(10000);
  }
  if ((ui32Config & 0xC0000000) == 0xC0000000) {
    (*((volatile uint32_t *)(0x400EC000 + 0x00000FC8))) |= 0x00010000;
  } else {
    (*((volatile uint32_t *)(0x400EC000 + 0x00000FC8))) &= ~0x00010000;
  }
  EMACReset(0x400EC000);
  SysCtlDelay(1000);
}


x86 assembly (clang, -O0):
<EMACPHYConfigSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xfc4,%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
and    $0xc0000000,%eax
cmp    $0x0,%eax
jne    11a6 <EMACPHYConfigSet+0x66>
mov    $0xf0003000,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0xf0003000,%edi
call   1050 <SysCtlPeripheralReady@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1197 <EMACPHYConfigSet+0x57>
jmp    119c <EMACPHYConfigSet+0x5c>
jmp    1178 <EMACPHYConfigSet+0x38>
mov    $0x2710,%edi
call   1040 <SysCtlDelay@plt>
mov    -0x8(%rbp),%eax
and    $0xc0000000,%eax
cmp    $0xc0000000,%eax
jne    11d2 <EMACPHYConfigSet+0x92>
mov    $0x400ecfc8,%eax
mov    (%rax),%ecx
or     $0x10000,%ecx
mov    $0x400ecfc8,%eax
mov    %ecx,(%rax)
jmp    11e6 <EMACPHYConfigSet+0xa6>
mov    $0x400ecfc8,%eax
mov    (%rax),%ecx
and    $0xfffeffff,%ecx
mov    $0x400ecfc8,%eax
mov    %ecx,(%rax)
mov    $0x400ec000,%edi
call   1060 <EMACReset@plt>
mov    $0x3e8,%edi
call   1040 <SysCtlDelay@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EMACPHYConfigSet>:
push   %rbx
mov    %esi,%ebx
movslq %edi,%rax
mov    %esi,0xfc4(%rax)
cmp    $0x3fffffff,%esi
ja     1178 <EMACPHYConfigSet+0x38>
mov    $0xf0003000,%edi
call   1030 <SysCtlPeripheralReset@plt>
xchg   %ax,%ax
mov    $0xf0003000,%edi
call   1050 <SysCtlPeripheralReady@plt>
test   %eax,%eax
je     1160 <EMACPHYConfigSet+0x20>
mov    $0x2710,%edi
call   1040 <SysCtlDelay@plt>
xor    %eax,%eax
cmp    $0xc0000000,%ebx
setae  %al
mov    $0xfffeffff,%ecx
and    0x400ecfc8,%ecx
shl    $0x10,%eax
or     %ecx,%eax
mov    %eax,0x400ecfc8
mov    $0x400ec000,%edi
call   1060 <EMACReset@plt>
mov    $0x3e8,%edi
pop    %rbx
jmp    1040 <SysCtlDelay@plt>

LLVM IR (-O0):
define void @EMACPHYConfigSet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 4036
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
store volatile i32 %5, i32* %9
%10 = load i32, i32* %4
%11 = and i32 %10, -1073741824
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = call i32 @SysCtlPeripheralReset(i32 -268423168)
br label %15
15: ; preds = %19, %13
%16 = call i32 @SysCtlPeripheralReady(i32 -268423168)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %20
19: ; preds = %15
br label %15
20: ; preds = %15
%21 = call i32 @SysCtlDelay(i32 10000)
br label %22
22: ; preds = %20, %2
%23 = load i32, i32* %4
%24 = and i32 %23, -1073741824
%25 = icmp eq i32 %24, -1073741824
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%28 = or i32 %27, 65536
store volatile i32 %28, i32* inttoptr (i64 1074712520 to i32*)
br label %32
29: ; preds = %22
%30 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%31 = and i32 %30, -65537
store volatile i32 %31, i32* inttoptr (i64 1074712520 to i32*)
br label %32
32: ; preds = %29, %26
%33 = call i32 @EMACReset(i32 1074708480)
%34 = call i32 @SysCtlDelay(i32 1000)
ret void
}

LLVM IR (-O2):
define void @EMACPHYConfigSet(i32 %0, i32 %1) {
%3 = add nsw i32 %0, 4036
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i32*
store volatile i32 %1, i32* %5
%6 = icmp ult i32 %1, 1073741824
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = tail call i32 @SysCtlPeripheralReset(i32 -268423168)
br label %9
9: ; preds = %9, %7
%10 = tail call i32 @SysCtlPeripheralReady(i32 -268423168)
%11 = icmp eq i32 %10, 0
br i1 %11, label %9, label %12
12: ; preds = %9
%13 = tail call i32 @SysCtlDelay(i32 10000)
br label %14
14: ; preds = %12, %2
%15 = icmp ugt i32 %1, -1073741825
%16 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%17 = and i32 %16, -65537
%18 = select i1 %15, i32 65536, i32 0
%19 = or i32 %17, %18
store volatile i32 %19, i32* inttoptr (i64 1074712520 to i32*)
%20 = tail call i32 @EMACReset(i32 1074708480)
%21 = tail call i32 @SysCtlDelay(i32 1000)
ret void
}