#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*/ copy_keysig(char, char);
int /*<<< orphan*/ copy_metaeot();
int /*<<< orphan*/ copy_metamisc(int, int, char *);
int /*<<< orphan*/ copy_metaseqnum(int /*<<< orphan*/);
int /*<<< orphan*/ copy_metaspecial(int, char *);
int /*<<< orphan*/ copy_metatext(int, int, char *);
int /*<<< orphan*/ copy_timesig(char, char, char, char);
int /*<<< orphan*/ mf_write_meta_event(int, char *, int);
int /*<<< orphan*/ mf_write_tempo(int /*<<< orphan*/);
char *msg();
int msgleng();
int /*<<< orphan*/ to16bit(char, char);
int /*<<< orphan*/ to32bit(int /*<<< orphan*/, char, char, char);
void metaevent(int type) {
  int leng;
  char *m;
  leng = msgleng();
  m = msg();
  switch (type) {
  case 0x00:
    copy_metaseqnum(to16bit(m[0], m[1]));
    break;
  case 0x01:
  case 0x02:
  case 0x03:
  case 0x04:
  case 0x05:
  case 0x06:
  case 0x07:
  case 0x08:
  case 0x09:
  case 0x0a:
  case 0x0b:
  case 0x0c:
  case 0x0d:
  case 0x0e:
  case 0x0f:
    copy_metatext(type, leng, m);
    break;
  case 0x2f:
    copy_metaeot();
    break;
  case 0x51:
    mf_write_tempo(to32bit(0, m[0], m[1], m[2]));
    break;
  case 0x54:
    mf_write_meta_event(0x54, m, 5);
    break;
  case 0x58:
    copy_timesig(m[0], m[1], m[2], m[3]);
    break;
  case 0x59:
    copy_keysig(m[0], m[1]);
    break;
  case 0x7f:
    copy_metaspecial(leng, m);
    break;
  default:
    copy_metamisc(type, leng, m);
  }
}


x86 assembly (clang, -O0):
<metaevent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1040 <msgleng@plt>
mov    %eax,%ecx
mov    -0x19(%rbp),%al
mov    %ecx,-0x8(%rbp)
call   10f0 <msg@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x7f,%rax
ja     1300 <metaevent+0x130>
mov    -0x18(%rbp),%rax
lea    0xdee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
movsbl %cl,%edi
movsbl 0x1(%rax),%esi
call   10e0 <to16bit@plt>
mov    %eax,%edi
call   1060 <copy_metaseqnum@plt>
jmp    130f <metaevent+0x13f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <copy_metatext@plt>
jmp    130f <metaevent+0x13f>
mov    $0x0,%al
call   10a0 <copy_metaeot@plt>
jmp    130f <metaevent+0x13f>
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
xor    %edi,%edi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl 0x2(%rax),%ecx
call   1050 <to32bit@plt>
mov    %eax,%edi
call   10d0 <mf_write_tempo@plt>
jmp    130f <metaevent+0x13f>
mov    -0x10(%rbp),%rsi
mov    $0x54,%edi
mov    $0x5,%edx
call   10c0 <mf_write_meta_event@plt>
jmp    130f <metaevent+0x13f>
mov    -0x10(%rbp),%rax
mov    (%rax),%sil
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%dl
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x10(%rbp),%rax
movsbl %sil,%edi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl 0x3(%rax),%ecx
call   10b0 <copy_timesig@plt>
jmp    130f <metaevent+0x13f>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
movsbl %cl,%edi
movsbl 0x1(%rax),%esi
call   1090 <copy_keysig@plt>
jmp    130f <metaevent+0x13f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <copy_metaspecial@plt>
jmp    130f <metaevent+0x13f>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1080 <copy_metamisc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<metaevent>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <msgleng@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10f0 <msg@plt>
cmp    $0x7f,%ebx
ja     1227 <metaevent+0x57>
mov    %ebx,%ecx
lea    0xe0d(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    %ebx,%edi
mov    %ebp,%esi
mov    %rax,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <copy_metatext@plt>
movsbl (%rax),%edi
movsbl 0x1(%rax),%esi
call   10e0 <to16bit@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <copy_metaseqnum@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %rax,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <copy_metamisc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10a0 <copy_metaeot@plt>
movsbl (%rax),%esi
movsbl 0x1(%rax),%edx
movsbl 0x2(%rax),%ecx
xor    %edi,%edi
call   1050 <to32bit@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10d0 <mf_write_tempo@plt>
mov    $0x54,%edi
mov    %rax,%rsi
mov    $0x5,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10c0 <mf_write_meta_event@plt>
movsbl (%rax),%edi
movsbl 0x1(%rax),%esi
movsbl 0x2(%rax),%edx
movsbl 0x3(%rax),%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10b0 <copy_timesig@plt>
movsbl (%rax),%edi
movsbl 0x1(%rax),%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <copy_keysig@plt>
mov    %ebp,%edi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <copy_metaspecial@plt>

LLVM IR (-O0):
define void @metaevent(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
%5 = call i32 (...) @msgleng()
store i32 %5, i32* %3
%6 = call i8* (...) @msg()
store i8* %6, i8** %4
%7 = load i32, i32* %2
switch i32 %7, label %65 [
i32 0, label %8
i32 1, label %17
i32 2, label %17
i32 3, label %17
i32 4, label %17
i32 5, label %17
i32 6, label %17
i32 7, label %17
i32 8, label %17
i32 9, label %17
i32 10, label %17
i32 11, label %17
i32 12, label %17
i32 13, label %17
i32 14, label %17
i32 15, label %17
i32 47, label %22
i32 81, label %24
i32 84, label %36
i32 88, label %39
i32 89, label %53
i32 127, label %61
]
8: ; preds = %1
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = call i32 @to16bit(i8 signext %11, i8 signext %14)
%16 = call i32 @copy_metaseqnum(i32 %15)
br label %70
17: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i8*, i8** %4
%21 = call i32 @copy_metatext(i32 %18, i32 %19, i8* %20)
br label %70
22: ; preds = %1
%23 = call i32 (...) @copy_metaeot()
br label %70
24: ; preds = %1
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 2
%33 = load i8, i8* %32
%34 = call i32 @to32bit(i32 0, i8 signext %27, i8 signext %30, i8 signext %33)
%35 = call i32 @mf_write_tempo(i32 %34)
br label %70
36: ; preds = %1
%37 = load i8*, i8** %4
%38 = call i32 @mf_write_meta_event(i32 84, i8* %37, i32 5)
br label %70
39: ; preds = %1
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 2
%48 = load i8, i8* %47
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 3
%51 = load i8, i8* %50
%52 = call i32 @copy_timesig(i8 signext %42, i8 signext %45, i8 signext %48, i8 signext %51)
br label %70
53: ; preds = %1
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = load i8, i8* %55
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = load i8, i8* %58
%60 = call i32 @copy_keysig(i8 signext %56, i8 signext %59)
br label %70
61: ; preds = %1
%62 = load i32, i32* %3
%63 = load i8*, i8** %4
%64 = call i32 @copy_metaspecial(i32 %62, i8* %63)
br label %70
65: ; preds = %1
%66 = load i32, i32* %2
%67 = load i32, i32* %3
%68 = load i8*, i8** %4
%69 = call i32 @copy_metamisc(i32 %66, i32 %67, i8* %68)
br label %70
70: ; preds = %65, %61, %53, %39, %36, %24, %22, %17, %8
ret void
}

LLVM IR (-O2):
define void @metaevent(i32 %0) {
%2 = tail call i32 (...) @msgleng()
%3 = tail call i8* (...) @msg()
switch i32 %0, label %40 [
i32 0, label %4
i32 1, label %10
i32 2, label %10
i32 3, label %10
i32 4, label %10
i32 5, label %10
i32 6, label %10
i32 7, label %10
i32 8, label %10
i32 9, label %10
i32 10, label %10
i32 11, label %10
i32 12, label %10
i32 13, label %10
i32 14, label %10
i32 15, label %10
i32 47, label %12
i32 81, label %14
i32 84, label %22
i32 88, label %24
i32 89, label %33
i32 127, label %38
]
4: ; preds = %1
%5 = load i8, i8* %3
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %6
%8 = tail call i32 @to16bit(i8 signext %5, i8 signext %7)
%9 = tail call i32 @copy_metaseqnum(i32 %8)
br label %42
10: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
%11 = tail call i32 @copy_metatext(i32 %0, i32 %2, i8* %3)
br label %42
12: ; preds = %1
%13 = tail call i32 (...) @copy_metaeot()
br label %42
14: ; preds = %1
%15 = load i8, i8* %3
%16 = getelementptr inbounds i8, i8* %3, i64 1
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %3, i64 2
%19 = load i8, i8* %18
%20 = tail call i32 @to32bit(i32 0, i8 signext %15, i8 signext %17, i8 signext %19)
%21 = tail call i32 @mf_write_tempo(i32 %20)
br label %42
22: ; preds = %1
%23 = tail call i32 @mf_write_meta_event(i32 84, i8* %3, i32 5)
br label %42
24: ; preds = %1
%25 = load i8, i8* %3
%26 = getelementptr inbounds i8, i8* %3, i64 1
%27 = load i8, i8* %26
%28 = getelementptr inbounds i8, i8* %3, i64 2
%29 = load i8, i8* %28
%30 = getelementptr inbounds i8, i8* %3, i64 3
%31 = load i8, i8* %30
%32 = tail call i32 @copy_timesig(i8 signext %25, i8 signext %27, i8 signext %29, i8 signext %31)
br label %42
33: ; preds = %1
%34 = load i8, i8* %3
%35 = getelementptr inbounds i8, i8* %3, i64 1
%36 = load i8, i8* %35
%37 = tail call i32 @copy_keysig(i8 signext %34, i8 signext %36)
br label %42
38: ; preds = %1
%39 = tail call i32 @copy_metaspecial(i32 %2, i8* %3)
br label %42
40: ; preds = %1
%41 = tail call i32 @copy_metamisc(i32 %0, i32 %2, i8* %3)
br label %42
42: ; preds = %40, %38, %33, %24, %22, %14, %12, %10, %4
ret void
}