#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*/ close_note(int, int);
scalar_t__ cut_beginning();
int /*<<< orphan*/ mf_write_midi_event(int, int, char *, int);
int /*<<< orphan*/ open_note(int, int);
void copy_noteon(int chan, int c1, int c2) {
  char data[2];
  if (c2 > 0)
    open_note(chan, c1);
  else
    close_note(chan, c1);
  if (cut_beginning())
    return;
  data[0] = (char)c1;
  data[1] = (char)c2;
  mf_write_midi_event(0x90, chan, data, 2);
}


x86 assembly (clang, -O0):
<copy_noteon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    116b <copy_noteon+0x2b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <open_note@plt>
jmp    1176 <copy_noteon+0x36>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <close_note@plt>
mov    $0x0,%al
call   1050 <cut_beginning@plt>
cmp    $0x0,%rax
je     118c <copy_noteon+0x4c>
jmp    11ae <copy_noteon+0x6e>
mov    -0x8(%rbp),%eax
mov    %al,-0xe(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
mov    -0x4(%rbp),%esi
lea    -0xe(%rbp),%rdx
mov    $0x90,%edi
mov    $0x2,%ecx
call   1030 <mf_write_midi_event@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_noteon>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r14d
test   %edx,%edx
jle    115a <copy_noteon+0x1a>
call   1060 <open_note@plt>
jmp    115f <copy_noteon+0x1f>
call   1040 <close_note@plt>
xor    %eax,%eax
call   1050 <cut_beginning@plt>
test   %rax,%rax
jne    118b <copy_noteon+0x4b>
mov    %bl,0xe(%rsp)
mov    %bpl,0xf(%rsp)
lea    0xe(%rsp),%rdx
mov    $0x90,%edi
mov    %r14d,%esi
mov    $0x2,%ecx
call   1030 <mf_write_midi_event@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @copy_noteon(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = call i32 @open_note(i32 %11, i32 %12)
br label %18
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 @close_note(i32 %15, i32 %16)
br label %18
18: ; preds = %14, %10
%19 = call i64 (...) @cut_beginning()
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %32
22: ; preds = %18
%23 = load i32, i32* %5
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 %24, i8* %25
%26 = load i32, i32* %6
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
store i8 %27, i8* %28
%29 = load i32, i32* %4
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%31 = call i32 @mf_write_midi_event(i32 144, i32 %29, i8* %30, i32 2)
br label %32
32: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
define void @copy_noteon(i32 %0, i32 %1, i32 %2) {
%4 = alloca [2 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @open_note(i32 %0, i32 %1)
br label %11
9: ; preds = %3
%10 = tail call i32 @close_note(i32 %0, i32 %1)
br label %11
11: ; preds = %9, %7
%12 = tail call i64 (...) @cut_beginning()
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = trunc i32 %1 to i8
store i8 %15, i8* %5
%16 = trunc i32 %2 to i8
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
store i8 %16, i8* %17
%18 = call i32 @mf_write_midi_event(i32 144, i32 %0, i8* %5, i32 2)
br label %19
19: ; preds = %11, %14
ret void
}