#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_pattern_type(int /*<<< orphan*/, int, int);
void seq_ctrl_set_pattern_type(int track, int pattern) {
  int i;
  if (pattern < 0 || pattern >= 32) {
    return;
  }
  if (track == -1) {
    for (i = 0; i < 6; i++) {
      song_set_pattern_type(seq_engine_get_current_scene(), i, pattern);
    }
  } else {
    if (track < 0 || track >= 6) {
      log_error("scspt - track invalid: %d", track);
      return;
    }
    song_set_pattern_type(seq_engine_get_current_scene(), track, pattern);
  }
}


x86 assembly (clang, -O0):
<seq_ctrl_set_pattern_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1152 <seq_ctrl_set_pattern_type+0x22>
cmpl   $0x20,-0x8(%rbp)
jl     1157 <seq_ctrl_set_pattern_type+0x27>
jmp    11d5 <seq_ctrl_set_pattern_type+0xa5>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1199 <seq_ctrl_set_pattern_type+0x69>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    1194 <seq_ctrl_set_pattern_type+0x64>
mov    $0x0,%al
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <song_set_pattern_type@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <seq_ctrl_set_pattern_type+0x38>
jmp    11d5 <seq_ctrl_set_pattern_type+0xa5>
cmpl   $0x0,-0x4(%rbp)
jl     11ad <seq_ctrl_set_pattern_type+0x7d>
cmpl   $0x6,-0x4(%rbp)
jl     11c1 <seq_ctrl_set_pattern_type+0x91>
mov    -0x4(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1040 <log_error@plt>
jmp    11d5 <seq_ctrl_set_pattern_type+0xa5>
mov    $0x0,%al
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <song_set_pattern_type@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_set_pattern_type>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1f,%esi
jbe    113f <seq_ctrl_set_pattern_type+0xf>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %esi,%ebx
mov    %edi,%ebp
cmp    $0xffffffff,%edi
je     1165 <seq_ctrl_set_pattern_type+0x35>
cmp    $0x6,%ebp
jb     11db <seq_ctrl_set_pattern_type+0xab>
lea    0xea8(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <log_error@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1030 <song_set_pattern_type@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1030 <song_set_pattern_type@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1030 <song_set_pattern_type@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x3,%esi
mov    %ebx,%edx
call   1030 <song_set_pattern_type@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x4,%esi
mov    %ebx,%edx
call   1030 <song_set_pattern_type@plt>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    $0x5,%esi
jmp    11e6 <seq_ctrl_set_pattern_type+0xb6>
xor    %eax,%eax
call   1050 <seq_engine_get_current_scene@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <song_set_pattern_type@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"scspt - track invalid: %d\00"
define void @seq_ctrl_set_pattern_type(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 32
br i1 %10, label %11, label %12
11: ; preds = %8, %2
br label %42
12: ; preds = %8
%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* %4
%23 = call i32 @song_set_pattern_type(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* %4
%41 = call i32 @song_set_pattern_type(i32 %38, i32 %39, i32 %40)
br label %42
42: ; preds = %11, %34, %37, %27
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"scspt - track invalid: %d\00"
define void @seq_ctrl_set_pattern_type(i32 %0, i32 %1) {
%3 = icmp ugt i32 %1, 31
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = icmp eq i32 %0, -1
br i1 %5, label %6, label %19
6: ; preds = %4
%7 = tail call i32 (...) @seq_engine_get_current_scene()
%8 = tail call i32 @song_set_pattern_type(i32 %7, i32 0, i32 %1)
%9 = tail call i32 (...) @seq_engine_get_current_scene()
%10 = tail call i32 @song_set_pattern_type(i32 %9, i32 1, i32 %1)
%11 = tail call i32 (...) @seq_engine_get_current_scene()
%12 = tail call i32 @song_set_pattern_type(i32 %11, i32 2, i32 %1)
%13 = tail call i32 (...) @seq_engine_get_current_scene()
%14 = tail call i32 @song_set_pattern_type(i32 %13, i32 3, i32 %1)
%15 = tail call i32 (...) @seq_engine_get_current_scene()
%16 = tail call i32 @song_set_pattern_type(i32 %15, i32 4, i32 %1)
%17 = tail call i32 (...) @seq_engine_get_current_scene()
%18 = tail call i32 @song_set_pattern_type(i32 %17, i32 5, i32 %1)
br label %26
19: ; preds = %4
%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 ([26 x i8], [26 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_pattern_type(i32 %24, i32 %0, i32 %1)
br label %26
26: ; preds = %6, %23, %2, %21
ret void
}