#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*/ inmidi_noteon(int, int, int, int);
int libpd_noteon(int channel, int pitch, int velocity) {
  if (channel < 0)
    return -1;
  if (pitch < 0 || pitch > 0x7f)
    return -1;
  if (velocity < 0 || velocity > 0x7f)
    return -1;
  inmidi_noteon((channel >> 4), (channel & 0x0f), pitch, velocity);
  return 0;
}


x86 assembly (clang, -O0):
<libpd_noteon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1137 <libpd_noteon+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <libpd_noteon+0x85>
cmpl   $0x0,-0xc(%rbp)
jl     114b <libpd_noteon+0x3b>
cmpl   $0x7f,-0xc(%rbp)
jle    1157 <libpd_noteon+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <libpd_noteon+0x85>
cmpl   $0x0,-0x10(%rbp)
jl     116b <libpd_noteon+0x5b>
cmpl   $0x7f,-0x10(%rbp)
jle    1177 <libpd_noteon+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <libpd_noteon+0x85>
mov    -0x8(%rbp),%edi
sar    $0x4,%edi
mov    -0x8(%rbp),%esi
and    $0xf,%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <inmidi_noteon@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libpd_noteon>:
mov    $0xffffffff,%eax
test   %edi,%edi
js     113c <libpd_noteon+0x2c>
mov    %edx,%ecx
mov    %esi,%edx
mov    %edi,%esi
mov    %ecx,%edi
or     %edx,%edi
cmp    $0x7f,%edi
ja     113c <libpd_noteon+0x2c>
push   %rax
mov    %esi,%edi
shr    $0x4,%edi
and    $0xf,%esi
call   1030 <inmidi_noteon@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @libpd_noteon(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 -1, i32* %4
br label %33
11: ; preds = %3
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 127
br i1 %16, label %17, label %18
17: ; preds = %14, %11
store i32 -1, i32* %4
br label %33
18: ; preds = %14
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 127
br i1 %23, label %24, label %25
24: ; preds = %21, %18
store i32 -1, i32* %4
br label %33
25: ; preds = %21
%26 = load i32, i32* %5
%27 = ashr i32 %26, 4
%28 = load i32, i32* %5
%29 = and i32 %28, 15
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = call i32 @inmidi_noteon(i32 %27, i32 %29, i32 %30, i32 %31)
store i32 0, i32* %4
br label %33
33: ; preds = %25, %24, %17, %10
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @libpd_noteon(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %0, 0
%5 = or i32 %2, %1
%6 = icmp ugt i32 %5, 127
%7 = or i1 %4, %6
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = lshr i32 %0, 4
%10 = and i32 %0, 15
%11 = tail call i32 @inmidi_noteon(i32 %9, i32 %10, i32 %1, i32 %2)
br label %12
12: ; preds = %3, %8
%13 = phi i32 [ 0, %8 ], [ -1, %3 ]
ret i32 %13
}