#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*/ controller(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ handle_f(int);
int /*<<< orphan*/ midi_note_off(int);
int /*<<< orphan*/ midi_note_on(int);
int /*<<< orphan*/ patch(int);
int /*<<< orphan*/ stderr;
void status_byte(unsigned char c) {
  int type = c >> 4;
  int n = c % (1 << 4);
  switch (type) {
  case 0x8:
    midi_note_off(n);
    break;
  case 0x9:
    midi_note_on(n);
    break;
  case 0xB:
    controller(n);
    break;
  case 0xC:
    patch(n);
    break;
  case 0xF:
    handle_f(n);
    break;
  default:
    fprintf(stderr, "unhandled: %d %d\n", type, n);
    break;
  }
}


x86 assembly (clang, -O0):
<status_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     11ec <status_byte+0x8c>
mov    -0x18(%rbp),%rax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edi
call   1050 <midi_note_off@plt>
jmp    1207 <status_byte+0xa7>
mov    -0xc(%rbp),%edi
call   1030 <midi_note_on@plt>
jmp    1207 <status_byte+0xa7>
mov    -0xc(%rbp),%edi
call   1060 <controller@plt>
jmp    1207 <status_byte+0xa7>
mov    -0xc(%rbp),%edi
call   1070 <patch@plt>
jmp    1207 <status_byte+0xa7>
mov    -0xc(%rbp),%edi
call   1080 <handle_f@plt>
jmp    1207 <status_byte+0xa7>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe1e(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_byte>:
mov    %edi,%ecx
mov    %edi,%edx
shr    $0x4,%edx
and    $0xf,%ecx
lea    -0x8(%rdx),%eax
cmp    $0x7,%eax
ja     1190 <status_byte+0x30>
lea    0xe87(%rip),%rsi
movslq (%rsi,%rax,4),%rax
add    %rsi,%rax
jmp    *%rax
mov    %ecx,%edi
jmp    1050 <midi_note_off@plt>
mov    %ecx,%edi
jmp    1030 <midi_note_on@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
jmp    1040 <fprintf@plt>
mov    %ecx,%edi
jmp    1060 <controller@plt>
mov    %ecx,%edi
jmp    1070 <patch@plt>
mov    %ecx,%edi
jmp    1080 <handle_f@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"unhandled: %d %d\0A\00"
define void @status_byte(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i8 %0, i8* %2
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = ashr i32 %6, 4
store i32 %7, i32* %3
%8 = load i8, i8* %2
%9 = zext i8 %8 to i32
%10 = srem i32 %9, 16
store i32 %10, i32* %4
%11 = load i32, i32* %3
switch i32 %11, label %27 [
i32 8, label %12
i32 9, label %15
i32 11, label %18
i32 12, label %21
i32 15, label %24
]
12: ; preds = %1
%13 = load i32, i32* %4
%14 = call i32 @midi_note_off(i32 %13)
br label %32
15: ; preds = %1
%16 = load i32, i32* %4
%17 = call i32 @midi_note_on(i32 %16)
br label %32
18: ; preds = %1
%19 = load i32, i32* %4
%20 = call i32 @controller(i32 %19)
br label %32
21: ; preds = %1
%22 = load i32, i32* %4
%23 = call i32 @patch(i32 %22)
br label %32
24: ; preds = %1
%25 = load i32, i32* %4
%26 = call i32 @handle_f(i32 %25)
br label %32
27: ; preds = %1
%28 = load i32, i32* @stderr
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %27, %24, %21, %18, %15, %12
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"unhandled: %d %d\0A\00"
define void @status_byte(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = lshr i32 %2, 4
%4 = and i32 %2, 15
switch i32 %3, label %15 [
i32 8, label %5
i32 9, label %7
i32 11, label %9
i32 12, label %11
i32 15, label %13
]
5: ; preds = %1
%6 = tail call i32 @midi_note_off(i32 %4)
br label %18
7: ; preds = %1
%8 = tail call i32 @midi_note_on(i32 %4)
br label %18
9: ; preds = %1
%10 = tail call i32 @controller(i32 %4)
br label %18
11: ; preds = %1
%12 = tail call i32 @patch(i32 %4)
br label %18
13: ; preds = %1
%14 = tail call i32 @handle_f(i32 %4)
br label %18
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
br label %18
18: ; preds = %15, %13, %11, %9, %7, %5
ret void
}