#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 */
int /*<<< orphan*/ putchp(char);
int /*<<< orphan*/ tc_putp(char *);
void select_bank(char *bank) {
  tc_putp(bank);
  switch (bank[1] & 3) {
  case 0:
    putchp('O' & 0x1f);
    break;
  case 1:
    putchp('N' & 0x1f);
    tc_putp("\033~");
    break;
  case 2:
    tc_putp("\033n\033}");
    break;
  case 3:
    tc_putp("\033o\033|");
    break;
  }
}


x86 assembly (clang, -O0):
<select_bank>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <tc_putp@plt>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11aa <select_bank+0x8a>
mov    -0x10(%rbp),%rax
lea    0xea6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xf,%edi
call   1040 <putchp@plt>
jmp    11aa <select_bank+0x8a>
mov    $0xe,%edi
call   1040 <putchp@plt>
lea    0xe8d(%rip),%rdi
call   1030 <tc_putp@plt>
jmp    11aa <select_bank+0x8a>
lea    0xe7f(%rip),%rdi
call   1030 <tc_putp@plt>
jmp    11aa <select_bank+0x8a>
lea    0xe73(%rip),%rdi
call   1030 <tc_putp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_bank>:
push   %rbx
mov    %rdi,%rbx
call   1030 <tc_putp@plt>
movzbl 0x1(%rbx),%eax
and    $0x3,%eax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xf,%edi
pop    %rbx
jmp    1040 <putchp@plt>
lea    0xec1(%rip),%rdi
pop    %rbx
jmp    1030 <tc_putp@plt>
lea    0xeb9(%rip),%rdi
pop    %rbx
jmp    1030 <tc_putp@plt>
mov    $0xe,%edi
call   1040 <putchp@plt>
lea    0xe9a(%rip),%rdi
pop    %rbx
jmp    1030 <tc_putp@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\1B~\00"
@.str.1 = [5 x i8] c"\1Bn\1B}\00"
@.str.2 = [5 x i8] c"\1Bo\1B|\00"
define void @select_bank(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @tc_putp(i8* %3)
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = and i32 %8, 3
switch i32 %9, label %19 [
i32 0, label %10
i32 1, label %12
i32 2, label %15
i32 3, label %17
]
10: ; preds = %1
%11 = call i32 @putchp(i8 signext 15)
br label %19
12: ; preds = %1
%13 = call i32 @putchp(i8 signext 14)
%14 = call i32 @tc_putp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %1
%16 = call i32 @tc_putp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %19
17: ; preds = %1
%18 = call i32 @tc_putp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %1, %17, %15, %12, %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\1B~\00"
@.str.1 = [5 x i8] c"\1Bn\1B}\00"
@.str.2 = [5 x i8] c"\1Bo\1B|\00"
define void @select_bank(i8* %0) {
%2 = tail call i32 @tc_putp(i8* %0)
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
%5 = and i8 %4, 3
%6 = zext i8 %5 to i32
switch i32 %6, label %16 [
i32 0, label %7
i32 1, label %9
i32 2, label %12
i32 3, label %14
]
7: ; preds = %1
%8 = tail call i32 @putchp(i8 signext 15)
br label %17
9: ; preds = %1
%10 = tail call i32 @putchp(i8 signext 14)
%11 = tail call i32 @tc_putp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %17
12: ; preds = %1
%13 = tail call i32 @tc_putp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %17
14: ; preds = %1
%15 = tail call i32 @tc_putp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %17
16: ; preds = %1
unreachable
17: ; preds = %14, %12, %9, %7
ret void
}