#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 *, ...);
void multi_channel_capability_get_dump(void *data, void *payload, int len) {
  unsigned char *pp = (unsigned char *)payload;
  int i;
  if (pp[0] != 0xA) {
    printf("Impossible command %x\n", pp[0]);
    return;
  }
  if (pp[1] & 0x80) {
    printf("The number of channnels are dynamic\n");
  } else {
    printf("The number of channnels are fixed\n");
  }
  printf("end point %d\n", pp[1] & 0x7f);
  printf("generic type is %x\n", pp[2]);
  printf("specific type is %x\n", pp[3]);
  printf("Supported command classes:\n");
  for (i = 4; i < len - 1; i++) {
    printf("\t%x\n", pp[i]);
  }
}


x86 assembly (clang, -O0):
<multi_channel_capability_get_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
je     1155 <multi_channel_capability_get_dump+0x45>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <multi_channel_capability_get_dump+0x10f>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     117e <multi_channel_capability_get_dump+0x6e>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118c <multi_channel_capability_get_dump+0x7c>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%esi
and    $0x7f,%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121f <multi_channel_capability_get_dump+0x10f>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e6 <multi_channel_capability_get_dump+0xd6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_channel_capability_get_dump>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
movzbl (%rsi),%esi
cmp    $0xa,%esi
jne    11e4 <multi_channel_capability_get_dump+0xc4>
mov    %edx,%r14d
cmpb   $0x0,0x1(%r12)
lea    0xf0c(%rip),%rax
lea    0xf42(%rip),%rdi
cmovns %rax,%rdi
call   1030 <puts@plt>
movzbl 0x1(%r12),%esi
and    $0x7f,%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%r12),%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%r12),%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x6,%r14d
jl     11d8 <multi_channel_capability_get_dump+0xb8>
add    $0xffffffff,%r14d
mov    $0x4,%ebx
lea    0xe96(%rip),%r15
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11c0 <multi_channel_capability_get_dump+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe15(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Impossible command %x\0A\00"
@.str.1 = [37 x i8] c"The number of channnels are dynamic\0A\00"
@.str.2 = [35 x i8] c"The number of channnels are fixed\0A\00"
@.str.3 = [14 x i8] c"end point %d\0A\00"
@.str.4 = [20 x i8] c"generic type is %x\0A\00"
@.str.5 = [21 x i8] c"specific type is %x\0A\00"
@.str.6 = [28 x i8] c"Supported command classes:\0A\00"
@.str.7 = [5 x i8] c"\09%x\0A\00"
define void @multi_channel_capability_get_dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %21
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %66
21: ; preds = %3
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = and i32 %25, 128
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %32
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = and i32 %36, 127
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 3
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store i32 4, i32* %8
br label %50
50: ; preds = %63, %32
%51 = load i32, i32* %8
%52 = load i32, i32* %6
%53 = sub nsw i32 %52, 1
%54 = icmp slt i32 %51, %53
br i1 %54, label %55, label %66
55: ; preds = %50
%56 = load i8*, i8** %7
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %55
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %50
66: ; preds = %15, %50
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Impossible command %x\0A\00"
@.str.3 = [14 x i8] c"end point %d\0A\00"
@.str.4 = [20 x i8] c"generic type is %x\0A\00"
@.str.5 = [21 x i8] c"specific type is %x\0A\00"
@.str.7 = [5 x i8] c"\09%x\0A\00"
@str = [34 x i8] c"The number of channnels are fixed\00"
@str.8 = [27 x i8] c"Supported command classes:\00"
@str.9 = [36 x i8] c"The number of channnels are dynamic\00"
define void @multi_channel_capability_get_dump(i8* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 10
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = zext i8 %4 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %40
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %1, i64 1
%11 = load i8, i8* %10
%12 = icmp sgt i8 %11, -1
%13 = select i1 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = load i8, i8* %10
%16 = and i8 %15, 127
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i8, i8* %1, i64 2
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i8, i8* %1, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0))
%28 = icmp sgt i32 %2, 5
br i1 %28, label %29, label %40
29: ; preds = %9
%30 = add nsw i32 %2, -1
%31 = zext i32 %30 to i64
br label %32
32: ; preds = %29, %32
%33 = phi i64 [ 4, %29 ], [ %38, %32 ]
%34 = getelementptr inbounds i8, i8* %1, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %33, 1
%39 = icmp eq i64 %38, %31
br i1 %39, label %40, label %32
40: ; preds = %32, %9, %6
ret void
}