#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 char McResCtrl_GetEFIFO0LSource();
unsigned char McResCtrl_GetEFIFO0RSource();
unsigned char McResCtrl_GetEFIFO1LSource();
unsigned char McResCtrl_GetEFIFO1RSource();
unsigned char McResCtrl_GetRegVal(int, int);
unsigned char McResCtrl_GetEFIFOSourceReg(void) {
  unsigned char bReg, bEFIFO0L, bEFIFO0R, bEFIFO1L, bEFIFO1R;
  bReg = McResCtrl_GetRegVal((0x00002000UL), (116));
  bEFIFO0L = McResCtrl_GetEFIFO0LSource();
  bEFIFO0R = McResCtrl_GetEFIFO0RSource();
  bEFIFO1L = McResCtrl_GetEFIFO1LSource();
  bEFIFO1R = McResCtrl_GetEFIFO1RSource();
  if (bEFIFO0L == 0xFF) {
    bEFIFO0L = bReg & (0x0C);
  }
  if (bEFIFO0R == 0xFF) {
    bEFIFO0R = bReg & (0x03);
  }
  if (bEFIFO1L == 0xFF) {
    bEFIFO1L = bReg & (0xC0);
  }
  if (bEFIFO1R == 0xFF) {
    bEFIFO1R = bReg & (0x30);
  }
  return (bEFIFO1L | bEFIFO1R | bEFIFO0L | bEFIFO0R);
}


x86 assembly (clang, -O0):
<McResCtrl_GetEFIFOSourceReg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2000,%edi
mov    $0x74,%esi
call   1050 <McResCtrl_GetRegVal@plt>
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1070 <McResCtrl_GetEFIFO0LSource@plt>
mov    %al,-0x2(%rbp)
mov    $0x0,%al
call   1040 <McResCtrl_GetEFIFO0RSource@plt>
mov    %al,-0x3(%rbp)
mov    $0x0,%al
call   1030 <McResCtrl_GetEFIFO1LSource@plt>
mov    %al,-0x4(%rbp)
mov    $0x0,%al
call   1060 <McResCtrl_GetEFIFO1RSource@plt>
mov    %al,-0x5(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0xff,%eax
jne    11ab <McResCtrl_GetEFIFOSourceReg+0x5b>
movzbl -0x1(%rbp),%eax
and    $0xc,%eax
mov    %al,-0x2(%rbp)
movzbl -0x3(%rbp),%eax
cmp    $0xff,%eax
jne    11c4 <McResCtrl_GetEFIFOSourceReg+0x74>
movzbl -0x1(%rbp),%eax
and    $0x3,%eax
mov    %al,-0x3(%rbp)
movzbl -0x4(%rbp),%eax
cmp    $0xff,%eax
jne    11df <McResCtrl_GetEFIFOSourceReg+0x8f>
movzbl -0x1(%rbp),%eax
and    $0xc0,%eax
mov    %al,-0x4(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0xff,%eax
jne    11f8 <McResCtrl_GetEFIFOSourceReg+0xa8>
movzbl -0x1(%rbp),%eax
and    $0x30,%eax
mov    %al,-0x5(%rbp)
movzbl -0x4(%rbp),%eax
movzbl -0x5(%rbp),%ecx
or     %ecx,%eax
movzbl -0x2(%rbp),%ecx
or     %ecx,%eax
movzbl -0x3(%rbp),%ecx
or     %ecx,%eax
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<McResCtrl_GetEFIFOSourceReg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2000,%edi
mov    $0x74,%esi
call   1050 <McResCtrl_GetRegVal@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <McResCtrl_GetEFIFO0LSource@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <McResCtrl_GetEFIFO0RSource@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1030 <McResCtrl_GetEFIFO1LSource@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <McResCtrl_GetEFIFO1RSource@plt>
mov    %ebx,%ecx
and    $0xc,%cl
cmp    $0xff,%bpl
movzbl %cl,%ecx
movzbl %bpl,%edx
cmove  %ecx,%edx
mov    %ebx,%ecx
and    $0x3,%cl
cmp    $0xff,%r14b
movzbl %cl,%ecx
movzbl %r14b,%esi
cmove  %ecx,%esi
mov    %ebx,%ecx
and    $0xc0,%cl
cmp    $0xff,%r15b
movzbl %cl,%ecx
movzbl %r15b,%edi
cmove  %ecx,%edi
and    $0x30,%bl
cmp    $0xff,%al
movzbl %bl,%ecx
movzbl %al,%eax
cmove  %ecx,%eax
or     %edx,%esi
or     %edi,%eax
or     %esi,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @McResCtrl_GetEFIFOSourceReg() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = call zeroext i8 @McResCtrl_GetRegVal(i32 8192, i32 116)
store i8 %6, i8* %1
%7 = call zeroext i8 (...) @McResCtrl_GetEFIFO0LSource()
store i8 %7, i8* %2
%8 = call zeroext i8 (...) @McResCtrl_GetEFIFO0RSource()
store i8 %8, i8* %3
%9 = call zeroext i8 (...) @McResCtrl_GetEFIFO1LSource()
store i8 %9, i8* %4
%10 = call zeroext i8 (...) @McResCtrl_GetEFIFO1RSource()
store i8 %10, i8* %5
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %12, 255
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i8, i8* %1
%16 = zext i8 %15 to i32
%17 = and i32 %16, 12
%18 = trunc i32 %17 to i8
store i8 %18, i8* %2
br label %19
19: ; preds = %14, %0
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 255
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %1
%25 = zext i8 %24 to i32
%26 = and i32 %25, 3
%27 = trunc i32 %26 to i8
store i8 %27, i8* %3
br label %28
28: ; preds = %23, %19
%29 = load i8, i8* %4
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 255
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8, i8* %1
%34 = zext i8 %33 to i32
%35 = and i32 %34, 192
%36 = trunc i32 %35 to i8
store i8 %36, i8* %4
br label %37
37: ; preds = %32, %28
%38 = load i8, i8* %5
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 255
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i8, i8* %1
%43 = zext i8 %42 to i32
%44 = and i32 %43, 48
%45 = trunc i32 %44 to i8
store i8 %45, i8* %5
br label %46
46: ; preds = %41, %37
%47 = load i8, i8* %4
%48 = zext i8 %47 to i32
%49 = load i8, i8* %5
%50 = zext i8 %49 to i32
%51 = or i32 %48, %50
%52 = load i8, i8* %2
%53 = zext i8 %52 to i32
%54 = or i32 %51, %53
%55 = load i8, i8* %3
%56 = zext i8 %55 to i32
%57 = or i32 %54, %56
%58 = trunc i32 %57 to i8
ret i8 %58
}

LLVM IR (-O2):
define zeroext i8 @McResCtrl_GetEFIFOSourceReg() {
%1 = tail call zeroext i8 @McResCtrl_GetRegVal(i32 8192, i32 116)
%2 = tail call zeroext i8 (...) @McResCtrl_GetEFIFO0LSource()
%3 = tail call zeroext i8 (...) @McResCtrl_GetEFIFO0RSource()
%4 = tail call zeroext i8 (...) @McResCtrl_GetEFIFO1LSource()
%5 = tail call zeroext i8 (...) @McResCtrl_GetEFIFO1RSource()
%6 = icmp eq i8 %2, -1
%7 = and i8 %1, 12
%8 = select i1 %6, i8 %7, i8 %2
%9 = icmp eq i8 %3, -1
%10 = and i8 %1, 3
%11 = select i1 %9, i8 %10, i8 %3
%12 = icmp eq i8 %4, -1
%13 = and i8 %1, -64
%14 = select i1 %12, i8 %13, i8 %4
%15 = icmp eq i8 %5, -1
%16 = and i8 %1, 48
%17 = select i1 %15, i8 %16, i8 %5
%18 = or i8 %11, %8
%19 = or i8 %18, %14
%20 = or i8 %19, %17
ret i8 %20
}