int ReadDigital(int bitnumber) {
  switch (bitnumber) {
  case 0: {
    if ((*((volatile unsigned int *)(0x50010000 + 0x3ffc))) & (1 << 0))
      return 1;
    else
      return 0;
    break;
  }
  case 1: {
    if ((*((volatile unsigned int *)(0x50010000 + 0x3ffc))) & (1 << 1))
      return 1;
    else
      return 0;
    break;
  }
  case 2: {
    if ((*((volatile unsigned int *)(0x50010000 + 0x3ffc))) & (1 << 2))
      return 1;
    else
      return 0;
    break;
  }
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<ReadDigital>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     113c <ReadDigital+0x3c>
jmp    111a <ReadDigital+0x1a>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     1167 <ReadDigital+0x67>
jmp    112b <ReadDigital+0x2b>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1192 <ReadDigital+0x92>
jmp    11bd <ReadDigital+0xbd>
mov    $0x50013ffc,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     115b <ReadDigital+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
mov    $0x50013ffc,%eax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1186 <ReadDigital+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
mov    $0x50013ffc,%eax
mov    (%rax),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11b1 <ReadDigital+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <ReadDigital+0xc4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadDigital>:
cmp    $0x2,%edi
je     1119 <ReadDigital+0x19>
cmp    $0x1,%edi
je     1125 <ReadDigital+0x25>
xor    %eax,%eax
test   %edi,%edi
jne    1131 <ReadDigital+0x31>
mov    0x50013ffc,%eax
jmp    112e <ReadDigital+0x2e>
mov    0x50013ffc,%eax
shr    $0x2,%eax
jmp    112e <ReadDigital+0x2e>
mov    0x50013ffc,%eax
shr    %eax
and    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @ReadDigital(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %23 [
i32 0, label %5
i32 1, label %11
i32 2, label %17
]
5: ; preds = %1
%6 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%7 = and i32 %6, 1
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
store i32 1, i32* %2
br label %24
10: ; preds = %5
store i32 0, i32* %2
br label %24
11: ; preds = %1
%12 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%13 = and i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 1, i32* %2
br label %24
16: ; preds = %11
store i32 0, i32* %2
br label %24
17: ; preds = %1
%18 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%19 = and i32 %18, 4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %2
br label %24
22: ; preds = %17
store i32 0, i32* %2
br label %24
23: ; preds = %1
store i32 0, i32* %2
br label %24
24: ; preds = %23, %22, %21, %16, %15, %10, %9
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @ReadDigital(i32 %0) {
switch i32 %0, label %13 [
i32 0, label %2
i32 1, label %5
i32 2, label %9
]
2: ; preds = %1
%3 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%4 = and i32 %3, 1
br label %13
5: ; preds = %1
%6 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%7 = lshr i32 %6, 1
%8 = and i32 %7, 1
br label %13
9: ; preds = %1
%10 = load volatile i32, i32* inttoptr (i64 1342259196 to i32*)
%11 = lshr i32 %10, 2
%12 = and i32 %11, 1
br label %13
13: ; preds = %1, %9, %5, %2
%14 = phi i32 [ %4, %2 ], [ %8, %5 ], [ %12, %9 ], [ 0, %1 ]
ret i32 %14
}