#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*/ log_error(char *, int);
int /*<<< orphan*/ seq_utils_clamp(scalar_t__, int /*<<< orphan*/, int);
scalar_t__ song_get_midi_port_clock_out(int);
int /*<<< orphan*/ song_set_midi_port_clock_out(int, int /*<<< orphan*/);
void seq_ctrl_adjust_clock_out_rate(int port, int change) {
  if (port < 0 || port >= 5) {
    log_error("scacor - port invalid: %d", port);
    return;
  }
  song_set_midi_port_clock_out(
      port,
      seq_utils_clamp(song_get_midi_port_clock_out(port) + change, 0, (9 - 1)));
}


x86 assembly (clang, -O0):
<seq_ctrl_adjust_clock_out_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1162 <seq_ctrl_adjust_clock_out_rate+0x22>
cmpl   $0x5,-0x4(%rbp)
jl     1176 <seq_ctrl_adjust_clock_out_rate+0x36>
mov    -0x4(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1040 <log_error@plt>
jmp    11a4 <seq_ctrl_adjust_clock_out_rate+0x64>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <song_get_midi_port_clock_out@plt>
mov    %rax,%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <seq_utils_clamp@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1060 <song_set_midi_port_clock_out@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_adjust_clock_out_rate>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x5,%edi
jb     115e <seq_ctrl_adjust_clock_out_rate+0x1e>
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <log_error@plt>
mov    %esi,%ebp
mov    %ebx,%edi
call   1030 <song_get_midi_port_clock_out@plt>
movslq %ebp,%rdi
add    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <seq_utils_clamp@plt>
mov    %ebx,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <song_set_midi_port_clock_out@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"scacor - port invalid: %d\00"
define void @seq_ctrl_adjust_clock_out_rate(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 5
br i1 %9, label %10, label %13
10: ; preds = %7, %2
%11 = load i32, i32* %3
%12 = call i32 @log_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %22
13: ; preds = %7
%14 = load i32, i32* %3
%15 = load i32, i32* %3
%16 = call i64 @song_get_midi_port_clock_out(i32 %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = add nsw i64 %16, %18
%20 = call i32 @seq_utils_clamp(i64 %19, i32 0, i32 8)
%21 = call i32 @song_set_midi_port_clock_out(i32 %14, i32 %20)
br label %22
22: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"scacor - port invalid: %d\00"
define void @seq_ctrl_adjust_clock_out_rate(i32 %0, i32 %1) {
%3 = icmp ugt i32 %0, 4
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @log_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %12
6: ; preds = %2
%7 = tail call i64 @song_get_midi_port_clock_out(i32 %0)
%8 = sext i32 %1 to i64
%9 = add nsw i64 %7, %8
%10 = tail call i32 @seq_utils_clamp(i64 %9, i32 0, i32 8)
%11 = tail call i32 @song_set_midi_port_clock_out(i32 %0, i32 %10)
br label %12
12: ; preds = %6, %4
ret void
}