#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*/ midi_chanpressure(int, int);
int /*<<< orphan*/ midi_controlparameter(int, int, int);
int /*<<< orphan*/ midi_noteoff(int, int, int);
int /*<<< orphan*/ midi_noteon(int, int, int);
int /*<<< orphan*/ midi_pitchbend(int, int, int);
int /*<<< orphan*/ midi_pressure(int, int, int);
int /*<<< orphan*/ midi_program(int, int);
int /*<<< orphan*/ sys_message(int, char *);
void chanmessage(int status, int c1, int c2) {
  int chan = status & 0xf;
  switch (status & 0xf0) {
  case 0x80:
    midi_noteoff(chan, c1, c2);
    break;
  case 0x90:
    midi_noteon(chan, c1, c2);
    break;
  case 0xa0:
    midi_pressure(chan, c1, c2);
    break;
  case 0xb0:
    midi_controlparameter(chan, c1, c2);
    break;
  case 0xe0:
    midi_pitchbend(chan, c1, c2);
    break;
  case 0xc0:
    midi_program(chan, c1);
    break;
  case 0xd0:
    midi_chanpressure(chan, c1);
    break;
  default:
    sys_message(2, "Unknown Message\n");
  }
}


x86 assembly (clang, -O0):
<chanmessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     1227 <chanmessage+0xa7>
jmp    11b5 <chanmessage+0x35>
mov    -0x14(%rbp),%eax
sub    $0x90,%eax
je     123a <chanmessage+0xba>
jmp    11c8 <chanmessage+0x48>
mov    -0x14(%rbp),%eax
sub    $0xa0,%eax
je     124d <chanmessage+0xcd>
jmp    11db <chanmessage+0x5b>
mov    -0x14(%rbp),%eax
sub    $0xb0,%eax
je     1260 <chanmessage+0xe0>
jmp    11ee <chanmessage+0x6e>
mov    -0x14(%rbp),%eax
sub    $0xc0,%eax
je     1286 <chanmessage+0x106>
jmp    1201 <chanmessage+0x81>
mov    -0x14(%rbp),%eax
sub    $0xd0,%eax
je     1296 <chanmessage+0x116>
jmp    1214 <chanmessage+0x94>
mov    -0x14(%rbp),%eax
sub    $0xe0,%eax
je     1273 <chanmessage+0xf3>
jmp    12a6 <chanmessage+0x126>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1090 <midi_noteoff@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   10a0 <midi_noteon@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <midi_pressure@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <midi_controlparameter@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <midi_pitchbend@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1070 <midi_program@plt>
jmp    12b7 <chanmessage+0x137>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <midi_chanpressure@plt>
jmp    12b7 <chanmessage+0x137>
mov    $0x2,%edi
lea    0xd4e(%rip),%rsi
call   1080 <sys_message@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chanmessage>:
mov    %edi,%eax
and    $0xf0,%eax
add    $0xffffff80,%eax
shr    $0x4,%eax
cmp    $0x6,%eax
ja     11aa <chanmessage+0x2a>
and    $0xf,%edi
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1090 <midi_noteoff@plt>
lea    0xe6b(%rip),%rsi
mov    $0x2,%edi
jmp    1080 <sys_message@plt>
jmp    10a0 <midi_noteon@plt>
jmp    1060 <midi_pressure@plt>
jmp    1030 <midi_controlparameter@plt>
jmp    1070 <midi_program@plt>
jmp    1040 <midi_chanpressure@plt>
jmp    1050 <midi_pitchbend@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Unknown Message\0A\00"
define void @chanmessage(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = and i32 %8, 15
store i32 %9, i32* %7
%10 = load i32, i32* %4
%11 = and i32 %10, 240
switch i32 %11, label %45 [
i32 128, label %12
i32 144, label %17
i32 160, label %22
i32 176, label %27
i32 224, label %32
i32 192, label %37
i32 208, label %41
]
12: ; preds = %3
%13 = load i32, i32* %7
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @midi_noteoff(i32 %13, i32 %14, i32 %15)
br label %47
17: ; preds = %3
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @midi_noteon(i32 %18, i32 %19, i32 %20)
br label %47
22: ; preds = %3
%23 = load i32, i32* %7
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i32 @midi_pressure(i32 %23, i32 %24, i32 %25)
br label %47
27: ; preds = %3
%28 = load i32, i32* %7
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i32 @midi_controlparameter(i32 %28, i32 %29, i32 %30)
br label %47
32: ; preds = %3
%33 = load i32, i32* %7
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = call i32 @midi_pitchbend(i32 %33, i32 %34, i32 %35)
br label %47
37: ; preds = %3
%38 = load i32, i32* %7
%39 = load i32, i32* %5
%40 = call i32 @midi_program(i32 %38, i32 %39)
br label %47
41: ; preds = %3
%42 = load i32, i32* %7
%43 = load i32, i32* %5
%44 = call i32 @midi_chanpressure(i32 %42, i32 %43)
br label %47
45: ; preds = %3
%46 = call i32 @sys_message(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %47
47: ; preds = %45, %41, %37, %32, %27, %22, %17, %12
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Unknown Message\0A\00"
define void @chanmessage(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %0, 15
%5 = and i32 %0, 240
%6 = add nsw i32 %5, -128
%7 = lshr exact i32 %6, 4
switch i32 %7, label %22 [
i32 0, label %8
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 6, label %16
i32 4, label %18
i32 5, label %20
]
8: ; preds = %3
%9 = tail call i32 @midi_noteoff(i32 %4, i32 %1, i32 %2)
br label %24
10: ; preds = %3
%11 = tail call i32 @midi_noteon(i32 %4, i32 %1, i32 %2)
br label %24
12: ; preds = %3
%13 = tail call i32 @midi_pressure(i32 %4, i32 %1, i32 %2)
br label %24
14: ; preds = %3
%15 = tail call i32 @midi_controlparameter(i32 %4, i32 %1, i32 %2)
br label %24
16: ; preds = %3
%17 = tail call i32 @midi_pitchbend(i32 %4, i32 %1, i32 %2)
br label %24
18: ; preds = %3
%19 = tail call i32 @midi_program(i32 %4, i32 %1)
br label %24
20: ; preds = %3
%21 = tail call i32 @midi_chanpressure(i32 %4, i32 %1)
br label %24
22: ; preds = %3
%23 = tail call i32 @sys_message(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10, %8
ret void
}