unsigned int I2CBufferStatus(unsigned int baseAdd, unsigned int flag) {
  unsigned int status = 0;
  switch (flag) {
  case 0:
    status = (*((volatile unsigned int *)(baseAdd + (0xC0)))) & (0x0000003Fu);
    break;
  case 1:
    status =
        ((*((volatile unsigned int *)(baseAdd + (0xC0)))) & (0x00003F00u)) >>
        (0x00000008u);
    break;
  case 2:
    status =
        ((*((volatile unsigned int *)(baseAdd + (0xC0)))) & (0x0000C000u)) >>
        (0x0000000Eu);
    break;
  default:
    break;
  }
  return status;
}


x86 assembly (clang, -O0):
<I2CBufferStatus>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1146 <I2CBufferStatus+0x46>
jmp    1124 <I2CBufferStatus+0x24>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     115d <I2CBufferStatus+0x5d>
jmp    1135 <I2CBufferStatus+0x35>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1179 <I2CBufferStatus+0x79>
jmp    1195 <I2CBufferStatus+0x95>
mov    -0x4(%rbp),%eax
add    $0xc0,%eax
mov    %eax,%eax
mov    (%rax),%eax
and    $0x3f,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <I2CBufferStatus+0x9a>
mov    -0x4(%rbp),%eax
add    $0xc0,%eax
mov    %eax,%eax
mov    (%rax),%eax
and    $0x3f00,%eax
shr    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <I2CBufferStatus+0x9a>
mov    -0x4(%rbp),%eax
add    $0xc0,%eax
mov    %eax,%eax
mov    (%rax),%eax
and    $0xc000,%eax
shr    $0xe,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <I2CBufferStatus+0x9a>
jmp    119a <I2CBufferStatus+0x9a>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2CBufferStatus>:
cmp    $0x2,%esi
je     111c <I2CBufferStatus+0x1c>
cmp    $0x1,%esi
je     112b <I2CBufferStatus+0x2b>
xor    %eax,%eax
test   %esi,%esi
jne    112a <I2CBufferStatus+0x2a>
add    $0xc0,%edi
mov    (%rdi),%eax
and    $0x3f,%eax
ret
add    $0xc0,%edi
mov    (%rdi),%eax
shr    $0xe,%eax
and    $0x3,%eax
ret
add    $0xc0,%edi
mov    (%rdi),%eax
shr    $0x8,%eax
and    $0x3f,%eax
ret

LLVM IR (-O0):
define i32 @I2CBufferStatus(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %30 [
i32 0, label %7
i32 1, label %14
i32 2, label %22
]
7: ; preds = %2
%8 = load i32, i32* %3
%9 = add i32 %8, 192
%10 = zext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = load volatile i32, i32* %11
%13 = and i32 %12, 63
store i32 %13, i32* %5
br label %31
14: ; preds = %2
%15 = load i32, i32* %3
%16 = add i32 %15, 192
%17 = zext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = load volatile i32, i32* %18
%20 = and i32 %19, 16128
%21 = lshr i32 %20, 8
store i32 %21, i32* %5
br label %31
22: ; preds = %2
%23 = load i32, i32* %3
%24 = add i32 %23, 192
%25 = zext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = load volatile i32, i32* %26
%28 = and i32 %27, 49152
%29 = lshr i32 %28, 14
store i32 %29, i32* %5
br label %31
30: ; preds = %2
br label %31
31: ; preds = %30, %22, %14, %7
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @I2CBufferStatus(i32 %0, i32 %1) {
switch i32 %1, label %23 [
i32 0, label %3
i32 1, label %9
i32 2, label %16
]
3: ; preds = %2
%4 = add i32 %0, 192
%5 = zext i32 %4 to i64
%6 = inttoptr i64 %5 to i32*
%7 = load volatile i32, i32* %6
%8 = and i32 %7, 63
br label %23
9: ; preds = %2
%10 = add i32 %0, 192
%11 = zext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = load volatile i32, i32* %12
%14 = lshr i32 %13, 8
%15 = and i32 %14, 63
br label %23
16: ; preds = %2
%17 = add i32 %0, 192
%18 = zext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load volatile i32, i32* %19
%21 = lshr i32 %20, 14
%22 = and i32 %21, 3
br label %23
23: ; preds = %2, %16, %9, %3
%24 = phi i32 [ 0, %2 ], [ %22, %16 ], [ %15, %9 ], [ %8, %3 ]
ret i32 %24
}