#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_cv_output_scaling(int);
int /*<<< orphan*/ song_set_cv_output_scaling(int, int /*<<< orphan*/);
void seq_ctrl_adjust_cv_output_scaling(int out, int change) {
  if (out < 0 || out >= 4) {
    log_error("scacos - out invalid: %d", out);
    return;
  }
  song_set_cv_output_scaling(
      out, seq_utils_clamp(song_get_cv_output_scaling(out) + change, 0, (1)));
}


x86 assembly (clang, -O0):
<seq_ctrl_adjust_cv_output_scaling>:
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_cv_output_scaling+0x22>
cmpl   $0x4,-0x4(%rbp)
jl     1176 <seq_ctrl_adjust_cv_output_scaling+0x36>
mov    -0x4(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1030 <log_error@plt>
jmp    11a4 <seq_ctrl_adjust_cv_output_scaling+0x64>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <song_get_cv_output_scaling@plt>
mov    %rax,%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <seq_utils_clamp@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1040 <song_set_cv_output_scaling@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [25 x i8] c"scacos - out invalid: %d\00"
define void @seq_ctrl_adjust_cv_output_scaling(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, 4
br i1 %9, label %10, label %13
10: ; preds = %7, %2
%11 = load i32, i32* %3
%12 = call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 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_cv_output_scaling(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 1)
%21 = call i32 @song_set_cv_output_scaling(i32 %14, i32 %20)
br label %22
22: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"scacos - out invalid: %d\00"
define void @seq_ctrl_adjust_cv_output_scaling(i32 %0, i32 %1) {
%3 = icmp ugt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %12
6: ; preds = %2
%7 = tail call i64 @song_get_cv_output_scaling(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 1)
%11 = tail call i32 @song_set_cv_output_scaling(i32 %0, i32 %10)
br label %12
12: ; preds = %6, %4
ret void
}