#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 atoi(char *);
int /*<<< orphan*/ zwave_sendClassCommand(unsigned int, int, int,
                                          unsigned char *, int);
void zwavecmd_configuration_bulk_set(unsigned int id, unsigned int offset,
                                     char *argv[]) {
  unsigned char buf[255];
  int ptr;
  int v;
  buf[0] = offset / 256;
  buf[1] = offset % 256;
  buf[2] = 0;
  buf[3] = 4;
  ptr = 3;
  while (*argv) {
    v = atoi(*argv);
    argv++;
    buf[ptr + 1] = (v >> 24) & 0xff;
    buf[ptr + 2] = (v >> 16) & 0xff;
    buf[ptr + 3] = (v >> 8) & 0xff;
    buf[ptr + 4] = v & 0xff;
    ptr += 4;
    buf[2]++;
  }
  zwave_sendClassCommand(id, 0x70, 0x07, buf, ptr + 1);
}


x86 assembly (clang, -O0):
<zwavecmd_configuration_bulk_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %al,-0x110(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x10f(%rbp)
movb   $0x0,-0x10e(%rbp)
movb   $0x4,-0x10d(%rbp)
movl   $0x3,-0x114(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     123a <zwavecmd_configuration_bulk_set+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x118(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x118(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
add    $0x4,%eax
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x114(%rbp)
mov    -0x10e(%rbp),%al
add    $0x1,%al
mov    %al,-0x10e(%rbp)
jmp    1167 <zwavecmd_configuration_bulk_set+0x47>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rcx
mov    -0x114(%rbp),%r8d
add    $0x1,%r8d
mov    $0x70,%esi
mov    $0x7,%edx
call   1030 <zwave_sendClassCommand@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zwavecmd_configuration_bulk_set>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%eax
mov    %edi,%r14d
mov    %ah,(%rsp)
mov    %al,0x1(%rsp)
movw   $0x400,0x2(%rsp)
mov    (%rdx),%rdi
test   %rdi,%rdi
je     116f <zwavecmd_configuration_bulk_set+0x4f>
mov    %rdx,%rbp
mov    $0x4,%ebx
xchg   %ax,%ax
call   1040 <atoi@plt>
bswap  %eax
mov    %eax,(%rsp,%rbx,1)
addb   $0x1,0x2(%rsp)
mov    0x0(%rbp,%rbx,2),%rdi
add    $0x4,%rbx
test   %rdi,%rdi
jne    1150 <zwavecmd_configuration_bulk_set+0x30>
jmp    1174 <zwavecmd_configuration_bulk_set+0x54>
mov    $0x4,%ebx
mov    %rsp,%rcx
mov    %r14d,%edi
mov    $0x70,%esi
mov    $0x7,%edx
mov    %ebx,%r8d
call   1030 <zwave_sendClassCommand@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @zwavecmd_configuration_bulk_set(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca [255 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%10 = load i32, i32* %5
%11 = udiv i32 %10, 256
%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 = load i32, i32* %5
%15 = urem i32 %14, 256
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 1
store i8 %16, i8* %17
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 2
store i8 0, i8* %18
%19 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 3
store i8 4, i8* %19
store i32 3, i32* %8
br label %20
20: ; preds = %24, %3
%21 = load i8**, i8*** %6
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %66
24: ; preds = %20
%25 = load i8**, i8*** %6
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %9
%28 = load i8**, i8*** %6
%29 = getelementptr inbounds i8*, i8** %28, i32 1
store i8** %29, i8*** %6
%30 = load i32, i32* %9
%31 = ashr i32 %30, 24
%32 = and i32 %31, 255
%33 = trunc i32 %32 to i8
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %36
store i8 %33, i8* %37
%38 = load i32, i32* %9
%39 = ashr i32 %38, 16
%40 = and i32 %39, 255
%41 = trunc i32 %40 to i8
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %44
store i8 %41, i8* %45
%46 = load i32, i32* %9
%47 = ashr i32 %46, 8
%48 = and i32 %47, 255
%49 = trunc i32 %48 to i8
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %52
store i8 %49, i8* %53
%54 = load i32, i32* %9
%55 = and i32 %54, 255
%56 = trunc i32 %55 to i8
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %59
store i8 %56, i8* %60
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 4
store i32 %62, i32* %8
%63 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 2
%64 = load i8, i8* %63
%65 = add i8 %64, 1
store i8 %65, i8* %63
br label %20
66: ; preds = %20
%67 = load i32, i32* %4
%68 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
%71 = call i32 @zwave_sendClassCommand(i32 %67, i32 112, i32 7, i8* %68, i32 %70)
ret void
}

LLVM IR (-O2):
define void @zwavecmd_configuration_bulk_set(i32 %0, i32 %1, i8** nocapture %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = lshr i32 %1, 8
%7 = trunc i32 %6 to i8
store i8 %7, i8* %5
%8 = trunc i32 %1 to i8
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 1
store i8 %8, i8* %9
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 2
store i8 0, i8* %10
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 3
store i8 4, i8* %11
%12 = load i8*, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %42, label %14
14: ; preds = %3, %14
%15 = phi i64 [ %33, %14 ], [ 3, %3 ]
%16 = phi i8* [ %37, %14 ], [ %12, %3 ]
%17 = phi i8** [ %19, %14 ], [ %2, %3 ]
%18 = tail call i32 @atoi(i8* %16)
%19 = getelementptr inbounds i8*, i8** %17, i64 1
%20 = lshr i32 %18, 24
%21 = trunc i32 %20 to i8
%22 = add nuw nsw i64 %15, 1
%23 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %22
store i8 %21, i8* %23
%24 = lshr i32 %18, 16
%25 = trunc i32 %24 to i8
%26 = add nuw nsw i64 %15, 2
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %26
store i8 %25, i8* %27
%28 = lshr i32 %18, 8
%29 = trunc i32 %28 to i8
%30 = add nuw nsw i64 %15, 3
%31 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %30
store i8 %29, i8* %31
%32 = trunc i32 %18 to i8
%33 = add nuw nsw i64 %15, 4
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %33
store i8 %32, i8* %34
%35 = load i8, i8* %10
%36 = add i8 %35, 1
store i8 %36, i8* %10
%37 = load i8*, i8** %19
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %14
39: ; preds = %14
%40 = trunc i64 %33 to i32
%41 = add i32 %40, 1
br label %42
42: ; preds = %39, %3
%43 = phi i32 [ 4, %3 ], [ %41, %39 ]
%44 = call i32 @zwave_sendClassCommand(i32 %0, i32 112, i32 7, i8* %5, i32 %43)
ret void
}