#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 BMCR_FULLDPLX;
unsigned int BMCR_SPEED100;
unsigned int BMCR_SPEED1000;
int LPA_1000FULL;
int LPA_1000HALF;
unsigned int LPA_100FULL;
unsigned int LPA_100HALF;
unsigned int LPA_10FULL;
unsigned int LPA_10HALF;
unsigned int gmii_forced_result(unsigned int bmcr) {
  unsigned int result;
  int full_duplex;
  full_duplex = bmcr & BMCR_FULLDPLX;
  if (bmcr & BMCR_SPEED1000)
    result = full_duplex ? (LPA_1000FULL << 6) : (LPA_1000HALF << 6);
  else if (bmcr & BMCR_SPEED100)
    result = full_duplex ? LPA_100FULL : LPA_100HALF;
  else
    result = full_duplex ? LPA_10FULL : LPA_10HALF;
  return result;
}


x86 assembly (clang, -O0):
<gmii_forced_result>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eaf(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e98(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1163 <gmii_forced_result+0x63>
cmpl   $0x0,-0xc(%rbp)
je     1149 <gmii_forced_result+0x49>
mov    0x2eb4(%rip),%rax
mov    (%rax),%eax
shl    $0x6,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <gmii_forced_result+0x58>
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
shl    $0x6,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11dc <gmii_forced_result+0xdc>
mov    -0x4(%rbp),%eax
mov    0x2e8b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11aa <gmii_forced_result+0xaa>
cmpl   $0x0,-0xc(%rbp)
je     1193 <gmii_forced_result+0x93>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    119f <gmii_forced_result+0x9f>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d7 <gmii_forced_result+0xd7>
cmpl   $0x0,-0xc(%rbp)
je     11c5 <gmii_forced_result+0xc5>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    11d1 <gmii_forced_result+0xd1>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11dc <gmii_forced_result+0xdc>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gmii_forced_result>:
mov    0x2eb9(%rip),%rax
mov    (%rax),%eax
mov    0x2ea8(%rip),%rcx
test   %edi,(%rcx)
je     1121 <gmii_forced_result+0x21>
test   %edi,%eax
jne    113a <gmii_forced_result+0x3a>
mov    0x2e91(%rip),%rax
jmp    1141 <gmii_forced_result+0x41>
mov    0x2ed0(%rip),%rcx
test   %edi,(%rcx)
je     1147 <gmii_forced_result+0x47>
test   %edi,%eax
jne    1155 <gmii_forced_result+0x55>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
shl    $0x6,%eax
ret
test   %edi,%eax
jne    115f <gmii_forced_result+0x5f>
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@BMCR_FULLDPLX = global i32 0
@BMCR_SPEED1000 = global i32 0
@LPA_1000FULL = global i32 0
@LPA_1000HALF = global i32 0
@BMCR_SPEED100 = global i32 0
@LPA_100FULL = global i32 0
@LPA_100HALF = global i32 0
@LPA_10FULL = global i32 0
@LPA_10HALF = global i32 0
define i32 @gmii_forced_result(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* @BMCR_FULLDPLX
%7 = and i32 %5, %6
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = load i32, i32* @BMCR_SPEED1000
%10 = and i32 %8, %9
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %1
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @LPA_1000FULL
%17 = shl i32 %16, 6
br label %21
18: ; preds = %12
%19 = load i32, i32* @LPA_1000HALF
%20 = shl i32 %19, 6
br label %21
21: ; preds = %18, %15
%22 = phi i32 [ %17, %15 ], [ %20, %18 ]
store i32 %22, i32* %3
br label %47
23: ; preds = %1
%24 = load i32, i32* %2
%25 = load i32, i32* @BMCR_SPEED100
%26 = and i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load i32, i32* @LPA_100FULL
br label %35
33: ; preds = %28
%34 = load i32, i32* @LPA_100HALF
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
store i32 %36, i32* %3
br label %46
37: ; preds = %23
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = load i32, i32* @LPA_10FULL
br label %44
42: ; preds = %37
%43 = load i32, i32* @LPA_10HALF
br label %44
44: ; preds = %42, %40
%45 = phi i32 [ %41, %40 ], [ %43, %42 ]
store i32 %45, i32* %3
br label %46
46: ; preds = %44, %35
br label %47
47: ; preds = %46, %21
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@BMCR_FULLDPLX = global i32 0
@BMCR_SPEED1000 = global i32 0
@LPA_1000FULL = global i32 0
@LPA_1000HALF = global i32 0
@BMCR_SPEED100 = global i32 0
@LPA_100FULL = global i32 0
@LPA_100HALF = global i32 0
@LPA_10FULL = global i32 0
@LPA_10HALF = global i32 0
define i32 @gmii_forced_result(i32 %0) {
%2 = load i32, i32* @BMCR_FULLDPLX
%3 = and i32 %2, %0
%4 = load i32, i32* @BMCR_SPEED1000
%5 = and i32 %4, %0
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = icmp eq i32 %3, 0
%9 = load i32, i32* @LPA_1000FULL
%10 = load i32, i32* @LPA_1000HALF
%11 = select i1 %8, i32 %10, i32 %9
%12 = shl i32 %11, 6
br label %26
13: ; preds = %1
%14 = load i32, i32* @BMCR_SPEED100
%15 = and i32 %14, %0
%16 = icmp eq i32 %15, 0
%17 = icmp eq i32 %3, 0
br i1 %16, label %22, label %18
18: ; preds = %13
%19 = load i32, i32* @LPA_100FULL
%20 = load i32, i32* @LPA_100HALF
%21 = select i1 %17, i32 %20, i32 %19
br label %26
22: ; preds = %13
%23 = load i32, i32* @LPA_10FULL
%24 = load i32, i32* @LPA_10HALF
%25 = select i1 %17, i32 %24, i32 %23
br label %26
26: ; preds = %18, %22, %7
%27 = phi i32 [ %12, %7 ], [ %21, %18 ], [ %25, %22 ]
ret i32 %27
}