#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_engine_get_current_scene();
int seq_utils_clamp(int, int, int);
int /*<<< orphan*/ song_set_transpose(int /*<<< orphan*/, int, int);
void seq_ctrl_set_transpose(int track, int transpose) {
  int i, val;
  val = seq_utils_clamp(transpose, -24, 24);
  if (track == -1) {
    for (i = 0; i < 6; i++) {
      song_set_transpose(seq_engine_get_current_scene(), i, val);
    }
  } else {
    if (track < 0 || track >= 6) {
      log_error("scst - track invalid: %d", track);
      return;
    }
    song_set_transpose(seq_engine_get_current_scene(), track, val);
  }
}


x86 assembly (clang, -O0):
<seq_ctrl_set_transpose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0xffffffe8,%esi
mov    $0x18,%edx
call   1060 <seq_utils_clamp@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    11a5 <seq_ctrl_set_transpose+0x65>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    11a0 <seq_ctrl_set_transpose+0x60>
mov    $0x0,%al
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <song_set_transpose@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <seq_ctrl_set_transpose+0x34>
jmp    11e1 <seq_ctrl_set_transpose+0xa1>
cmpl   $0x0,-0x4(%rbp)
jl     11b9 <seq_ctrl_set_transpose+0x79>
cmpl   $0x6,-0x4(%rbp)
jl     11cd <seq_ctrl_set_transpose+0x8d>
mov    -0x4(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1030 <log_error@plt>
jmp    11e1 <seq_ctrl_set_transpose+0xa1>
mov    $0x0,%al
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <song_set_transpose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_set_transpose>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %esi,%edi
mov    $0xffffffe8,%esi
mov    $0x18,%edx
call   1060 <seq_utils_clamp@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%ebp
je     117a <seq_ctrl_set_transpose+0x3a>
cmp    $0x6,%ebp
jb     11f0 <seq_ctrl_set_transpose+0xb0>
lea    0xe93(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <log_error@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <song_set_transpose@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1050 <song_set_transpose@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1050 <song_set_transpose@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    %ebx,%edx
call   1050 <song_set_transpose@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x4,%esi
mov    %ebx,%edx
call   1050 <song_set_transpose@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x5,%esi
jmp    11fb <seq_ctrl_set_transpose+0xbb>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <song_set_transpose@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"scst - track invalid: %d\00"
define void @seq_ctrl_set_transpose(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @seq_utils_clamp(i32 %7, i32 -24, i32 24)
store i32 %8, i32* %6
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %24
11: ; preds = %2
store i32 0, i32* %5
br label %12
12: ; preds = %20, %11
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = call i32 (...) @seq_engine_get_current_scene()
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @song_set_transpose(i32 %16, i32 %17, i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %12
23: ; preds = %12
br label %38
24: ; preds = %2
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = icmp sge i32 %28, 6
br i1 %29, label %30, label %33
30: ; preds = %27, %24
%31 = load i32, i32* %3
%32 = call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %38
33: ; preds = %27
%34 = call i32 (...) @seq_engine_get_current_scene()
%35 = load i32, i32* %3
%36 = load i32, i32* %6
%37 = call i32 @song_set_transpose(i32 %34, i32 %35, i32 %36)
br label %38
38: ; preds = %30, %33, %23
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"scst - track invalid: %d\00"
define void @seq_ctrl_set_transpose(i32 %0, i32 %1) {
%3 = tail call i32 @seq_utils_clamp(i32 %1, i32 -24, i32 24)
%4 = icmp eq i32 %0, -1
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = tail call i32 (...) @seq_engine_get_current_scene()
%7 = tail call i32 @song_set_transpose(i32 %6, i32 0, i32 %3)
%8 = tail call i32 (...) @seq_engine_get_current_scene()
%9 = tail call i32 @song_set_transpose(i32 %8, i32 1, i32 %3)
%10 = tail call i32 (...) @seq_engine_get_current_scene()
%11 = tail call i32 @song_set_transpose(i32 %10, i32 2, i32 %3)
%12 = tail call i32 (...) @seq_engine_get_current_scene()
%13 = tail call i32 @song_set_transpose(i32 %12, i32 3, i32 %3)
%14 = tail call i32 (...) @seq_engine_get_current_scene()
%15 = tail call i32 @song_set_transpose(i32 %14, i32 4, i32 %3)
%16 = tail call i32 (...) @seq_engine_get_current_scene()
%17 = tail call i32 @song_set_transpose(i32 %16, i32 5, i32 %3)
br label %25
18: ; preds = %2
%19 = icmp ugt i32 %0, 5
br i1 %19, label %20, label %22
20: ; preds = %18
%21 = tail call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %25
22: ; preds = %18
%23 = tail call i32 (...) @seq_engine_get_current_scene()
%24 = tail call i32 @song_set_transpose(i32 %23, i32 %0, i32 %3)
br label %25
25: ; preds = %5, %22, %20
ret void
}