#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 */
scalar_t__ seq_ctrl_get_track_select(int);
int /*<<< orphan*/ seq_engine_stop_live_notes();
int /*<<< orphan*/ seq_utils_clamp(scalar_t__, int /*<<< orphan*/, int);
scalar_t__ song_get_key_split(int);
int /*<<< orphan*/ song_set_key_split(int, int /*<<< orphan*/);
void seq_ctrl_adjust_key_split(int change) {
  int track;
  seq_engine_stop_live_notes();
  for (track = 0; track < 6; track++) {
    if (seq_ctrl_get_track_select(track)) {
      song_set_key_split(
          track, seq_utils_clamp(song_get_key_split(track) + change, 0, 2));
    }
  }
}


x86 assembly (clang, -O0):
<seq_ctrl_adjust_key_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <seq_engine_stop_live_notes@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11c6 <seq_ctrl_adjust_key_split+0x76>
mov    -0x8(%rbp),%edi
call   1050 <seq_ctrl_get_track_select@plt>
cmp    $0x0,%rax
je     11b3 <seq_ctrl_adjust_key_split+0x63>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <song_get_key_split@plt>
mov    %rax,%rdi
movslq -0x4(%rbp),%rax
add    %rax,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
jmp    11b8 <seq_ctrl_adjust_key_split+0x68>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <seq_ctrl_adjust_key_split+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_adjust_key_split>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <seq_engine_stop_live_notes@plt>
movslq %ebx,%rbx
xor    %edi,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     1189 <seq_ctrl_adjust_key_split+0x39>
xor    %edi,%edi
call   1060 <song_get_key_split@plt>
lea    (%rax,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
mov    $0x1,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     11be <seq_ctrl_adjust_key_split+0x6e>
mov    $0x1,%edi
call   1060 <song_get_key_split@plt>
lea    (%rax,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    $0x1,%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
mov    $0x2,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     11f3 <seq_ctrl_adjust_key_split+0xa3>
mov    $0x2,%edi
call   1060 <song_get_key_split@plt>
lea    (%rax,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    $0x2,%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
mov    $0x3,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     1228 <seq_ctrl_adjust_key_split+0xd8>
mov    $0x3,%edi
call   1060 <song_get_key_split@plt>
lea    (%rax,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    $0x3,%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
mov    $0x4,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     125d <seq_ctrl_adjust_key_split+0x10d>
mov    $0x4,%edi
call   1060 <song_get_key_split@plt>
lea    (%rax,%rbx,1),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    $0x4,%edi
mov    %eax,%esi
call   1030 <song_set_key_split@plt>
mov    $0x5,%edi
call   1050 <seq_ctrl_get_track_select@plt>
test   %rax,%rax
je     1295 <seq_ctrl_adjust_key_split+0x145>
mov    $0x5,%edi
call   1060 <song_get_key_split@plt>
add    %rax,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <seq_utils_clamp@plt>
mov    $0x5,%edi
mov    %eax,%esi
pop    %rbx
jmp    1030 <song_set_key_split@plt>
pop    %rbx
ret

LLVM IR (-O0):
define void @seq_ctrl_adjust_key_split(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @seq_engine_stop_live_notes()
store i32 0, i32* %3
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 6
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i64 @seq_ctrl_get_track_select(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = call i64 @song_get_key_split(i32 %14)
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = add nsw i64 %15, %17
%19 = call i32 @seq_utils_clamp(i64 %18, i32 0, i32 2)
%20 = call i32 @song_set_key_split(i32 %13, i32 %19)
br label %21
21: ; preds = %12, %8
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %5
25: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @seq_ctrl_adjust_key_split(i32 %0) {
%2 = tail call i32 (...) @seq_engine_stop_live_notes()
%3 = sext i32 %0 to i64
%4 = tail call i64 @seq_ctrl_get_track_select(i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = tail call i64 @song_get_key_split(i32 0)
%8 = add nsw i64 %7, %3
%9 = tail call i32 @seq_utils_clamp(i64 %8, i32 0, i32 2)
%10 = tail call i32 @song_set_key_split(i32 0, i32 %9)
br label %11
11: ; preds = %1, %6
%12 = tail call i64 @seq_ctrl_get_track_select(i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = tail call i64 @song_get_key_split(i32 1)
%16 = add nsw i64 %15, %3
%17 = tail call i32 @seq_utils_clamp(i64 %16, i32 0, i32 2)
%18 = tail call i32 @song_set_key_split(i32 1, i32 %17)
br label %19
19: ; preds = %14, %11
%20 = tail call i64 @seq_ctrl_get_track_select(i32 2)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = tail call i64 @song_get_key_split(i32 2)
%24 = add nsw i64 %23, %3
%25 = tail call i32 @seq_utils_clamp(i64 %24, i32 0, i32 2)
%26 = tail call i32 @song_set_key_split(i32 2, i32 %25)
br label %27
27: ; preds = %22, %19
%28 = tail call i64 @seq_ctrl_get_track_select(i32 3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = tail call i64 @song_get_key_split(i32 3)
%32 = add nsw i64 %31, %3
%33 = tail call i32 @seq_utils_clamp(i64 %32, i32 0, i32 2)
%34 = tail call i32 @song_set_key_split(i32 3, i32 %33)
br label %35
35: ; preds = %30, %27
%36 = tail call i64 @seq_ctrl_get_track_select(i32 4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %35
%39 = tail call i64 @song_get_key_split(i32 4)
%40 = add nsw i64 %39, %3
%41 = tail call i32 @seq_utils_clamp(i64 %40, i32 0, i32 2)
%42 = tail call i32 @song_set_key_split(i32 4, i32 %41)
br label %43
43: ; preds = %38, %35
%44 = tail call i64 @seq_ctrl_get_track_select(i32 5)
%45 = icmp eq i64 %44, 0
br i1 %45, label %51, label %46
46: ; preds = %43
%47 = tail call i64 @song_get_key_split(i32 5)
%48 = add nsw i64 %47, %3
%49 = tail call i32 @seq_utils_clamp(i64 %48, i32 0, i32 2)
%50 = tail call i32 @song_set_key_split(i32 5, i32 %49)
br label %51
51: ; preds = %46, %43
ret void
}