#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_get_dump(void *data, void *payload, int len) {
  unsigned char *pp = (unsigned char *)payload;
  if (pp[0] != 0x8) {
    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");
  }
  if (pp[1] & 0x40) {
    printf("All channels are identical\n");
  } else {
    printf("Each channel has its own type\n");
  }
  printf("There are %d end points\n", pp[2] & 0x7f);
}


x86 assembly (clang, -O0):
<multi_channel_get_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    $0x8,%eax
je     1155 <multi_channel_get_dump+0x45>
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <multi_channel_get_dump+0xca>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     117e <multi_channel_get_dump+0x6e>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118c <multi_channel_get_dump+0x7c>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11b3 <multi_channel_get_dump+0xa3>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <multi_channel_get_dump+0xb1>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%esi
and    $0x7f,%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_channel_get_dump>:
push   %rbx
mov    (%rsi),%al
cmp    $0x8,%al
jne    116e <multi_channel_get_dump+0x4e>
mov    %rsi,%rbx
cmpb   $0x0,0x1(%rsi)
lea    0xefb(%rip),%rax
lea    0xf4f(%rip),%rdi
cmovns %rax,%rdi
call   1030 <puts@plt>
testb  $0x40,0x1(%rbx)
lea    0xf02(%rip),%rax
lea    0xf19(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x2(%rbx),%al
and    $0x7f,%al
lea    0xeab(%rip),%rdi
jmp    1175 <multi_channel_get_dump+0x55>
lea    0xe8b(%rip),%rdi
movzbl %al,%esi
xor    %eax,%eax
pop    %rbx
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 = [28 x i8] c"All channels are identical\0A\00"
@.str.4 = [31 x i8] c"Each channel has its own type\0A\00"
@.str.5 = [25 x i8] c"There are %d end points\0A\00"
define void @multi_channel_get_dump(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = icmp ne i32 %12, 8
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %49
20: ; preds = %3
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = and i32 %24, 128
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %31
29: ; preds = %20
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = and i32 %35, 64
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %42
40: ; preds = %31
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = and i32 %46, 127
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %42, %14
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Impossible command %x\0A\00"
@.str.5 = [25 x i8] c"There are %d end points\0A\00"
@str = [34 x i8] c"The number of channnels are fixed\00"
@str.6 = [30 x i8] c"Each channel has its own type\00"
@str.7 = [27 x i8] c"All channels are identical\00"
@str.8 = [36 x i8] c"The number of channnels are dynamic\00"
define void @multi_channel_get_dump(i8* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 8
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = icmp sgt i8 %8, -1
%10 = select i1 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.8, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
%12 = load i8, i8* %7
%13 = and i8 %12, 64
%14 = icmp eq i8 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.7, i64 0, i64 0)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
%17 = getelementptr inbounds i8, i8* %1, i64 2
%18 = load i8, i8* %17
%19 = and i8 %18, 127
br label %20
20: ; preds = %3, %6
%21 = phi i8 [ %19, %6 ], [ %4, %3 ]
%22 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %3 ]
%23 = zext i8 %21 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, i32 %23)
ret void
}