#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 */
char *cmd_class_string(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void dump_node_info(unsigned char *buf, int len) {
  int i;
  printf("  Basic Device Class = %02x\n", buf[0]);
  printf("  Generic Device Class = %02x\n", buf[1]);
  printf("  Specific Device Class = %02x\n", buf[2]);
  printf("  Command Classes:\n");
  for (i = 3; i < len; i++) {
    printf("\t%s\n", cmd_class_string(buf[i]));
  }
}


x86 assembly (clang, -O0):
<dump_node_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%esi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c1 <dump_node_info+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <cmd_class_string@plt>
mov    %rax,%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <dump_node_info+0x65>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_node_info>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
movzbl (%rdi),%esi
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x1(%r15),%esi
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x2(%r15),%esi
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%ebp
jl     11c0 <dump_node_info+0x90>
mov    %ebp,%ebp
mov    $0x3,%ebx
lea    0xeca(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%edi
call   1040 <cmd_class_string@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <dump_node_info+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c" Basic Device Class = %02x\0A\00"
@.str.1 = [31 x i8] c" Generic Device Class = %02x\0A\00"
@.str.2 = [32 x i8] c" Specific Device Class = %02x\0A\00"
@.str.3 = [20 x i8] c" Command Classes:\0A\00"
@.str.4 = [5 x i8] c"\09%s\0A\00"
define void @dump_node_info(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %5
br label %22
22: ; preds = %34, %2
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i8* @cmd_class_string(i8 zeroext %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %22
37: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c" Basic Device Class = %02x\0A\00"
@.str.1 = [31 x i8] c" Generic Device Class = %02x\0A\00"
@.str.2 = [32 x i8] c" Specific Device Class = %02x\0A\00"
@.str.4 = [5 x i8] c"\09%s\0A\00"
@str = [19 x i8] c" Command Classes:\00"
define void @dump_node_info(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = zext i8 %3 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%15 = icmp sgt i32 %1, 3
br i1 %15, label %16, label %26
16: ; preds = %2
%17 = zext i32 %1 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 3, %16 ], [ %24, %18 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = tail call i8* @cmd_class_string(i8 zeroext %21)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = add nuw nsw i64 %19, 1
%25 = icmp eq i64 %24, %17
br i1 %25, label %26, label %18
26: ; preds = %18, %2
ret void
}