#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_ctrl_set_run_lockout(int /*<<< orphan*/);
int /*<<< orphan*/ seq_ctrl_set_run_state(int /*<<< orphan*/);
int /*<<< orphan*/ song_save(int);
int seq_ctrl_save_song(int song) {
  if (song < 0 || song >= 64) {
    log_error("scss - song invalid: %d", song);
    return -1;
  }
  seq_ctrl_set_record_mode(0);
  seq_ctrl_set_run_lockout(0);
  seq_ctrl_set_run_state(0);
  song_save(song);
  return 0;
}


x86 assembly (clang, -O0):
<seq_ctrl_save_song>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     116f <seq_ctrl_save_song+0x1f>
cmpl   $0x40,-0x8(%rbp)
jl     118a <seq_ctrl_save_song+0x3a>
mov    -0x8(%rbp),%esi
lea    0xe87(%rip),%rdi
call   1030 <log_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <seq_ctrl_save_song+0x5e>
xor    %edi,%edi
call   1040 <seq_ctrl_set_record_mode@plt>
xor    %edi,%edi
call   1050 <seq_ctrl_set_run_lockout@plt>
xor    %edi,%edi
call   1070 <seq_ctrl_set_run_state@plt>
mov    -0x8(%rbp),%edi
call   1060 <song_save@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_ctrl_save_song>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x40,%edi
jb     116f <seq_ctrl_save_song+0x1f>
lea    0xe9f(%rip),%rdi
mov    %ebx,%esi
call   1030 <log_error@plt>
mov    $0xffffffff,%ebp
jmp    118d <seq_ctrl_save_song+0x3d>
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <seq_ctrl_set_record_mode@plt>
xor    %edi,%edi
call   1050 <seq_ctrl_set_run_lockout@plt>
xor    %edi,%edi
call   1070 <seq_ctrl_set_run_state@plt>
mov    %ebx,%edi
call   1060 <song_save@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"scss - song invalid: %d\00"
define i32 @seq_ctrl_save_song(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 64
br i1 %8, label %9, label %12
9: ; preds = %6, %1
%10 = load i32, i32* %3
%11 = call i32 @log_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 -1, i32* %2
br label %18
12: ; preds = %6
%13 = call i32 @seq_ctrl_set_record_mode(i32 0)
%14 = call i32 @seq_ctrl_set_run_lockout(i32 0)
%15 = call i32 @seq_ctrl_set_run_state(i32 0)
%16 = load i32, i32* %3
%17 = call i32 @song_save(i32 %16)
store i32 0, i32* %2
br label %18
18: ; preds = %12, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [24 x i8] c"scss - song invalid: %d\00"
define i32 @seq_ctrl_save_song(i32 %0) {
%2 = icmp ugt i32 %0, 63
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @log_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %10
5: ; preds = %1
%6 = tail call i32 @seq_ctrl_set_record_mode(i32 0)
%7 = tail call i32 @seq_ctrl_set_run_lockout(i32 0)
%8 = tail call i32 @seq_ctrl_set_run_state(i32 0)
%9 = tail call i32 @song_save(i32 %0)
br label %10
10: ; preds = %5, %3
%11 = phi i32 [ -1, %3 ], [ 0, %5 ]
ret i32 %11
}