#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_association_set(unsigned int id, unsigned int group, char *ids) {
  unsigned char buf[255];
  int n, v;
  n = 1;
  v = 0;
  buf[0] = group;
  while (*ids) {
    if (*ids >= '0' && *ids <= '9') {
      v = v * 10 + (*ids - '0');
    } else {
      buf[n++] = v;
      v = 0;
    }
    ids++;
  }
  if (v)
    buf[n++] = v;
  zwave_sendClassCommand(id, 0x85, 0x1, buf, n);
}


x86 assembly (clang, -O0):
<zwavecmd_association_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x1,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,-0x110(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ca <zwavecmd_association_set+0xba>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     118d <zwavecmd_association_set+0x7d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     118d <zwavecmd_association_set+0x7d>
imul   $0xa,-0x118(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x118(%rbp)
jmp    11b9 <zwavecmd_association_set+0xa9>
mov    -0x118(%rbp),%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x114(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
movl   $0x0,-0x118(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1142 <zwavecmd_association_set+0x32>
cmpl   $0x0,-0x118(%rbp)
je     11f9 <zwavecmd_association_set+0xe9>
mov    -0x118(%rbp),%eax
mov    %al,%cl
mov    -0x114(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x114(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rcx
mov    -0x114(%rbp),%r8d
mov    $0x85,%esi
mov    $0x1,%edx
call   1030 <zwave_sendClassCommand@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zwavecmd_association_set>:
sub    $0x108,%rsp
mov    %sil,(%rsp)
mov    (%rdx),%cl
test   %cl,%cl
je     116e <zwavecmd_association_set+0x5e>
add    $0x1,%rdx
mov    $0x1,%r8d
xor    %eax,%eax
jmp    1147 <zwavecmd_association_set+0x37>
nop
movslq %r8d,%rcx
add    $0x1,%r8d
mov    %al,(%rsp,%rcx,1)
xor    %eax,%eax
movzbl (%rdx),%ecx
add    $0x1,%rdx
test   %cl,%cl
je     115e <zwavecmd_association_set+0x4e>
lea    -0x30(%rcx),%esi
cmp    $0x9,%sil
ja     1130 <zwavecmd_association_set+0x20>
movzbl %cl,%ecx
lea    (%rax,%rax,4),%eax
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
jmp    113c <zwavecmd_association_set+0x2c>
test   %eax,%eax
je     1174 <zwavecmd_association_set+0x64>
movslq %r8d,%rcx
add    $0x1,%r8d
mov    %al,(%rsp,%rcx,1)
jmp    1174 <zwavecmd_association_set+0x64>
mov    $0x1,%r8d
mov    %rsp,%rcx
mov    $0x85,%esi
mov    $0x1,%edx
call   1030 <zwave_sendClassCommand@plt>
add    $0x108,%rsp
ret

LLVM IR (-O0):
define void @zwavecmd_association_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
store i32 1, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %5
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
store i8 %11, i8* %12
br label %13
13: ; preds = %42, %3
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 48
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp sle i32 %25, 57
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = load i32, i32* %9
%29 = mul nsw i32 %28, 10
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 48
%34 = add nsw i32 %29, %33
store i32 %34, i32* %9
br label %42
35: ; preds = %22, %17
%36 = load i32, i32* %9
%37 = trunc i32 %36 to i8
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %40
store i8 %37, i8* %41
store i32 0, i32* %9
br label %42
42: ; preds = %35, %27
%43 = load i8*, i8** %6
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %6
br label %13
45: ; preds = %13
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i32, i32* %9
%50 = trunc i32 %49 to i8
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 %53
store i8 %50, i8* %54
br label %55
55: ; preds = %48, %45
%56 = load i32, i32* %4
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%58 = load i32, i32* %8
%59 = call i32 @zwave_sendClassCommand(i32 %56, i32 133, i32 1, i8* %57, i32 %58)
ret void
}

LLVM IR (-O2):
define void @zwavecmd_association_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 = trunc i32 %1 to i8
store i8 %6, i8* %5
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %39, label %9
9: ; preds = %3, %26
%10 = phi i8 [ %30, %26 ], [ %7, %3 ]
%11 = phi i32 [ %28, %26 ], [ 0, %3 ]
%12 = phi i32 [ %27, %26 ], [ 1, %3 ]
%13 = phi i8* [ %29, %26 ], [ %2, %3 ]
%14 = add i8 %10, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %16, label %21
16: ; preds = %9
%17 = zext i8 %10 to i32
%18 = mul nsw i32 %11, 10
%19 = add i32 %18, -48
%20 = add i32 %19, %17
br label %26
21: ; preds = %9
%22 = trunc i32 %11 to i8
%23 = add nsw i32 %12, 1
%24 = sext i32 %12 to i64
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %24
store i8 %22, i8* %25
br label %26
26: ; preds = %21, %16
%27 = phi i32 [ %12, %16 ], [ %23, %21 ]
%28 = phi i32 [ %20, %16 ], [ 0, %21 ]
%29 = getelementptr inbounds i8, i8* %13, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %9
32: ; preds = %26
%33 = icmp eq i32 %28, 0
br i1 %33, label %39, label %34
34: ; preds = %32
%35 = trunc i32 %28 to i8
%36 = add nsw i32 %27, 1
%37 = sext i32 %27 to i64
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %3, %34, %32
%40 = phi i32 [ %36, %34 ], [ %27, %32 ], [ 1, %3 ]
%41 = call i32 @zwave_sendClassCommand(i32 %0, i32 133, i32 1, i8* %5, i32 %40)
ret void
}