#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_ctrl_set_record_mode(int /*<<< orphan*/);
int /*<<< orphan*/ seq_engine_get_current_scene();
int /*<<< orphan*/ song_set_motion_dir(int /*<<< orphan*/, int, int);
void seq_ctrl_set_motion_dir(int track, int dir) {
  int i, val;
  seq_ctrl_set_record_mode(0);
  if (dir) {
    val = 1;
  } else {
    val = 0;
  }
  if (track == -1) {
    for (i = 0; i < 6; i++) {
      song_set_motion_dir(seq_engine_get_current_scene(), i, val);
    }
  } else {
    if (track < 0 || track >= 6) {
      log_error("scsmd - track invalid: %d", track);
      return;
    }
    song_set_motion_dir(seq_engine_get_current_scene(), track, val);
  }
}


x86 assembly (clang, -O0):
<seq_ctrl_set_motion_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %edi,%edi
call   1040 <seq_ctrl_set_record_mode@plt>
cmpl   $0x0,-0x8(%rbp)
je     116b <seq_ctrl_set_motion_dir+0x2b>
movl   $0x1,-0x10(%rbp)
jmp    1172 <seq_ctrl_set_motion_dir+0x32>
movl   $0x0,-0x10(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    11b4 <seq_ctrl_set_motion_dir+0x74>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    11af <seq_ctrl_set_motion_dir+0x6f>
mov    $0x0,%al
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <song_set_motion_dir@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <seq_ctrl_set_motion_dir+0x43>
jmp    11f0 <seq_ctrl_set_motion_dir+0xb0>
cmpl   $0x0,-0x4(%rbp)
jl     11c8 <seq_ctrl_set_motion_dir+0x88>
cmpl   $0x6,-0x4(%rbp)
jl     11dc <seq_ctrl_set_motion_dir+0x9c>
mov    -0x4(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1030 <log_error@plt>
jmp    11f0 <seq_ctrl_set_motion_dir+0xb0>
mov    $0x0,%al
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <song_set_motion_dir@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_set_motion_dir>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
call   1040 <seq_ctrl_set_record_mode@plt>
xor    %r14d,%r14d
test   %ebx,%ebx
setne  %r14b
cmp    $0xffffffff,%ebp
je     1178 <seq_ctrl_set_motion_dir+0x38>
cmp    $0x6,%ebp
jb     11f3 <seq_ctrl_set_motion_dir+0xb3>
lea    0xe93(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <log_error@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <song_set_motion_dir@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x1,%esi
mov    %r14d,%edx
call   1050 <song_set_motion_dir@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x2,%esi
mov    %r14d,%edx
call   1050 <song_set_motion_dir@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    %r14d,%edx
call   1050 <song_set_motion_dir@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x4,%esi
mov    %r14d,%edx
call   1050 <song_set_motion_dir@plt>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x5,%esi
jmp    11fe <seq_ctrl_set_motion_dir+0xbe>
xor    %eax,%eax
call   1060 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <song_set_motion_dir@plt>

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

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