#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*/ panel_set_led(int, int);
int /*<<< orphan*/ seq_ctrl_get_first_track();
int /*<<< orphan*/ seq_ctrl_get_scene();
int song_get_motion_dir(int /*<<< orphan*/, int /*<<< orphan*/);
void panel_update_dir_led(void) {
  static int state = 0;
  int newstate =
      song_get_motion_dir(seq_ctrl_get_scene(), seq_ctrl_get_first_track());
  if (newstate != state) {
    if (newstate) {
      panel_set_led(9, 2);
    } else {
      panel_set_led(9, 0);
    }
    state = newstate;
  }
}


x86 assembly (clang, -O0):
<panel_update_dir_led>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <seq_ctrl_get_scene@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <seq_ctrl_get_first_track@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%esi
call   1030 <song_get_motion_dir@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    0x2ed5(%rip),%eax
je     11a8 <panel_update_dir_led+0x68>
cmpl   $0x0,-0x4(%rbp)
je     1193 <panel_update_dir_led+0x53>
mov    $0x9,%edi
mov    $0x2,%esi
call   1050 <panel_set_led@plt>
jmp    119f <panel_update_dir_led+0x5f>
mov    $0x9,%edi
xor    %esi,%esi
call   1050 <panel_set_led@plt>
mov    -0x4(%rbp),%eax
mov    %eax,0x2e9c(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<panel_update_dir_led>:
push   %rbx
xor    %eax,%eax
call   1040 <seq_ctrl_get_scene@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <seq_ctrl_get_first_track@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <song_get_motion_dir@plt>
cmp    0x2ee4(%rip),%eax
je     117e <panel_update_dir_led+0x3e>
mov    %eax,%ebx
xor    %esi,%esi
test   %eax,%eax
setne  %sil
add    %esi,%esi
mov    $0x9,%edi
call   1050 <panel_set_led@plt>
mov    %ebx,0x2ec6(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@panel_update_dir_led.state = internal global i32 0
define void @panel_update_dir_led() {
%1 = alloca i32
%2 = call i32 (...) @seq_ctrl_get_scene()
%3 = call i32 (...) @seq_ctrl_get_first_track()
%4 = call i32 @song_get_motion_dir(i32 %2, i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = load i32, i32* @panel_update_dir_led.state
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %17
8: ; preds = %0
%9 = load i32, i32* %1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @panel_set_led(i32 9, i32 2)
br label %15
13: ; preds = %8
%14 = call i32 @panel_set_led(i32 9, i32 0)
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %1
store i32 %16, i32* @panel_update_dir_led.state
br label %17
17: ; preds = %15, %0
ret void
}

LLVM IR (-O2):
@panel_update_dir_led.state = internal unnamed_addr global i32 0
define void @panel_update_dir_led() {
%1 = tail call i32 (...) @seq_ctrl_get_scene()
%2 = tail call i32 (...) @seq_ctrl_get_first_track()
%3 = tail call i32 @song_get_motion_dir(i32 %1, i32 %2)
%4 = load i32, i32* @panel_update_dir_led.state
%5 = icmp eq i32 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = icmp eq i32 %3, 0
%8 = select i1 %7, i32 0, i32 2
%9 = tail call i32 @panel_set_led(i32 9, i32 %8)
store i32 %3, i32* @panel_update_dir_led.state
br label %10
10: ; preds = %6, %0
ret void
}