#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*/ term_printf(char *, ...);
char *usb_class_str(int);
void usb_info_device(int bus_num, int addr, int class_id, int vendor_id,
                     int product_id, const char *product_name, int speed) {
  const char *class_str, *speed_str;
  switch (speed) {
  case 0:
    speed_str = "1.5";
    break;
  case 1:
    speed_str = "12";
    break;
  case 2:
    speed_str = "480";
    break;
  default:
    speed_str = "?";
    break;
  }
  term_printf("  Device %d.%d, speed %s Mb/s\n", bus_num, addr, speed_str);
  class_str = usb_class_str(class_id);
  if (class_str)
    term_printf("    %s:", class_str);
  else
    term_printf("    Class %02x:", class_id);
  term_printf(" USB device %04x:%04x", vendor_id, product_id);
  if (product_name[0] != '\0')
    term_printf(", %s", product_name);
  term_printf("\n");
}


x86 assembly (clang, -O0):
<usb_info_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     1174 <usb_info_device+0x54>
jmp    1152 <usb_info_device+0x32>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     1184 <usb_info_device+0x64>
jmp    1163 <usb_info_device+0x43>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     1194 <usb_info_device+0x74>
jmp    11a4 <usb_info_device+0x84>
lea    0xe85(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11af <usb_info_device+0x8f>
lea    0xe79(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11af <usb_info_device+0x8f>
lea    0xe6c(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11af <usb_info_device+0x8f>
lea    0xe60(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <usb_class_str@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f5 <usb_info_device+0xd5>
mov    -0x28(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
jmp    1206 <usb_info_device+0xe6>
mov    -0xc(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     123c <usb_info_device+0x11c>
mov    -0x20(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <term_printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_info_device>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%edx
mov    %edi,%esi
mov    0x30(%rsp),%eax
cmp    $0x2,%eax
ja     1151 <usb_info_device+0x31>
cltq
lea    0xf18(%rip),%rdi
movslq (%rdi,%rax,4),%rcx
add    %rdi,%rcx
jmp    1158 <usb_info_device+0x38>
lea    0xeb3(%rip),%rcx
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <term_printf@plt>
mov    %ebp,%edi
call   1030 <usb_class_str@plt>
test   %rax,%rax
je     1185 <usb_info_device+0x65>
lea    0xeb3(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <term_printf@plt>
jmp    1195 <usb_info_device+0x75>
lea    0xea8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <term_printf@plt>
lea    0xea8(%rip),%rdi
mov    %r15d,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <term_printf@plt>
cmpb   $0x0,(%rbx)
je     11bf <usb_info_device+0x9f>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <term_printf@plt>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <term_printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"1.5\00"
@.str.1 = [3 x i8] c"12\00"
@.str.2 = [4 x i8] c"480\00"
@.str.3 = [2 x i8] c"?\00"
@.str.4 = [31 x i8] c" Device %d.%d, speed %s Mb/s\0A\00"
@.str.5 = [8 x i8] c" %s:\00"
@.str.6 = [16 x i8] c" Class %02x:\00"
@.str.7 = [22 x i8] c" USB device %04x:%04x\00"
@.str.8 = [5 x i8] c", %s\00"
@.str.9 = [2 x i8] c"\0A\00"
define void @usb_info_device(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i32 %6, i32* %14
%17 = load i32, i32* %14
switch i32 %17, label %21 [
i32 0, label %18
i32 1, label %19
i32 2, label %20
]
18: ; preds = %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %16
br label %22
19: ; preds = %7
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %16
br label %22
20: ; preds = %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %16
br label %22
21: ; preds = %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %16
br label %22
22: ; preds = %21, %20, %19, %18
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = load i8*, i8** %16
%26 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %24, i8* %25)
%27 = load i32, i32* %10
%28 = call i8* @usb_class_str(i32 %27)
store i8* %28, i8** %15
%29 = load i8*, i8** %15
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = load i8*, i8** %15
%33 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %32)
br label %37
34: ; preds = %22
%35 = load i32, i32* %10
%36 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %31
%38 = load i32, i32* %11
%39 = load i32, i32* %12
%40 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i8*, i8** %13
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %37
%47 = load i8*, i8** %13
%48 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %37
%50 = call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"1.5\00"
@.str.1 = [3 x i8] c"12\00"
@.str.2 = [4 x i8] c"480\00"
@.str.3 = [2 x i8] c"?\00"
@.str.4 = [31 x i8] c" Device %d.%d, speed %s Mb/s\0A\00"
@.str.5 = [8 x i8] c" %s:\00"
@.str.6 = [16 x i8] c" Class %02x:\00"
@.str.7 = [22 x i8] c" USB device %04x:%04x\00"
@.str.8 = [5 x i8] c", %s\00"
@.str.9 = [2 x i8] c"\0A\00"
@reltable.usb_info_device = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.usb_info_device to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.usb_info_device to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.usb_info_device to i64)) to i32)]
define void @usb_info_device(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6) {
%8 = icmp ult i32 %6, 3
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = sext i32 %6 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.usb_info_device to i8*), i64 %11)
br label %13
13: ; preds = %7, %9
%14 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %7 ]
%15 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %0, i32 %1, i8* %14)
%16 = tail call i8* @usb_class_str(i32 %2)
%17 = icmp eq i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %16)
br label %22
20: ; preds = %13
%21 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %2)
br label %22
22: ; preds = %20, %18
%23 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %3, i32 %4)
%24 = load i8, i8* %5
%25 = icmp eq i8 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %28
28: ; preds = %26, %22
%29 = tail call i32 (i8*, ...) @term_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret void
}