#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 val[]) {
  __u16 major = val[222], minor = val[223];
  unsigned int ttype, subtype, transport = 0;
  if (major == 0x0000 || major == 0xffff) {
    return transport;
  }
  printf("\t%-20s", "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 & 0x2f) {
      if (subtype & (1 << 0))
        printf(", ATA8-AST");
      if (subtype & (1 << 1))
        printf(", SATA 1.0a");
      if (subtype & (1 << 2))
        printf(", SATA II Extensions");
      if (subtype & (1 << 3))
        printf(", SATA Rev 2.5");
      if (subtype & (1 << 4))
        printf(", SATA Rev 2.6");
      if (subtype & (1 << 5))
        printf(", SATA Rev 3.0");
    }
    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    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x378(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x37c(%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1164 <print_transport_type+0x44>
cmpl   $0xffff,-0x14(%rbp)
jne    116f <print_transport_type+0x4f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1347 <print_transport_type+0x227>
lea    0xe8a(%rip),%rdi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
sar    $0xc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
test   %eax,%eax
je     11c2 <print_transport_type+0xa2>
jmp    11b1 <print_transport_type+0x91>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     11f2 <print_transport_type+0xd2>
jmp    12c7 <print_transport_type+0x1a7>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ed <print_transport_type+0xcd>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d8 <print_transport_type+0x1b8>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x2f,%eax
cmp    $0x0,%eax
je     12c2 <print_transport_type+0x1a2>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     122c <print_transport_type+0x10c>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1249 <print_transport_type+0x129>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1266 <print_transport_type+0x146>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1283 <print_transport_type+0x163>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     12a0 <print_transport_type+0x180>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     12bd <print_transport_type+0x19d>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c2 <print_transport_type+0x1a2>
jmp    12d8 <print_transport_type+0x1b8>
mov    -0x14(%rbp),%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
je     1337 <print_transport_type+0x217>
cmpl   $0xffff,-0x18(%rbp)
je     1337 <print_transport_type+0x217>
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
sub    $0x21,%eax
jne    1321 <print_transport_type+0x201>
jmp    130e <print_transport_type+0x1ee>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1332 <print_transport_type+0x212>
mov    -0x18(%rbp),%esi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1337 <print_transport_type+0x217>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_transport_type>:
push   %rbp
push   %r14
push   %rbx
mov    0x378(%rdi),%ebx
xor    %ebp,%ebp
test   %ebx,%ebx
je     1290 <print_transport_type+0x170>
cmp    $0xffff,%ebx
je     1290 <print_transport_type+0x170>
mov    0x37c(%rdi),%r14d
lea    0xeb2(%rip),%rdi
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%ebp
sar    $0xc,%ebp
cmp    $0x1,%ebp
je     118d <print_transport_type+0x6d>
test   %ebp,%ebp
jne    11c4 <print_transport_type+0xa4>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
je     1243 <print_transport_type+0x123>
lea    0xe93(%rip),%rdi
jmp    123c <print_transport_type+0x11c>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2f,%bl
je     1243 <print_transport_type+0x123>
test   $0x1,%bl
jne    11d6 <print_transport_type+0xb6>
test   $0x2,%bl
jne    11e9 <print_transport_type+0xc9>
test   $0x4,%bl
jne    11fc <print_transport_type+0xdc>
test   $0x8,%bl
jne    120f <print_transport_type+0xef>
test   $0x10,%bl
jne    1222 <print_transport_type+0x102>
test   $0x20,%bl
jne    1235 <print_transport_type+0x115>
jmp    1243 <print_transport_type+0x123>
lea    0xebb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1243 <print_transport_type+0x123>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2,%bl
je     11ae <print_transport_type+0x8e>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x4,%bl
je     11b3 <print_transport_type+0x93>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x8,%bl
je     11b8 <print_transport_type+0x98>
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x10,%bl
je     11bd <print_transport_type+0x9d>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x20,%bl
je     1243 <print_transport_type+0x123>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     1286 <print_transport_type+0x166>
cmp    $0xffff,%r14d
je     1286 <print_transport_type+0x166>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x21,%r14d
jne    1275 <print_transport_type+0x155>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1286 <print_transport_type+0x166>
lea    0xe0a(%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 = [7 x i8] c"\09%-20s\00"
@.str.1 = [11 x i8] c"Transport:\00"
@.str.2 = [9 x i8] c"Parallel\00"
@.str.3 = [11 x i8] c", ATA8-APT\00"
@.str.4 = [7 x i8] c"Serial\00"
@.str.5 = [11 x i8] c", ATA8-AST\00"
@.str.6 = [12 x i8] c", SATA 1.0a\00"
@.str.7 = [21 x i8] c", SATA II Extensions\00"
@.str.8 = [15 x i8] c", SATA Rev 2.5\00"
@.str.9 = [15 x i8] c", SATA Rev 2.6\00"
@.str.10 = [15 x i8] c", SATA Rev 3.0\00"
@.str.11 = [7 x i8] c"0x%04x\00"
@.str.12 = [13 x i8] c"; Revision: \00"
@.str.13 = [39 x i8] c"ATA8-AST T13 Project D1697 Revision 0b\00"
define i32 @print_transport_type(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 222
%11 = load i32, i32* %10
store i32 %11, i32* %4
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 223
%14 = load i32, i32* %13
store i32 %14, i32* %5
store i32 0, i32* %8
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %1
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 65535
br i1 %19, label %20, label %22
20: ; preds = %17, %1
%21 = load i32, i32* %8
store i32 %21, i32* %2
br label %102
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = ashr i32 %24, 12
store i32 %25, i32* %6
%26 = load i32, i32* %4
%27 = and i32 %26, 4095
store i32 %27, i32* %7
%28 = load i32, i32* %6
store i32 %28, i32* %8
%29 = load i32, i32* %6
switch i32 %29, label %81 [
i32 0, label %30
i32 1, label %38
]
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %7
%33 = and i32 %32, 1
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
br label %84
38: ; preds = %22
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%40 = load i32, i32* %7
%41 = and i32 %40, 47
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %80
43: ; preds = %38
%44 = load i32, i32* %7
%45 = and i32 %44, 1
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = load i32, i32* %7
%51 = and i32 %50, 2
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = load i32, i32* %7
%57 = and i32 %56, 4
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
%62 = load i32, i32* %7
%63 = and i32 %62, 8
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %67
67: ; preds = %65, %61
%68 = load i32, i32* %7
%69 = and i32 %68, 16
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %73
73: ; preds = %71, %67
%74 = load i32, i32* %7
%75 = and i32 %74, 32
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
br label %80
80: ; preds = %79, %38
br label %84
81: ; preds = %22
%82 = load i32, i32* %4
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %81, %80, %37
%85 = load i32, i32* %5
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %99
87: ; preds = %84
%88 = load i32, i32* %5
%89 = icmp ne i32 %88, 65535
br i1 %89, label %90, label %99
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%92 = load i32, i32* %5
switch i32 %92, label %95 [
i32 33, label %93
]
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
br label %98
95: ; preds = %90
%96 = load i32, i32* %5
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %96)
br label %98
98: ; preds = %95, %93
br label %99
99: ; preds = %98, %87, %84
%100 = call i32 @putchar(i8 signext 10)
%101 = load i32, i32* %8
store i32 %101, i32* %2
br label %102
102: ; preds = %99, %20
%103 = load i32, i32* %2
ret i32 %103
}

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