#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 */
typedef int __u16;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int print_transport_type(__u16 major, __u16 minor) {
  unsigned int ttype, subtype, transport = 0;
  if (major == 0x0000 || major == 0xffff)
    return transport;
  printf("Transport: ");
  ttype = major >> 12;
  subtype = major & 0xfff;
  transport = ttype;
  switch (ttype) {
  case 0:
    printf("Parallel");
    if (subtype & 1)
      printf(", ATA8-APT");
    break;
  case 1:
    printf("Serial");
    if (subtype & 0xf) {
      if (subtype & 1)
        printf(", ATA8-AST");
      if (subtype & 2)
        printf(", SATA 1.0a");
      if (subtype & 4)
        printf(", SATA II Extensions");
      if (subtype & 8)
        printf(", SATA Rev 2.5");
    }
    break;
  default:
    printf("0x%04x", major);
    break;
  }
  if (minor != 0x0000 && minor != 0xffff) {
    printf("; Revision: ");
    switch (minor) {
    case 0x21:
      printf("ATA8-AST T13 Project D1697 Revision 0b");
      break;
    default:
      printf("0x%04x", minor);
    }
  }
  putchar('\n');
  return transport;
}


x86 assembly (clang, -O0):
<print_transport_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     114c <print_transport_type+0x2c>
cmpl   $0xffff,-0x8(%rbp)
jne    1157 <print_transport_type+0x37>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12ee <print_transport_type+0x1ce>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
sar    $0xc,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     11a3 <print_transport_type+0x83>
jmp    1192 <print_transport_type+0x72>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     11d3 <print_transport_type+0xb3>
jmp    126e <print_transport_type+0x14e>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ce <print_transport_type+0xae>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127f <print_transport_type+0x15f>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
je     1269 <print_transport_type+0x149>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     120d <print_transport_type+0xed>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     122a <print_transport_type+0x10a>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1247 <print_transport_type+0x127>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1264 <print_transport_type+0x144>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1269 <print_transport_type+0x149>
jmp    127f <print_transport_type+0x15f>
mov    -0x8(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     12de <print_transport_type+0x1be>
cmpl   $0xffff,-0xc(%rbp)
je     12de <print_transport_type+0x1be>
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x21,%eax
jne    12c8 <print_transport_type+0x1a8>
jmp    12b5 <print_transport_type+0x195>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d9 <print_transport_type+0x1b9>
mov    -0xc(%rbp),%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12de <print_transport_type+0x1be>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_transport_type>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
test   %edi,%edi
je     124a <print_transport_type+0x12a>
mov    %edi,%ebx
cmp    $0xffff,%edi
je     124a <print_transport_type+0x12a>
mov    %esi,%r14d
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%ebp
sar    $0xc,%ebp
cmp    $0x1,%ebp
je     117b <print_transport_type+0x5b>
test   %ebp,%ebp
jne    11a4 <print_transport_type+0x84>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
je     11fd <print_transport_type+0xdd>
lea    0xe9c(%rip),%rdi
jmp    11f6 <print_transport_type+0xd6>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0xf,%bl
je     11fd <print_transport_type+0xdd>
test   $0x1,%bl
jne    11b6 <print_transport_type+0x96>
test   $0x2,%bl
jne    11c9 <print_transport_type+0xa9>
test   $0x4,%bl
jne    11dc <print_transport_type+0xbc>
test   $0x8,%bl
jne    11ef <print_transport_type+0xcf>
jmp    11fd <print_transport_type+0xdd>
lea    0xeb7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11fd <print_transport_type+0xdd>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2,%bl
je     1198 <print_transport_type+0x78>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x4,%bl
je     119d <print_transport_type+0x7d>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x8,%bl
je     11fd <print_transport_type+0xdd>
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     1240 <print_transport_type+0x120>
cmp    $0xffff,%r14d
je     1240 <print_transport_type+0x120>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x21,%r14d
jne    122f <print_transport_type+0x10f>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <print_transport_type+0x120>
lea    0xe2c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Transport: \00"
@.str.1 = [9 x i8] c"Parallel\00"
@.str.2 = [11 x i8] c", ATA8-APT\00"
@.str.3 = [7 x i8] c"Serial\00"
@.str.4 = [11 x i8] c", ATA8-AST\00"
@.str.5 = [12 x i8] c", SATA 1.0a\00"
@.str.6 = [21 x i8] c", SATA II Extensions\00"
@.str.7 = [15 x i8] c", SATA Rev 2.5\00"
@.str.8 = [7 x i8] c"0x%04x\00"
@.str.9 = [13 x i8] c"; Revision: \00"
@.str.10 = [39 x i8] c"ATA8-AST T13 Project D1697 Revision 0b\00"
define i32 @print_transport_type(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 65535
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = load i32, i32* %8
store i32 %15, i32* %3
br label %84
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %4
%19 = ashr i32 %18, 12
store i32 %19, i32* %6
%20 = load i32, i32* %4
%21 = and i32 %20, 4095
store i32 %21, i32* %7
%22 = load i32, i32* %6
store i32 %22, i32* %8
%23 = load i32, i32* %6
switch i32 %23, label %63 [
i32 0, label %24
i32 1, label %32
]
24: ; preds = %16
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %7
%27 = and i32 %26, 1
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
br label %66
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* %7
%35 = and i32 %34, 15
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %62
37: ; preds = %32
%38 = load i32, i32* %7
%39 = and i32 %38, 1
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = load i32, i32* %7
%45 = and i32 %44, 2
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = load i32, i32* %7
%51 = and i32 %50, 4
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = load i32, i32* %7
%57 = and i32 %56, 8
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
br label %62
62: ; preds = %61, %32
br label %66
63: ; preds = %16
%64 = load i32, i32* %4
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %62, %31
%67 = load i32, i32* %5
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %81
69: ; preds = %66
%70 = load i32, i32* %5
%71 = icmp ne i32 %70, 65535
br i1 %71, label %72, label %81
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%74 = load i32, i32* %5
switch i32 %74, label %77 [
i32 33, label %75
]
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %80
77: ; preds = %72
%78 = load i32, i32* %5
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %77, %75
br label %81
81: ; preds = %80, %69, %66
%82 = call i32 @putchar(i8 signext 10)
%83 = load i32, i32* %8
store i32 %83, i32* %3
br label %84
84: ; preds = %81, %14
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [12 x i8] c"Transport: \00"
@.str.1 = [9 x i8] c"Parallel\00"
@.str.2 = [11 x i8] c", ATA8-APT\00"
@.str.3 = [7 x i8] c"Serial\00"
@.str.4 = [11 x i8] c", ATA8-AST\00"
@.str.5 = [12 x i8] c", SATA 1.0a\00"
@.str.6 = [21 x i8] c", SATA II Extensions\00"
@.str.7 = [15 x i8] c", SATA Rev 2.5\00"
@.str.8 = [7 x i8] c"0x%04x\00"
@.str.9 = [13 x i8] c"; Revision: \00"
@.str.10 = [39 x i8] c"ATA8-AST T13 Project D1697 Revision 0b\00"
define i32 @print_transport_type(i32 %0, i32 %1) {
switch i32 %0, label %3 [
i32 65535, label %48
i32 0, label %48
]
3: ; preds = %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = ashr i32 %0, 12
switch i32 %5, label %36 [
i32 0, label %6
i32 1, label %12
]
6: ; preds = %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = and i32 %0, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %38, label %10
10: ; preds = %6
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %38
12: ; preds = %3
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = and i32 %0, 15
%15 = icmp eq i32 %14, 0
br i1 %15, label %38, label %16
16: ; preds = %12
%17 = and i32 %0, 1
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = and i32 %0, 2
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = and i32 %0, 4
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = and i32 %0, 8
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %38
36: ; preds = %3
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %0)
br label %38
38: ; preds = %12, %34, %31, %6, %10, %36
switch i32 %1, label %39 [
i32 65535, label %46
i32 0, label %46
]
39: ; preds = %38
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%41 = icmp eq i32 %1, 33
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %46
44: ; preds = %39
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %1)
br label %46
46: ; preds = %38, %38, %42, %44
%47 = tail call i32 @putchar(i8 signext 10)
br label %48
48: ; preds = %2, %2, %46
%49 = phi i32 [ %5, %46 ], [ 0, %2 ], [ 0, %2 ]
ret i32 %49
}