#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 */
typedef int uint8_t;

/* Variables and functions */
int ms_cm2_a5n_support(uint8_t *cm2, int n) {
  switch (n) {
  case 0:
    return 1;
  case 1:
    return (cm2[0] & (1 << 3)) ? 0 : 1;
  case 2:
    return (cm2[2] & (1 << 0)) ? 1 : 0;
  case 3:
    return (cm2[2] & (1 << 1)) ? 1 : 0;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<ms_cm2_a5n_support>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     1198 <ms_cm2_a5n_support+0x98>
mov    -0x20(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    119f <ms_cm2_a5n_support+0x9f>
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
and    $0x8,%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119f <ms_cm2_a5n_support+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
and    $0x1,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119f <ms_cm2_a5n_support+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
and    $0x2,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119f <ms_cm2_a5n_support+0x9f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ms_cm2_a5n_support>:
cmp    $0x3,%esi
ja     1125 <ms_cm2_a5n_support+0x25>
mov    $0x1,%eax
mov    %esi,%ecx
lea    0xeed(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
xor    %eax,%eax
testb  $0x8,(%rdi)
sete   %al
ret
xor    %eax,%eax
ret
mov    0x8(%rdi),%eax
and    $0x1,%eax
ret
mov    0x8(%rdi),%eax
shr    %eax
and    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @ms_cm2_a5n_support(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %32 [
i32 0, label %7
i32 1, label %8
i32 2, label %16
i32 3, label %24
]
7: ; preds = %2
store i32 1, i32* %3
br label %33
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = and i32 %11, 8
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 0, i32 1
store i32 %15, i32* %3
br label %33
16: ; preds = %2
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 1, i32 0
store i32 %23, i32* %3
br label %33
24: ; preds = %2
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = and i32 %27, 2
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 1, i32 0
store i32 %31, i32* %3
br label %33
32: ; preds = %2
store i32 0, i32* %3
br label %33
33: ; preds = %32, %24, %16, %8, %7
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @ms_cm2_a5n_support(i32* nocapture %0, i32 %1) {
switch i32 %1, label %17 [
i32 0, label %18
i32 1, label %3
i32 2, label %8
i32 3, label %12
]
3: ; preds = %2
%4 = load i32, i32* %0
%5 = lshr i32 %4, 3
%6 = and i32 %5, 1
%7 = xor i32 %6, 1
br label %18
8: ; preds = %2
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = and i32 %10, 1
br label %18
12: ; preds = %2
%13 = getelementptr inbounds i32, i32* %0, i64 2
%14 = load i32, i32* %13
%15 = lshr i32 %14, 1
%16 = and i32 %15, 1
br label %18
17: ; preds = %2
br label %18
18: ; preds = %2, %17, %12, %8, %3
%19 = phi i32 [ 0, %17 ], [ %16, %12 ], [ %11, %8 ], [ %7, %3 ], [ 1, %2 ]
ret i32 %19
}