void led(int x) {
  char temp;
  temp = (*(volatile unsigned char *)0x21180000);
  switch (x) {
  case 0:
    (*(volatile unsigned char *)0x21180000) = 0xFf;
    break;
  case 1:
    (*(volatile unsigned char *)0x21180000) = temp & 0xFe;
    break;
  case 2:
    (*(volatile unsigned char *)0x21180000) = temp & 0xFd;
    break;
  case 3:
    (*(volatile unsigned char *)0x21180000) = temp & 0xFb;
    break;
  case 4:
    (*(volatile unsigned char *)0x21180000) = temp & 0xF7;
    break;
  }
}


x86 assembly (clang, -O0):
<led>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    0x21180000,%al
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x4,%rax
ja     119a <led+0x9a>
mov    -0x10(%rbp),%rax
lea    0xed3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x21180000,%eax
movb   $0xff,(%rax)
jmp    119a <led+0x9a>
movsbl -0x5(%rbp),%eax
and    $0xfe,%eax
mov    %al,%cl
mov    $0x21180000,%eax
mov    %cl,(%rax)
jmp    119a <led+0x9a>
movsbl -0x5(%rbp),%eax
and    $0xfd,%eax
mov    %al,%cl
mov    $0x21180000,%eax
mov    %cl,(%rax)
jmp    119a <led+0x9a>
movsbl -0x5(%rbp),%eax
and    $0xfb,%eax
mov    %al,%cl
mov    $0x21180000,%eax
mov    %cl,(%rax)
jmp    119a <led+0x9a>
movsbl -0x5(%rbp),%eax
and    $0xf7,%eax
mov    %al,%cl
mov    $0x21180000,%eax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<led>:
mov    0x21180000,%al
cmp    $0x4,%edi
ja     1137 <led+0x37>
mov    $0xff,%cl
mov    %edi,%edx
lea    0xee9(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
and    $0xfe,%al
jmp    112e <led+0x2e>
and    $0xfd,%al
jmp    112e <led+0x2e>
and    $0xfb,%al
jmp    112e <led+0x2e>
and    $0xf7,%al
mov    %eax,%ecx
mov    %cl,0x21180000
ret

LLVM IR (-O0):
define void @led(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load volatile i8, i8* inttoptr (i64 555220992 to i8*)
store i8 %4, i8* %3
%5 = load i32, i32* %2
switch i32 %5, label %27 [
i32 0, label %6
i32 1, label %7
i32 2, label %12
i32 3, label %17
i32 4, label %22
]
6: ; preds = %1
store volatile i8 -1, i8* inttoptr (i64 555220992 to i8*)
br label %27
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = and i32 %9, 254
%11 = trunc i32 %10 to i8
store volatile i8 %11, i8* inttoptr (i64 555220992 to i8*)
br label %27
12: ; preds = %1
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = and i32 %14, 253
%16 = trunc i32 %15 to i8
store volatile i8 %16, i8* inttoptr (i64 555220992 to i8*)
br label %27
17: ; preds = %1
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = and i32 %19, 251
%21 = trunc i32 %20 to i8
store volatile i8 %21, i8* inttoptr (i64 555220992 to i8*)
br label %27
22: ; preds = %1
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = and i32 %24, 247
%26 = trunc i32 %25 to i8
store volatile i8 %26, i8* inttoptr (i64 555220992 to i8*)
br label %27
27: ; preds = %1, %22, %17, %12, %7, %6
ret void
}

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