#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*/ zwave_sendClassCommand(unsigned int, int, int,
                                          unsigned char *, int);
void zwavecmd_actuator_set(unsigned int id, unsigned int scene, int level,
                           int duration) {
  unsigned char buf[255];
  buf[0] = scene;
  buf[1] = duration;
  if (level == -1) {
    buf[2] = 0;
    buf[3] = 0;
  } else {
    buf[2] = 0x80;
    buf[3] = level;
  }
  zwave_sendClassCommand(id, 0x2C, 0x01, buf, 4);
}


x86 assembly (clang, -O0):
<zwavecmd_actuator_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0x110(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,-0x10f(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1156 <zwavecmd_actuator_set+0x46>
movb   $0x0,-0x10e(%rbp)
movb   $0x0,-0x10d(%rbp)
jmp    1166 <zwavecmd_actuator_set+0x56>
movb   $0x80,-0x10e(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0x10d(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rcx
mov    $0x2c,%esi
mov    $0x1,%edx
mov    $0x4,%r8d
call   1030 <zwave_sendClassCommand@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zwavecmd_actuator_set>:
sub    $0x108,%rsp
xor    %r8d,%r8d
cmp    $0xffffffff,%edx
setne  %al
mov    %sil,(%rsp)
cmovne %edx,%r8d
mov    %cl,0x1(%rsp)
shl    $0x7,%al
mov    %al,0x2(%rsp)
mov    %r8b,0x3(%rsp)
mov    %rsp,%rcx
mov    $0x2c,%esi
mov    $0x1,%edx
mov    $0x4,%r8d
call   1030 <zwave_sendClassCommand@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
define void @zwavecmd_actuator_set(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [255 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i32, i32* %8
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 1
store i8 %14, i8* %15
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 2
store i8 0, i8* %19
%20 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 3
store i8 0, i8* %20
br label %26
21: ; preds = %4
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 2
store i8 -128, i8* %22
%23 = load i32, i32* %7
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 3
store i8 %24, i8* %25
br label %26
26: ; preds = %21, %18
%27 = load i32, i32* %5
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%29 = call i32 @zwave_sendClassCommand(i32 %27, i32 44, i32 1, i8* %28, i32 4)
ret void
}

LLVM IR (-O2):
define void @zwavecmd_actuator_set(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%7 = trunc i32 %1 to i8
store i8 %7, i8* %6
%8 = trunc i32 %3 to i8
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 1
store i8 %8, i8* %9
%10 = icmp eq i32 %2, -1
%11 = trunc i32 %2 to i8
%12 = select i1 %10, i8 0, i8 -128
%13 = select i1 %10, i8 0, i8 %11
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 2
store i8 %12, i8* %14
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 3
store i8 %13, i8* %15
%16 = call i32 @zwave_sendClassCommand(i32 %0, i32 44, i32 1, i8* %6, i32 4)
ret void
}