#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 *, ...);
int /*<<< orphan*/ register_class_callback(int, void (*)(void *, void *, int),
                                           void *);
int /*<<< orphan*/ zwave_sendClassCommand(int, int, int, unsigned char *, int);
void zwavecmd_configuration_dump_next(void *data, void *payload, int len) {
  unsigned char buf[255];
  int *par = (int *)data;
  unsigned char *pp = (unsigned char *)payload;
  if (pp[0] == 0x06) {
    if (par[1] == par[2])
      return;
    par[2]++;
    buf[0] = par[2];
    zwave_sendClassCommand(par[0], 0x70, 0x05, buf, 1);
    register_class_callback(0x70, zwavecmd_configuration_dump_next, data);
  } else if (pp[0] == 0x09) {
    int offset = pp[1] * 256 + pp[2];
    int n = pp[3];
    int i;
    int size;
    if (pp[4] != 0) {
      register_class_callback(0x70, zwavecmd_configuration_dump_next, data);
    }
    size = pp[5] & 7;
    printf("[%d] ", offset);
    for (i = 0; i < n * size; i++) {
      printf("%02x ", pp[6 + i]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<zwavecmd_configuration_dump_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x6,%eax
jne    11ed <zwavecmd_configuration_dump_next+0xbd>
mov    -0x128(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x128(%rbp),%rcx
cmp    0x8(%rcx),%eax
jne    118e <zwavecmd_configuration_dump_next+0x5e>
jmp    12f4 <zwavecmd_configuration_dump_next+0x1c4>
mov    -0x128(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x8(%rax)
mov    -0x128(%rbp),%rax
mov    0x8(%rax),%eax
mov    %al,-0x120(%rbp)
mov    -0x128(%rbp),%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rcx
mov    $0x70,%esi
mov    $0x5,%edx
mov    $0x1,%r8d
call   1050 <zwave_sendClassCommand@plt>
mov    -0x8(%rbp),%rdx
mov    $0x70,%edi
mov    0x2e0d(%rip),%rsi
call   1030 <register_class_callback@plt>
jmp    12f4 <zwavecmd_configuration_dump_next+0x1c4>
mov    -0x130(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x9,%eax
jne    12ef <zwavecmd_configuration_dump_next+0x1bf>
mov    -0x130(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x8,%eax
mov    -0x130(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x134(%rbp)
mov    -0x130(%rbp),%rax
movzbl 0x3(%rax),%eax
mov    %eax,-0x138(%rbp)
mov    -0x130(%rbp),%rax
movzbl 0x4(%rax),%eax
cmp    $0x0,%eax
je     125b <zwavecmd_configuration_dump_next+0x12b>
mov    -0x8(%rbp),%rdx
mov    $0x70,%edi
mov    0x2d9a(%rip),%rsi
call   1030 <register_class_callback@plt>
mov    -0x130(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0x7,%eax
mov    %eax,-0x140(%rbp)
mov    -0x134(%rbp),%esi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x13c(%rbp)
mov    -0x13c(%rbp),%eax
mov    -0x138(%rbp),%ecx
imul   -0x140(%rbp),%ecx
cmp    %ecx,%eax
jge    12e1 <zwavecmd_configuration_dump_next+0x1b1>
mov    -0x130(%rbp),%rax
mov    -0x13c(%rbp),%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    128d <zwavecmd_configuration_dump_next+0x15d>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f4 <zwavecmd_configuration_dump_next+0x1c4>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zwavecmd_configuration_dump_next>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
mov    (%rsi),%al
cmp    $0x9,%al
je     11b3 <zwavecmd_configuration_dump_next+0x73>
cmp    $0x6,%al
jne    11a1 <zwavecmd_configuration_dump_next+0x61>
mov    0x8(%r14),%eax
cmp    %eax,0x4(%r14)
je     11a1 <zwavecmd_configuration_dump_next+0x61>
add    $0x1,%eax
mov    %eax,0x8(%r14)
mov    %al,(%rsp)
mov    (%r14),%edi
mov    %rsp,%rcx
mov    $0x70,%esi
mov    $0x5,%edx
mov    $0x1,%r8d
call   1060 <zwave_sendClassCommand@plt>
mov    0x2e5c(%rip),%rsi
mov    $0x70,%edi
mov    %r14,%rdx
call   1040 <register_class_callback@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r13
movzwl 0x1(%rsi),%r15d
shl    $0x10,%r15d
bswap  %r15d
movzbl 0x3(%rsi),%r12d
cmpb   $0x0,0x4(%rsi)
je     11e1 <zwavecmd_configuration_dump_next+0xa1>
mov    0x2e1c(%rip),%rsi
mov    $0x70,%edi
mov    %r14,%rdx
call   1040 <register_class_callback@plt>
movzbl 0x5(%r13),%ebp
and    $0x7,%ebp
imul   %r12,%rbp
lea    0xe0c(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbp,%rbp
je     1229 <zwavecmd_configuration_dump_next+0xe9>
lea    0xdfc(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl 0x6(%r13,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1210 <zwavecmd_configuration_dump_next+0xd0>
mov    $0xa,%edi
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"[%d] \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @zwavecmd_configuration_dump_next(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to i32*
store i32* %15, i32** %8
%16 = load i8*, i8** %5
store i8* %16, i8** %9
%17 = load i8*, i8** %9
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = icmp eq i32 %20, 6
br i1 %21, label %22, label %48
22: ; preds = %3
%23 = load i32*, i32** %8
%24 = getelementptr inbounds i32, i32* %23, i64 1
%25 = load i32, i32* %24
%26 = load i32*, i32** %8
%27 = getelementptr inbounds i32, i32* %26, i64 2
%28 = load i32, i32* %27
%29 = icmp eq i32 %25, %28
br i1 %29, label %30, label %31
30: ; preds = %22
br label %106
31: ; preds = %22
%32 = load i32*, i32** %8
%33 = getelementptr inbounds i32, i32* %32, i64 2
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
%36 = load i32*, i32** %8
%37 = getelementptr inbounds i32, i32* %36, i64 2
%38 = load i32, i32* %37
%39 = trunc i32 %38 to i8
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
store i8 %39, i8* %40
%41 = load i32*, i32** %8
%42 = getelementptr inbounds i32, i32* %41, i64 0
%43 = load i32, i32* %42
%44 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%45 = call i32 @zwave_sendClassCommand(i32 %43, i32 112, i32 5, i8* %44, i32 1)
%46 = load i8*, i8** %4
%47 = call i32 @register_class_callback(i32 112, void (i8*, i8*, i32)* @zwavecmd_configuration_dump_next, i8* %46)
br label %106
48: ; preds = %3
%49 = load i8*, i8** %9
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = icmp eq i32 %52, 9
br i1 %53, label %54, label %105
54: ; preds = %48
%55 = load i8*, i8** %9
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = mul nsw i32 %58, 256
%60 = load i8*, i8** %9
%61 = getelementptr inbounds i8, i8* %60, i64 2
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = add nsw i32 %59, %63
store i32 %64, i32* %10
%65 = load i8*, i8** %9
%66 = getelementptr inbounds i8, i8* %65, i64 3
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
store i32 %68, i32* %11
%69 = load i8*, i8** %9
%70 = getelementptr inbounds i8, i8* %69, i64 4
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %54
%75 = load i8*, i8** %4
%76 = call i32 @register_class_callback(i32 112, void (i8*, i8*, i32)* @zwavecmd_configuration_dump_next, i8* %75)
br label %77
77: ; preds = %74, %54
%78 = load i8*, i8** %9
%79 = getelementptr inbounds i8, i8* %78, i64 5
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = and i32 %81, 7
store i32 %82, i32* %13
%83 = load i32, i32* %10
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %83)
store i32 0, i32* %12
br label %85
85: ; preds = %100, %77
%86 = load i32, i32* %12
%87 = load i32, i32* %11
%88 = load i32, i32* %13
%89 = mul nsw i32 %87, %88
%90 = icmp slt i32 %86, %89
br i1 %90, label %91, label %103
91: ; preds = %85
%92 = load i8*, i8** %9
%93 = load i32, i32* %12
%94 = add nsw i32 6, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %92, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %91
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %85
103: ; preds = %85
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %105
105: ; preds = %103, %48
br label %106
106: ; preds = %30, %105, %31
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"[%d] \00"
@.str.1 = [6 x i8] c"%02x \00"
define void @zwavecmd_configuration_dump_next(i8* %0, i8* nocapture %1, i32 %2) {
%4 = alloca [255 x i8]
%5 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%6 = bitcast i8* %0 to i32*
%7 = load i8, i8* %1
switch i8 %7, label %60 [
i8 6, label %8
i8 9, label %22
]
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %0, i64 4
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = getelementptr inbounds i8, i8* %0, i64 8
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
%15 = icmp eq i32 %11, %14
br i1 %15, label %60, label %16
16: ; preds = %8
%17 = add nsw i32 %14, 1
store i32 %17, i32* %13
%18 = trunc i32 %17 to i8
store i8 %18, i8* %5
%19 = load i32, i32* %6
%20 = call i32 @zwave_sendClassCommand(i32 %19, i32 112, i32 5, i8* %5, i32 1)
%21 = call i32 @register_class_callback(i32 112, void (i8*, i8*, i32)* @zwavecmd_configuration_dump_next, i8* %0)
br label %60
22: ; preds = %3
%23 = getelementptr inbounds i8, i8* %1, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = shl nuw nsw i32 %25, 8
%27 = getelementptr inbounds i8, i8* %1, i64 2
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %26, %29
%31 = getelementptr inbounds i8, i8* %1, i64 3
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = getelementptr inbounds i8, i8* %1, i64 4
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %22
%38 = tail call i32 @register_class_callback(i32 112, void (i8*, i8*, i32)* @zwavecmd_configuration_dump_next, i8* %0)
br label %39
39: ; preds = %37, %22
%40 = getelementptr inbounds i8, i8* %1, i64 5
%41 = load i8, i8* %40
%42 = and i8 %41, 7
%43 = zext i8 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %30)
%45 = mul nuw nsw i32 %43, %33
%46 = icmp eq i32 %45, 0
br i1 %46, label %58, label %47
47: ; preds = %39
%48 = zext i32 %45 to i64
br label %49
49: ; preds = %47, %49
%50 = phi i64 [ 0, %47 ], [ %56, %49 ]
%51 = add nuw nsw i64 %50, 6
%52 = getelementptr inbounds i8, i8* %1, i64 %51
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i64 %50, 1
%57 = icmp eq i64 %56, %48
br i1 %57, label %58, label %49
58: ; preds = %49, %39
%59 = tail call i32 @putchar(i32 10)
br label %60
60: ; preds = %16, %58, %3, %8
ret void
}