#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*/ note_off(int);
int /*<<< orphan*/ note_on(int);
int /*<<< orphan*/ patch(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ timer_stamp();
void status_byte(unsigned char c) {
  int type = c >> 4;
  int n = c % (1 << 4);
  timer_stamp();
  switch (type) {
  case 0x8:
    note_off(n);
    break;
  case 0x9:
    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)
xor    %eax,%eax
call   1060 <timer_stamp@plt>
mov    -0x8(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     1203 <status_byte+0x93>
mov    -0x18(%rbp),%rax
lea    0xe47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edi
call   1030 <note_off@plt>
jmp    121e <status_byte+0xae>
mov    -0xc(%rbp),%edi
call   1080 <note_on@plt>
jmp    121e <status_byte+0xae>
mov    -0xc(%rbp),%edi
call   1050 <controller@plt>
jmp    121e <status_byte+0xae>
mov    -0xc(%rbp),%edi
call   1070 <patch@plt>
jmp    121e <status_byte+0xae>
mov    -0xc(%rbp),%edi
call   1090 <handle_f@plt>
jmp    121e <status_byte+0xae>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe07(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_byte>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%r14d
shr    $0x4,%r14d
and    $0xf,%ebx
xor    %eax,%eax
call   1060 <timer_stamp@plt>
lea    -0x8(%r14),%eax
cmp    $0x7,%eax
ja     11bc <status_byte+0x4c>
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <note_off@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <note_on@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    %r14d,%edx
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fprintf@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <controller@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <patch@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <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 = call i32 (...) @timer_stamp()
%12 = load i32, i32* %3
switch i32 %12, label %28 [
i32 8, label %13
i32 9, label %16
i32 11, label %19
i32 12, label %22
i32 15, label %25
]
13: ; preds = %1
%14 = load i32, i32* %4
%15 = call i32 @note_off(i32 %14)
br label %33
16: ; preds = %1
%17 = load i32, i32* %4
%18 = call i32 @note_on(i32 %17)
br label %33
19: ; preds = %1
%20 = load i32, i32* %4
%21 = call i32 @controller(i32 %20)
br label %33
22: ; preds = %1
%23 = load i32, i32* %4
%24 = call i32 @patch(i32 %23)
br label %33
25: ; preds = %1
%26 = load i32, i32* %4
%27 = call i32 @handle_f(i32 %26)
br label %33
28: ; preds = %1
%29 = load i32, i32* @stderr
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %31)
br label %33
33: ; preds = %28, %25, %22, %19, %16, %13
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
%5 = tail call i32 (...) @timer_stamp()
switch i32 %3, label %16 [
i32 8, label %6
i32 9, label %8
i32 11, label %10
i32 12, label %12
i32 15, label %14
]
6: ; preds = %1
%7 = tail call i32 @note_off(i32 %4)
br label %19
8: ; preds = %1
%9 = tail call i32 @note_on(i32 %4)
br label %19
10: ; preds = %1
%11 = tail call i32 @controller(i32 %4)
br label %19
12: ; preds = %1
%13 = tail call i32 @patch(i32 %4)
br label %19
14: ; preds = %1
%15 = tail call i32 @handle_f(i32 %4)
br label %19
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
br label %19
19: ; preds = %16, %14, %12, %10, %8, %6
ret void
}