#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 */
typedef int /*<<< orphan*/ path;
typedef int __u16;
typedef scalar_t__ __s32;

/* Variables and functions */
int /*<<< orphan*/ mp_dbus_send_signal(char *, char *, char *, char *,
                                       scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void handle_switch(__u16 code, __s32 value) {
  char *codename;
  switch (code) {
  default:
    codename = "unknown";
    break;
  }
  char *state = value ? "inserted" : "removed";
  char path[50];
  snprintf(path, sizeof(path), "/jack/%s", codename);
  mp_dbus_send_signal(path, "org.ude.jacklistener", state, NULL, 0);
  mp_dbus_send_signal("/state", "org.ude.jacklistener", "statechanged",
                      codename, value);
}


x86 assembly (clang, -O0):
<handle_switch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xecc(%rip),%rax
lea    0xebc(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x32,%esi
lea    0xead(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xea2(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1040 <mp_dbus_send_signal@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe9b(%rip),%rdi
lea    0xe7f(%rip),%rsi
lea    0xe94(%rip),%rdx
call   1040 <mp_dbus_send_signal@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_switch>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
test   %rsi,%rsi
lea    0xed7(%rip),%rax
lea    0xec7(%rip),%rbx
cmove  %rax,%rbx
lea    0xecd(%rip),%rdx
lea    0xead(%rip),%r15
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x32,%esi
mov    %r15,%rcx
call   1030 <snprintf@plt>
lea    0xeb5(%rip),%r13
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <mp_dbus_send_signal@plt>
lea    0xeb0(%rip),%rdi
lea    0xeb0(%rip),%rdx
mov    %r13,%rsi
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <mp_dbus_send_signal@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"unknown\00"
@.str.1 = [9 x i8] c"inserted\00"
@.str.2 = [8 x i8] c"removed\00"
@.str.3 = [9 x i8] c"/jack/%s\00"
@.str.4 = [21 x i8] c"org.ude.jacklistener\00"
@.str.5 = [7 x i8] c"/state\00"
@.str.6 = [13 x i8] c"statechanged\00"
define void @handle_switch(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [50 x i8]
store i32 %0, i32* %3
store i64 %1, i64* %4
%8 = load i32, i32* %3
switch i32 %8, label %9 [
]
9: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
br label %10
10: ; preds = %9
%11 = load i64, i64* %4
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
store i8* %14, i8** %6
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i32 @snprintf(i8* %15, i32 50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%19 = load i8*, i8** %6
%20 = call i32 @mp_dbus_send_signal(i8* %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %19, i8* null, i64 0)
%21 = load i8*, i8** %5
%22 = load i64, i64* %4
%23 = call i32 @mp_dbus_send_signal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %21, i64 %22)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"unknown\00"
@.str.1 = [9 x i8] c"inserted\00"
@.str.2 = [8 x i8] c"removed\00"
@.str.3 = [9 x i8] c"/jack/%s\00"
@.str.4 = [21 x i8] c"org.ude.jacklistener\00"
@.str.5 = [7 x i8] c"/state\00"
@.str.6 = [13 x i8] c"statechanged\00"
define void @handle_switch(i32 %0, i64 %1) {
%3 = alloca [50 x i8]
%4 = icmp eq i64 %1, 0
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @mp_dbus_send_signal(i8* %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* null, i64 0)
%9 = call i32 @mp_dbus_send_signal(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %1)
ret void
}