int mywritetrack(track)
int track;
{
  int i;
  char data[2];
  mf_write_tempo((long)500000);
  for (i = 1; i < 128; i++) {
    data[0] = i;
    data[1] = 64;
    if (!mf_write_midi_event(480, 0x90, 1, data, 2))
      return (-1);
    if (!mf_write_midi_event(480, 0x80, 1, data, 2))
      return (-1);
  }
  return (1);
}


x86 assembly (clang, -O0):
<mywritetrack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x7a120,%edi
mov    $0x0,%al
call   1040 <mf_write_tempo@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    11d2 <mywritetrack+0xb2>
mov    -0xc(%rbp),%eax
mov    %al,-0xe(%rbp)
movb   $0x40,-0xd(%rbp)
lea    -0xe(%rbp),%rcx
mov    $0x1e0,%edi
mov    $0x90,%esi
mov    $0x1,%edx
mov    $0x2,%r8d
mov    $0x0,%al
call   1030 <mf_write_midi_event@plt>
cmp    $0x0,%eax
jne    118a <mywritetrack+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d9 <mywritetrack+0xb9>
lea    -0xe(%rbp),%rcx
mov    $0x1e0,%edi
mov    $0x80,%esi
mov    $0x1,%edx
mov    $0x2,%r8d
mov    $0x0,%al
call   1030 <mf_write_midi_event@plt>
cmp    $0x0,%eax
jne    11bf <mywritetrack+0x9f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d9 <mywritetrack+0xb9>
jmp    11c4 <mywritetrack+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <mywritetrack+0x1e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mywritetrack>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x7a120,%edi
xor    %eax,%eax
call   1040 <mf_write_tempo@plt>
mov    $0xffffff81,%ebx
lea    0xe(%rsp),%r14
mov    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x80(%rbx),%eax
mov    %al,0xe(%rsp)
movb   $0x40,0xf(%rsp)
mov    $0x1e0,%edi
mov    $0x90,%esi
mov    $0x1,%edx
mov    %r14,%rcx
mov    $0x2,%r8d
xor    %eax,%eax
call   1030 <mf_write_midi_event@plt>
test   %eax,%eax
je     11ab <mywritetrack+0x8b>
mov    $0x1e0,%edi
mov    $0x80,%esi
mov    $0x1,%edx
mov    %r14,%rcx
mov    $0x2,%r8d
xor    %eax,%eax
call   1030 <mf_write_midi_event@plt>
test   %eax,%eax
je     11ab <mywritetrack+0x8b>
inc    %ebx
jne    1150 <mywritetrack+0x30>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mywritetrack(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
store i32 %0, i32* %3
%6 = call i32 (i64, ...) bitcast (i32 (...)* @mf_write_tempo to i32 (i64, ...)*)(i64 500000)
store i32 1, i32* %4
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 128
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %4
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
store i8 %12, i8* %13
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 64, i8* %14
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%16 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @mf_write_midi_event to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 480, i32 144, i32 1, i8* %15, i32 2)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %10
store i32 -1, i32* %2
br label %29
19: ; preds = %10
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%21 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @mf_write_midi_event to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 480, i32 128, i32 1, i8* %20, i32 2)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
store i32 -1, i32* %2
br label %29
24: ; preds = %19
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %7
28: ; preds = %7
store i32 1, i32* %2
br label %29
29: ; preds = %28, %23, %18
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @mywritetrack(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i64, ...) bitcast (i32 (...)* @mf_write_tempo to i32 (i64, ...)*)(i64 500000)
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
br label %9
6: ; preds = %14
%7 = add nuw nsw i32 %10, 1
%8 = icmp eq i32 %7, 128
br i1 %8, label %17, label %9
9: ; preds = %1, %6
%10 = phi i32 [ 1, %1 ], [ %7, %6 ]
%11 = trunc i32 %10 to i8
store i8 %11, i8* %3
store i8 64, i8* %5
%12 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @mf_write_midi_event to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 480, i32 144, i32 1, i8* %3, i32 2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = call i32 (i32, i32, i32, i8*, i32, ...) bitcast (i32 (...)* @mf_write_midi_event to i32 (i32, i32, i32, i8*, i32, ...)*)(i32 480, i32 128, i32 1, i8* %3, i32 2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %6, %14, %9
%18 = phi i32 [ -1, %9 ], [ -1, %14 ], [ 1, %6 ]
ret i32 %18
}