#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*/ printf(char *, unsigned int, int);
int /*<<< orphan*/ zwave_sendClassCommand(unsigned int, int, int,
                                          unsigned char *, unsigned char);
void zwavecmd_configuration_set4(unsigned int id, unsigned int no, int v) {
  unsigned char buf[255];
  printf("Set parameter %d to be %d\n", no, v);
  buf[0] = no;
  buf[1] = 4;
  buf[2] = v / (1 << 24);
  buf[3] = (v >> 16) & 0xff;
  buf[4] = (v >> 8) & 0xff;
  buf[5] = v & 0xff;
  zwave_sendClassCommand(id, 0x70, 0x04, buf, buf[1] + 2);
}


x86 assembly (clang, -O0):
<zwavecmd_configuration_set4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %al,-0x110(%rbp)
movb   $0x4,-0x10f(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x1000000,%ecx
cltd
idiv   %ecx
mov    %al,-0x10e(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,-0x10d(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x10c(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x10b(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rcx
movzbl -0x10f(%rbp),%eax
add    $0x2,%eax
mov    $0x70,%esi
mov    $0x4,%edx
movzbl %al,%r8d
call   1040 <zwave_sendClassCommand@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zwavecmd_configuration_set4>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    %bpl,(%rsp)
movb   $0x4,0x1(%rsp)
lea    0xffffff(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
shr    $0x18,%eax
mov    %al,0x2(%rsp)
mov    %ebx,%eax
shr    $0x10,%eax
mov    %al,0x3(%rsp)
mov    %bh,0x4(%rsp)
mov    %bl,0x5(%rsp)
mov    %rsp,%rcx
mov    %r14d,%edi
mov    $0x70,%esi
mov    $0x4,%edx
mov    $0x6,%r8d
call   1040 <zwave_sendClassCommand@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Set parameter %d to be %d\0A\00"
define void @zwavecmd_configuration_set4(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [255 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %5
%12 = trunc i32 %11 to i8
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
store i8 %12, i8* %13
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 1
store i8 4, i8* %14
%15 = load i32, i32* %6
%16 = sdiv i32 %15, 16777216
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 2
store i8 %17, i8* %18
%19 = load i32, i32* %6
%20 = ashr i32 %19, 16
%21 = and i32 %20, 255
%22 = trunc i32 %21 to i8
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 3
store i8 %22, i8* %23
%24 = load i32, i32* %6
%25 = ashr i32 %24, 8
%26 = and i32 %25, 255
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 4
store i8 %27, i8* %28
%29 = load i32, i32* %6
%30 = and i32 %29, 255
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 5
store i8 %31, i8* %32
%33 = load i32, i32* %4
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%35 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 1
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = add nsw i32 %37, 2
%39 = trunc i32 %38 to i8
%40 = call i32 @zwave_sendClassCommand(i32 %33, i32 112, i32 4, i8* %34, i8 zeroext %39)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Set parameter %d to be %d\0A\00"
define void @zwavecmd_configuration_set4(i32 %0, i32 %1, i32 %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%7 = trunc i32 %1 to i8
store i8 %7, i8* %5
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 1
store i8 4, i8* %8
%9 = sdiv i32 %2, 16777216
%10 = trunc i32 %9 to i8
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 2
store i8 %10, i8* %11
%12 = lshr i32 %2, 16
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 3
store i8 %13, i8* %14
%15 = lshr i32 %2, 8
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 4
store i8 %16, i8* %17
%18 = trunc i32 %2 to i8
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 5
store i8 %18, i8* %19
%20 = call i32 @zwave_sendClassCommand(i32 %0, i32 112, i32 4, i8* %5, i8 zeroext 6)
ret void
}