#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 u_char;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void dump_disk_ext(u_char *p, int len) {
  if (len < 1)
    return;
  switch (p[0]) {
  case 1:
    if (len < 2)
      goto err;
    printf("\tDisk interface: %s\n", (p[1] & 1) ? "IDE" : "Undefined");
    break;
  case 2:
  case 3:
    if (len < 3)
      goto err;
    printf("\tDisk features: %s, %s%s\n",
           (p[1] & 0x04) ? "Silicon" : "Rotating",
           (p[1] & 0x08) ? "Unique, " : "", (p[1] & 0x10) ? "Dual" : "Single");
    if (p[2] & 0x7f)
      printf("\t\t%s%s%s%s%s%s%s\n", (p[2] & 0x01) ? "Sleep, " : "",
             (p[2] & 0x02) ? "Standby, " : "", (p[2] & 0x04) ? "Idle, " : "",
             (p[2] & 0x08) ? "Low power, " : "",
             (p[2] & 0x10) ? "Reg inhibit, " : "",
             (p[2] & 0x20) ? "Index, " : "", (p[2] & 0x40) ? "Iois16" : "");
    break;
  err:
    printf("\tWrong length for fixed disk extension tuple\n");
    return;
  }
}


x86 assembly (clang, -O0):
<dump_disk_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    112e <dump_disk_ext+0x1e>
jmp    132d <dump_disk_ext+0x21d>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1159 <dump_disk_ext+0x49>
jmp    1145 <dump_disk_ext+0x35>
mov    -0x10(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     119a <dump_disk_ext+0x8a>
jmp    132d <dump_disk_ext+0x21d>
cmpl   $0x2,-0xc(%rbp)
jge    1168 <dump_disk_ext+0x58>
jmp    131f <dump_disk_ext+0x20f>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0x1,%ecx
lea    0xea0(%rip),%rsi
lea    0xe95(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132d <dump_disk_ext+0x21d>
cmpl   $0x3,-0xc(%rbp)
jge    11a9 <dump_disk_ext+0x99>
jmp    131f <dump_disk_ext+0x20f>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0x4,%ecx
lea    0xe8b(%rip),%rsi
lea    0xe7c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0x8,%ecx
lea    0xf0b(%rip),%rdx
lea    0xe6e(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
and    $0x10,%edi
lea    0xe64(%rip),%rcx
lea    0xe58(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
and    $0x7f,%eax
cmp    $0x0,%eax
je     131a <dump_disk_ext+0x20a>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
and    $0x1,%ecx
lea    0xeac(%rip),%rsi
lea    0xe36(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
and    $0x2,%ecx
lea    0xe8d(%rip),%rdx
lea    0xe1f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
and    $0x4,%edi
lea    0xe6e(%rip),%rcx
lea    0xe0a(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
and    $0x8,%edi
lea    0xe4f(%rip),%r8
lea    0xdf2(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
and    $0x10,%edi
lea    0xe30(%rip),%r9
lea    0xddf(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r9
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
and    $0x20,%edi
lea    0xe11(%rip),%r10
lea    0xdce(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r10
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r11d
and    $0x40,%r11d
lea    0xdf0(%rip),%rax
lea    0xdb5(%rip),%rdi
cmp    $0x0,%r11d
cmovne %rdi,%rax
lea    0xd59(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132d <dump_disk_ext+0x21d>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_disk_ext>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    122d <dump_disk_ext+0x10d>
mov    %rdi,%rbx
mov    (%rdi),%eax
lea    -0x2(%rax),%ecx
cmp    $0x2,%ecx
jae    1210 <dump_disk_ext+0xf0>
cmp    $0x3,%esi
jb     121a <dump_disk_ext+0xfa>
mov    0x4(%rbx),%eax
test   $0x4,%al
lea    0xef3(%rip),%rcx
lea    0xee4(%rip),%rsi
cmove  %rcx,%rsi
test   $0x8,%al
lea    0xeae(%rip),%r14
lea    0xee1(%rip),%rdx
cmove  %r14,%rdx
test   $0x10,%al
lea    0xee2(%rip),%rax
lea    0xed6(%rip),%rcx
cmove  %rax,%rcx
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%eax
test   $0x7f,%al
je     122d <dump_disk_ext+0x10d>
test   $0x1,%al
lea    0xece(%rip),%rsi
cmove  %r14,%rsi
test   $0x2,%al
lea    0xec9(%rip),%rdx
cmove  %r14,%rdx
test   $0x4,%al
lea    0xec6(%rip),%rcx
cmove  %r14,%rcx
test   $0x8,%al
lea    0xec0(%rip),%r8
cmove  %r14,%r8
test   $0x10,%al
lea    0xebf(%rip),%r9
cmove  %r14,%r9
test   $0x20,%al
lea    0xec0(%rip),%r10
cmove  %r14,%r10
test   $0x40,%al
lea    0xebb(%rip),%rbx
cmove  %r14,%rbx
lea    0xe63(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
call   1040 <printf@plt>
add    $0x18,%rsp
jmp    1231 <dump_disk_ext+0x111>
cmp    $0x1,%eax
jne    122d <dump_disk_ext+0x10d>
cmp    $0x2,%esi
jae    1235 <dump_disk_ext+0x115>
lea    0xe96(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
testb  $0x1,0x4(%rbx)
lea    0xdd9(%rip),%rax
lea    0xdce(%rip),%rsi
cmove  %rax,%rsi
lea    0xdae(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"\09Disk interface: %s\0A\00"
@.str.1 = [4 x i8] c"IDE\00"
@.str.2 = [10 x i8] c"Undefined\00"
@.str.3 = [26 x i8] c"\09Disk features: %s, %s%s\0A\00"
@.str.4 = [8 x i8] c"Silicon\00"
@.str.5 = [9 x i8] c"Rotating\00"
@.str.6 = [9 x i8] c"Unique, \00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [5 x i8] c"Dual\00"
@.str.9 = [7 x i8] c"Single\00"
@.str.10 = [18 x i8] c"\09\09%s%s%s%s%s%s%s\0A\00"
@.str.11 = [8 x i8] c"Sleep, \00"
@.str.12 = [10 x i8] c"Standby, \00"
@.str.13 = [7 x i8] c"Idle, \00"
@.str.14 = [12 x i8] c"Low power, \00"
@.str.15 = [14 x i8] c"Reg inhibit, \00"
@.str.16 = [8 x i8] c"Index, \00"
@.str.17 = [7 x i8] c"Iois16\00"
@.str.18 = [46 x i8] c"\09Wrong length for fixed disk extension tuple\0A\00"
define void @dump_disk_ext(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %2
br label %111
8: ; preds = %2
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
switch i32 %11, label %111 [
i32 1, label %12
i32 2, label %25
i32 3, label %25
]
12: ; preds = %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %16
15: ; preds = %12
br label %109
16: ; preds = %12
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32, i32* %18
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %111
25: ; preds = %8, %8
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %29
28: ; preds = %25
br label %109
29: ; preds = %25
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
%33 = and i32 %32, 4
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0)
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 1
%39 = load i32, i32* %38
%40 = and i32 %39, 8
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%44 = load i32*, i32** %3
%45 = getelementptr inbounds i32, i32* %44, i64 1
%46 = load i32, i32* %45
%47 = and i32 %46, 16
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %36, i8* %43, i8* %50)
%52 = load i32*, i32** %3
%53 = getelementptr inbounds i32, i32* %52, i64 2
%54 = load i32, i32* %53
%55 = and i32 %54, 127
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %108
57: ; preds = %29
%58 = load i32*, i32** %3
%59 = getelementptr inbounds i32, i32* %58, i64 2
%60 = load i32, i32* %59
%61 = and i32 %60, 1
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%65 = load i32*, i32** %3
%66 = getelementptr inbounds i32, i32* %65, i64 2
%67 = load i32, i32* %66
%68 = and i32 %67, 2
%69 = icmp ne i32 %68, 0
%70 = zext i1 %69 to i64
%71 = select i1 %69, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%72 = load i32*, i32** %3
%73 = getelementptr inbounds i32, i32* %72, i64 2
%74 = load i32, i32* %73
%75 = and i32 %74, 4
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%79 = load i32*, i32** %3
%80 = getelementptr inbounds i32, i32* %79, i64 2
%81 = load i32, i32* %80
%82 = and i32 %81, 8
%83 = icmp ne i32 %82, 0
%84 = zext i1 %83 to i64
%85 = select i1 %83, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%86 = load i32*, i32** %3
%87 = getelementptr inbounds i32, i32* %86, i64 2
%88 = load i32, i32* %87
%89 = and i32 %88, 16
%90 = icmp ne i32 %89, 0
%91 = zext i1 %90 to i64
%92 = select i1 %90, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%93 = load i32*, i32** %3
%94 = getelementptr inbounds i32, i32* %93, i64 2
%95 = load i32, i32* %94
%96 = and i32 %95, 32
%97 = icmp ne i32 %96, 0
%98 = zext i1 %97 to i64
%99 = select i1 %97, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%100 = load i32*, i32** %3
%101 = getelementptr inbounds i32, i32* %100, i64 2
%102 = load i32, i32* %101
%103 = and i32 %102, 64
%104 = icmp ne i32 %103, 0
%105 = zext i1 %104 to i64
%106 = select i1 %104, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %64, i8* %71, i8* %78, i8* %85, i8* %92, i8* %99, i8* %106)
br label %108
108: ; preds = %57, %29
br label %111
109: ; preds = %28, %15
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.18, i64 0, i64 0))
br label %111
111: ; preds = %7, %109, %8, %108, %16
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"\09Disk interface: %s\0A\00"
@.str.1 = [4 x i8] c"IDE\00"
@.str.2 = [10 x i8] c"Undefined\00"
@.str.3 = [26 x i8] c"\09Disk features: %s, %s%s\0A\00"
@.str.4 = [8 x i8] c"Silicon\00"
@.str.5 = [9 x i8] c"Rotating\00"
@.str.6 = [9 x i8] c"Unique, \00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [5 x i8] c"Dual\00"
@.str.9 = [7 x i8] c"Single\00"
@.str.10 = [18 x i8] c"\09\09%s%s%s%s%s%s%s\0A\00"
@.str.11 = [8 x i8] c"Sleep, \00"
@.str.12 = [10 x i8] c"Standby, \00"
@.str.13 = [7 x i8] c"Idle, \00"
@.str.14 = [12 x i8] c"Low power, \00"
@.str.15 = [14 x i8] c"Reg inhibit, \00"
@.str.16 = [8 x i8] c"Index, \00"
@.str.17 = [7 x i8] c"Iois16\00"
@str = [45 x i8] c"\09Wrong length for fixed disk extension tuple\00"
define void @dump_disk_ext(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %59, label %4
4: ; preds = %2
%5 = load i32, i32* %0
switch i32 %5, label %59 [
i32 1, label %6
i32 2, label %15
i32 3, label %15
]
6: ; preds = %4
%7 = icmp ult i32 %1, 2
br i1 %7, label %57, label %8
8: ; preds = %6
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %59
15: ; preds = %4, %4
%16 = icmp ult i32 %1, 3
br i1 %16, label %57, label %17
17: ; preds = %15
%18 = getelementptr inbounds i32, i32* %0, i64 1
%19 = load i32, i32* %18
%20 = and i32 %19, 4
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%23 = and i32 %19, 8
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0)
%26 = and i32 %19, 16
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %25, i8* %28)
%30 = getelementptr inbounds i32, i32* %0, i64 2
%31 = load i32, i32* %30
%32 = and i32 %31, 127
%33 = icmp eq i32 %32, 0
br i1 %33, label %59, label %34
34: ; preds = %17
%35 = and i32 %31, 1
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%38 = and i32 %31, 2
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0)
%41 = and i32 %31, 4
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0)
%44 = and i32 %31, 8
%45 = icmp eq i32 %44, 0
%46 = select i1 %45, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0)
%47 = and i32 %31, 16
%48 = icmp eq i32 %47, 0
%49 = select i1 %48, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0)
%50 = and i32 %31, 32
%51 = icmp eq i32 %50, 0
%52 = select i1 %51, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0)
%53 = and i32 %31, 64
%54 = icmp eq i32 %53, 0
%55 = select i1 %54, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0)
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* %37, i8* %40, i8* %43, i8* %46, i8* %49, i8* %52, i8* %55)
br label %59
57: ; preds = %15, %6
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %59
59: ; preds = %17, %34, %2, %57, %4, %8
ret void
}