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


x86 assembly (clang, -O0):
<panel_update_arp_led>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <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   1050 <song_get_arp_enable@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    0x2ed5(%rip),%eax
je     11a2 <panel_update_arp_led+0x62>
cmpl   $0x0,-0x4(%rbp)
je     1190 <panel_update_arp_led+0x50>
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <panel_set_led@plt>
jmp    1199 <panel_update_arp_led+0x59>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <panel_set_led@plt>
mov    -0x4(%rbp),%eax
mov    %eax,0x2ea2(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<panel_update_arp_led>:
push   %rbx
xor    %eax,%eax
call   1030 <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   1050 <song_get_arp_enable@plt>
cmp    0x2ee4(%rip),%eax
je     117b <panel_update_arp_led+0x3b>
mov    %eax,%ebx
xor    %esi,%esi
test   %eax,%eax
setne  %sil
add    %esi,%esi
xor    %edi,%edi
call   1040 <panel_set_led@plt>
mov    %ebx,0x2ec9(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@panel_update_arp_led.state = internal global i32 0
define void @panel_update_arp_led() {
%1 = alloca i32
%2 = call i32 (...) @seq_ctrl_get_scene()
%3 = call i32 (...) @seq_ctrl_get_first_track()
%4 = call i32 @song_get_arp_enable(i32 %2, i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = load i32, i32* @panel_update_arp_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 0, i32 2)
br label %15
13: ; preds = %8
%14 = call i32 @panel_set_led(i32 0, i32 0)
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %1
store i32 %16, i32* @panel_update_arp_led.state
br label %17
17: ; preds = %15, %0
ret void
}

LLVM IR (-O2):
@panel_update_arp_led.state = internal unnamed_addr global i32 0
define void @panel_update_arp_led() {
%1 = tail call i32 (...) @seq_ctrl_get_scene()
%2 = tail call i32 (...) @seq_ctrl_get_first_track()
%3 = tail call i32 @song_get_arp_enable(i32 %1, i32 %2)
%4 = load i32, i32* @panel_update_arp_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 0, i32 %8)
store i32 %3, i32* @panel_update_arp_led.state
br label %10
10: ; preds = %6, %0
ret void
}