int mf_write_midi_event(delta_time, type, chan, data, size)
long delta_time;
int chan, type;
int size;
char *data;
{
  int i;
  char c;
  WriteVarLen(delta_time);
  c = (char)(type | chan);
  if (chan > 15) {
    mferror("error: MIDI channel greater than 16");
  };
  eputc(c);
  for (i = 0; i < size; i++)
    eputc(data[i]);
  return (size);
}


x86 assembly (clang, -O0):
<mf_write_midi_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <WriteVarLen@plt>
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %al,-0x21(%rbp)
cmpl   $0xf,-0x10(%rbp)
jle    1176 <mf_write_midi_event+0x46>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <mferror@plt>
movsbl -0x21(%rbp),%edi
mov    $0x0,%al
call   1050 <eputc@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b5 <mf_write_midi_event+0x85>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
mov    $0x0,%al
call   1050 <eputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1188 <mf_write_midi_event+0x58>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mf_write_midi_event>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %edx,%ebp
mov    %esi,%r15d
xor    %eax,%eax
call   1030 <WriteVarLen@plt>
or     %ebp,%r15d
cmp    $0x10,%ebp
jl     1160 <mf_write_midi_event+0x30>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <mferror@plt>
movsbl %r15b,%edi
xor    %eax,%eax
call   1050 <eputc@plt>
test   %r14d,%r14d
jle    1195 <mf_write_midi_event+0x65>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r12,%rbx,1),%edi
xor    %eax,%eax
call   1050 <eputc@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <mf_write_midi_event+0x50>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"error: MIDI channel greater than 16\00"
define i32 @mf_write_midi_event(i64 %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i64 %0, i64* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load i64, i64* %6
%14 = call i32 (i64, ...) bitcast (i32 (...)* @WriteVarLen to i32 (i64, ...)*)(i64 %13)
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = or i32 %15, %16
%18 = trunc i32 %17 to i8
store i8 %18, i8* %12
%19 = load i32, i32* %8
%20 = icmp sgt i32 %19, 15
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @mferror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %5
%24 = load i8, i8* %12
%25 = sext i8 %24 to i32
%26 = call i32 (i32, ...) bitcast (i32 (...)* @eputc to i32 (i32, ...)*)(i32 %25)
store i32 0, i32* %11
br label %27
27: ; preds = %39, %23
%28 = load i32, i32* %11
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %42
31: ; preds = %27
%32 = load i8*, i8** %9
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 (i32, ...) bitcast (i32 (...)* @eputc to i32 (i32, ...)*)(i32 %37)
br label %39
39: ; preds = %31
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %27
42: ; preds = %27
%43 = load i32, i32* %10
ret i32 %43
}

LLVM IR (-O2):
@.str = [36 x i8] c"error: MIDI channel greater than 16\00"
define i32 @mf_write_midi_event(i64 %0, i32 %1, i32 %2, i8* nocapture %3, i32 returned %4) {
%6 = tail call i32 (i64, ...) bitcast (i32 (...)* @WriteVarLen to i32 (i64, ...)*)(i64 %0)
%7 = or i32 %2, %1
%8 = icmp sgt i32 %2, 15
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @mferror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %5
%12 = shl i32 %7, 24
%13 = ashr exact i32 %12, 24
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @eputc to i32 (i32, ...)*)(i32 %13)
%15 = icmp sgt i32 %4, 0
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = zext i32 %4 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %24, %18 ]
%20 = getelementptr inbounds i8, i8* %3, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @eputc to i32 (i32, ...)*)(i32 %22)
%24 = add nuw nsw i64 %19, 1
%25 = icmp eq i64 %24, %17
br i1 %25, label %26, label %18
26: ; preds = %18, %11
ret i32 %4
}