#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*/ receive_sndd(unsigned char *);
int /*<<< orphan*/ update_ui(int, unsigned char, unsigned char);
int /*<<< orphan*/ xprintf(char *, int);
void blofeld_midi_sysex(void *buffer, int len) {
  unsigned char *buf = buffer;
  xprintf("Blofeld received sysex, len %d\n", len);
  if (len <= 2 || buf[2] != 0x13)
    return;
  switch (buf[4]) {
  case 0x20:
    update_ui(((((int)(buf[6])) << 7) | (buf[7])), buf[5], buf[8]);
    break;
  case 0x10:
    if (buf[5] == 0x7f)
      receive_sndd(buf);
    break;
  case 0x00:
  case 0x04:
  case 0x14:
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<blofeld_midi_sysex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xf33(%rip),%rdi
call   1040 <xprintf@plt>
cmpl   $0x2,-0xc(%rbp)
jle    1171 <blofeld_midi_sysex+0x41>
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x13,%eax
je     1176 <blofeld_midi_sysex+0x46>
jmp    11fa <blofeld_midi_sysex+0xca>
mov    -0x18(%rbp),%rax
movzbl 0x4(%rax),%eax
mov    %rax,-0x20(%rbp)
sub    $0x20,%rax
ja     11f5 <blofeld_midi_sysex+0xc5>
mov    -0x20(%rbp),%rax
lea    0xe69(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movzbl 0x6(%rax),%edi
shl    $0x7,%edi
mov    -0x18(%rbp),%rax
movzbl 0x7(%rax),%eax
or     %eax,%edi
mov    -0x18(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x18(%rbp),%rax
movzbl %cl,%esi
movzbl 0x8(%rax),%edx
call   1050 <update_ui@plt>
jmp    11fa <blofeld_midi_sysex+0xca>
mov    -0x18(%rbp),%rax
movzbl 0x5(%rax),%eax
cmp    $0x7f,%eax
jne    11eb <blofeld_midi_sysex+0xbb>
mov    -0x18(%rbp),%rdi
call   1030 <receive_sndd@plt>
jmp    11fa <blofeld_midi_sysex+0xca>
jmp    11f5 <blofeld_midi_sysex+0xc5>
jmp    11fa <blofeld_midi_sysex+0xca>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blofeld_midi_sysex>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
call   1040 <xprintf@plt>
cmp    $0x3,%ebp
jl     1194 <blofeld_midi_sysex+0x64>
cmpb   $0x13,0x2(%rbx)
jne    1194 <blofeld_midi_sysex+0x64>
movzbl 0x4(%rbx),%eax
rol    $0x1e,%eax
cmp    $0x4,%eax
je     1180 <blofeld_midi_sysex+0x50>
cmp    $0x8,%eax
jne    1194 <blofeld_midi_sysex+0x64>
movzbl 0x6(%rbx),%eax
shl    $0x7,%eax
movzbl 0x7(%rbx),%edi
or     %eax,%edi
movzbl 0x5(%rbx),%esi
movzbl 0x8(%rbx),%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <update_ui@plt>
cmpb   $0x7f,0x5(%rbx)
jne    1194 <blofeld_midi_sysex+0x64>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <receive_sndd@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Blofeld received sysex, len %d\0A\00"
define void @blofeld_midi_sysex(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i32, i32* %4
%8 = call i32 @xprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %4
%10 = icmp sle i32 %9, 2
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 19
br i1 %16, label %17, label %18
17: ; preds = %11, %2
br label %53
18: ; preds = %11
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 4
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
switch i32 %22, label %52 [
i32 32, label %23
i32 16, label %41
i32 0, label %51
i32 4, label %51
i32 20, label %51
]
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 6
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = shl i32 %27, 7
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 7
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = or i32 %28, %32
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 5
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 8
%39 = load i8, i8* %38
%40 = call i32 @update_ui(i32 %33, i8 zeroext %36, i8 zeroext %39)
br label %53
41: ; preds = %18
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i64 5
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = icmp eq i32 %45, 127
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i8*, i8** %5
%49 = call i32 @receive_sndd(i8* %48)
br label %50
50: ; preds = %47, %41
br label %53
51: ; preds = %18, %18, %18
br label %52
52: ; preds = %18, %51
br label %53
53: ; preds = %17, %52, %50, %23
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Blofeld received sysex, len %d\0A\00"
define void @blofeld_midi_sysex(i8* %0, i32 %1) {
%3 = tail call i32 @xprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = icmp slt i32 %1, 3
br i1 %4, label %34, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 2
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 19
br i1 %8, label %9, label %34
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 4
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = tail call i32 @llvm.fshl.i32(i32 %12, i32 %12, i32 30)
switch i32 %13, label %34 [
i32 8, label %14
i32 4, label %28
]
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %0, i64 6
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl nuw nsw i32 %17, 7
%19 = getelementptr inbounds i8, i8* %0, i64 7
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = or i32 %18, %21
%23 = getelementptr inbounds i8, i8* %0, i64 5
%24 = load i8, i8* %23
%25 = getelementptr inbounds i8, i8* %0, i64 8
%26 = load i8, i8* %25
%27 = tail call i32 @update_ui(i32 %22, i8 zeroext %24, i8 zeroext %26)
br label %34
28: ; preds = %9
%29 = getelementptr inbounds i8, i8* %0, i64 5
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 127
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 @receive_sndd(i8* %0)
br label %34
34: ; preds = %14, %32, %28, %9, %2, %5
ret void
}