#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int send_command(unsigned int channel, unsigned char device,
                 unsigned char command, FILE *midiport) {
  if (channel >= 16) {
    fputs("send_command: channel out of range\n", stderr);
    return 0;
  }
  fputc(0xF0, midiport);
  fputc(0x42, midiport);
  fputc(0x30 + channel, midiport);
  fputc(device, midiport);
  fputc(command, midiport);
  fputc(0xF7, midiport);
  return 1;
}


x86 assembly (clang, -O0):
<send_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %edi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x10,-0x8(%rbp)
jb     1165 <send_command+0x45>
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bf <send_command+0x9f>
mov    -0x18(%rbp),%rsi
mov    $0xf0,%edi
call   1040 <fputc@plt>
mov    -0x18(%rbp),%rsi
mov    $0x42,%edi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%edi
add    $0x30,%edi
mov    -0x18(%rbp),%rsi
call   1040 <fputc@plt>
movzbl -0x9(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <fputc@plt>
movzbl -0xa(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x18(%rbp),%rsi
mov    $0xf7,%edi
call   1040 <fputc@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_command>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x10,%edi
jb     1145 <send_command+0x25>
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
lea    0xec4(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
jmp    11a1 <send_command+0x81>
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
mov    $0xf0,%edi
mov    %rcx,%rsi
call   1040 <fputc@plt>
mov    $0x42,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x30,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
movzbl %r15b,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
movzbl %r14b,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0xf7,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"send_command: channel out of range\0A\00"
@stderr = global i32 0
define i32 @send_command(i32 %0, i8 zeroext %1, i8 zeroext %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32*
store i32 %0, i32* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i32* %3, i32** %9
%10 = load i32, i32* %6
%11 = icmp uge i32 %10, 16
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %5
br label %34
15: ; preds = %4
%16 = load i32*, i32** %9
%17 = call i32 @fputc(i32 240, i32* %16)
%18 = load i32*, i32** %9
%19 = call i32 @fputc(i32 66, i32* %18)
%20 = load i32, i32* %6
%21 = add i32 48, %20
%22 = load i32*, i32** %9
%23 = call i32 @fputc(i32 %21, i32* %22)
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = load i32*, i32** %9
%27 = call i32 @fputc(i32 %25, i32* %26)
%28 = load i8, i8* %8
%29 = zext i8 %28 to i32
%30 = load i32*, i32** %9
%31 = call i32 @fputc(i32 %29, i32* %30)
%32 = load i32*, i32** %9
%33 = call i32 @fputc(i32 247, i32* %32)
store i32 1, i32* %5
br label %34
34: ; preds = %15, %12
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
@.str = [36 x i8] c"send_command: channel out of range\0A\00"
@stderr = global i32 0
define i32 @send_command(i32 %0, i8 zeroext %1, i8 zeroext %2, i32* nocapture %3) {
%5 = icmp ugt i32 %0, 15
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %19
9: ; preds = %4
%10 = tail call i32 @fputc(i32 240, i32* %3)
%11 = tail call i32 @fputc(i32 66, i32* %3)
%12 = add nuw nsw i32 %0, 48
%13 = tail call i32 @fputc(i32 %12, i32* %3)
%14 = zext i8 %1 to i32
%15 = tail call i32 @fputc(i32 %14, i32* %3)
%16 = zext i8 %2 to i32
%17 = tail call i32 @fputc(i32 %16, i32* %3)
%18 = tail call i32 @fputc(i32 247, i32* %3)
br label %19
19: ; preds = %9, %6
%20 = phi i32 [ 0, %6 ], [ 1, %9 ]
ret i32 %20
}