#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) {
  uint32_t ui32Val;
  ui32Val = (*((volatile uint32_t *)(ui32Base + 0x00000FC4))) & 0xC0000000;
  (*((volatile uint32_t *)(ui32Base + 0x00000FC4))) = ui32Config;
  if ((ui32Config & 0xC0000000) == 0x00000000) {
    SysCtlPeripheralReset(0xf0003000);
    while (!SysCtlPeripheralReady(0xf0003000)) {
    }
    SysCtlDelay(1000);
  }
  if ((ui32Config & 0xC0000000) == 0xC0000000) {
    (*((volatile uint32_t *)(0x400EC000 + 0x00000FC8))) |=
        (0x00020000 | 0x00010000);
  } else {
    (*((volatile uint32_t *)(0x400EC000 + 0x00000FC8))) &=
        ~(0x00020000 | 0x00010000);
  }
  if (ui32Val != (ui32Config & 0xC0000000)) {
    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    -0x4(%rbp),%eax
add    $0xfc4,%eax
cltq
mov    (%rax),%eax
and    $0xc0000000,%eax
mov    %eax,-0xc(%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    11ba <EMACPHYConfigSet+0x7a>
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    11ab <EMACPHYConfigSet+0x6b>
jmp    11b0 <EMACPHYConfigSet+0x70>
jmp    118c <EMACPHYConfigSet+0x4c>
mov    $0x3e8,%edi
call   1040 <SysCtlDelay@plt>
mov    -0x8(%rbp),%eax
and    $0xc0000000,%eax
cmp    $0xc0000000,%eax
jne    11e6 <EMACPHYConfigSet+0xa6>
mov    $0x400ecfc8,%eax
mov    (%rax),%ecx
or     $0x30000,%ecx
mov    $0x400ecfc8,%eax
mov    %ecx,(%rax)
jmp    11fa <EMACPHYConfigSet+0xba>
mov    $0x400ecfc8,%eax
mov    (%rax),%ecx
and    $0xfffcffff,%ecx
mov    $0x400ecfc8,%eax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0xc0000000,%ecx
cmp    %ecx,%eax
je     1222 <EMACPHYConfigSet+0xe2>
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   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
movslq %edi,%rax
mov    $0xc0000000,%r14d
and    0xfc4(%rax),%r14d
mov    %esi,0xfc4(%rax)
mov    %esi,%ebp
and    $0xc0000000,%ebp
jne    1188 <EMACPHYConfigSet+0x48>
mov    $0xf0003000,%edi
call   1030 <SysCtlPeripheralReset@plt>
mov    $0xf0003000,%edi
call   1050 <SysCtlPeripheralReady@plt>
test   %eax,%eax
je     1170 <EMACPHYConfigSet+0x30>
mov    $0x3e8,%edi
call   1040 <SysCtlDelay@plt>
mov    $0xfffcffff,%eax
and    0x400ecfc8,%eax
xor    %ecx,%ecx
cmp    $0xc0000000,%ebx
mov    $0x30000,%edx
cmovb  %ecx,%edx
or     %eax,%edx
mov    %edx,0x400ecfc8
cmp    %ebp,%r14d
jne    11b7 <EMACPHYConfigSet+0x77>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x400ec000,%edi
call   1060 <EMACReset@plt>
mov    $0x3e8,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <SysCtlDelay@plt>

LLVM IR (-O0):
define void @EMACPHYConfigSet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, 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*
%10 = load volatile i32, i32* %9
%11 = and i32 %10, -1073741824
store i32 %11, i32* %5
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 4036
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store volatile i32 %12, i32* %16
%17 = load i32, i32* %4
%18 = and i32 %17, -1073741824
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %2
%21 = call i32 @SysCtlPeripheralReset(i32 -268423168)
br label %22
22: ; preds = %26, %20
%23 = call i32 @SysCtlPeripheralReady(i32 -268423168)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %27
26: ; preds = %22
br label %22
27: ; preds = %22
%28 = call i32 @SysCtlDelay(i32 1000)
br label %29
29: ; preds = %27, %2
%30 = load i32, i32* %4
%31 = and i32 %30, -1073741824
%32 = icmp eq i32 %31, -1073741824
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%35 = or i32 %34, 196608
store volatile i32 %35, i32* inttoptr (i64 1074712520 to i32*)
br label %39
36: ; preds = %29
%37 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%38 = and i32 %37, -196609
store volatile i32 %38, i32* inttoptr (i64 1074712520 to i32*)
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %5
%41 = load i32, i32* %4
%42 = and i32 %41, -1073741824
%43 = icmp ne i32 %40, %42
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = call i32 @EMACReset(i32 1074708480)
%46 = call i32 @SysCtlDelay(i32 1000)
br label %47
47: ; preds = %44, %39
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*
%6 = load volatile i32, i32* %5
%7 = and i32 %6, -1073741824
store volatile i32 %1, i32* %5
%8 = and i32 %1, -1073741824
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = tail call i32 @SysCtlPeripheralReset(i32 -268423168)
br label %12
12: ; preds = %12, %10
%13 = tail call i32 @SysCtlPeripheralReady(i32 -268423168)
%14 = icmp eq i32 %13, 0
br i1 %14, label %12, label %15
15: ; preds = %12
%16 = tail call i32 @SysCtlDelay(i32 1000)
br label %17
17: ; preds = %15, %2
%18 = icmp ugt i32 %1, -1073741825
%19 = load volatile i32, i32* inttoptr (i64 1074712520 to i32*)
%20 = and i32 %19, -196609
%21 = select i1 %18, i32 196608, i32 0
%22 = or i32 %20, %21
store volatile i32 %22, i32* inttoptr (i64 1074712520 to i32*)
%23 = icmp eq i32 %7, %8
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = tail call i32 @EMACReset(i32 1074708480)
%26 = tail call i32 @SysCtlDelay(i32 1000)
br label %27
27: ; preds = %24, %17
ret void
}