#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 /*<<< orphan*/ song_set_arp_enable(int /*<<< orphan*/, int, int);
void seq_ctrl_set_arp_enable(int track, int enable) {
  int i, val;
  if (enable) {
    val = 1;
  } else {
    val = 0;
  }
  if (track == -1) {
    for (i = 0; i < 6; i++) {
      song_set_arp_enable(seq_engine_get_current_scene(), i, val);
    }
  } else {
    if (track < 0 || track >= 6) {
      log_error("scsagt - track invalid: %d", track);
      return;
    }
    song_set_arp_enable(seq_engine_get_current_scene(), track, val);
  }
}


x86 assembly (clang, -O0):
<seq_ctrl_set_arp_enable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1154 <seq_ctrl_set_arp_enable+0x24>
movl   $0x1,-0x10(%rbp)
jmp    115b <seq_ctrl_set_arp_enable+0x2b>
movl   $0x0,-0x10(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    119d <seq_ctrl_set_arp_enable+0x6d>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    1198 <seq_ctrl_set_arp_enable+0x68>
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_arp_enable@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116c <seq_ctrl_set_arp_enable+0x3c>
jmp    11d9 <seq_ctrl_set_arp_enable+0xa9>
cmpl   $0x0,-0x4(%rbp)
jl     11b1 <seq_ctrl_set_arp_enable+0x81>
cmpl   $0x6,-0x4(%rbp)
jl     11c5 <seq_ctrl_set_arp_enable+0x95>
mov    -0x4(%rbp),%esi
lea    0xe45(%rip),%rdi
call   1030 <log_error@plt>
jmp    11d9 <seq_ctrl_set_arp_enable+0xa9>
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_arp_enable@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_set_arp_enable>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %esi,%esi
setne  %bl
cmp    $0xffffffff,%edi
je     115e <seq_ctrl_set_arp_enable+0x2e>
mov    %edi,%ebp
cmp    $0x6,%edi
jb     11d4 <seq_ctrl_set_arp_enable+0xa4>
lea    0xeaf(%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_arp_enable@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_arp_enable@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_arp_enable@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_arp_enable@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_arp_enable@plt>
xor    %eax,%eax
call   1040 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x5,%esi
jmp    11df <seq_ctrl_set_arp_enable+0xaf>
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_arp_enable@plt>

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

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