#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;
typedef int c;

/* Variables and functions */
int /*<<< orphan*/ print_num(int, char *, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
u_char *print_io_map(u_char *p, u_char *q) {
  int i, j;
  u_char c;
  if (q <= p)
    goto err;
  if (((*p) & 0x1F))
    printf("\tCard decodes %d address lines", ((*p) & 0x1F));
  else
    printf("\tCard provides address decode");
  switch (*p & (0x20 | 0x40)) {
  case 0x20:
    printf(", 8 Bit I/O only");
    break;
  case 0x40:
    printf(", limited 8/16 Bit I/O");
    break;
  case (0x20 | 0x40):
    printf(", full 8/16 Bit I/O");
    break;
  }
  putchar('\n');
  if (*p++ & 0x80) {
    if (q <= p)
      goto err;
    c = *p++;
    j = (((c) >> 4) & 3) + (((c) >> 6) & 3);
    if ((((c) >> 4) & 3) == 3)
      j++;
    if ((((c) >> 6) & 3) == 3)
      j++;
    for (i = 0; i <= ((c)&0xF); i++) {
      if (q - p < j)
        goto err;
      printf("\t\tI/O address # %d: ", i + 1);
      p += print_num((((c) >> 4) & 3), "block start = 0x%x", p, 0);
      p += print_num((((c) >> 6) & 3), " block length = 0x%x", p, 1);
      putchar('\n');
    }
  }
  return p;
err:
  printf("\tWrong length for I/O mapping sub-tuple\n");
  return p;
}


x86 assembly (clang, -O0):
<print_io_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     1153 <print_io_map+0x23>
jmp    1374 <print_io_map+0x244>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x1f,%eax
cmp    $0x0,%eax
je     1181 <print_io_map+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
and    $0x1f,%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    118f <print_io_map+0x5f>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x60,%eax
mov    %eax,-0x28(%rbp)
sub    $0x20,%eax
je     11cb <print_io_map+0x9b>
jmp    11a9 <print_io_map+0x79>
mov    -0x28(%rbp),%eax
sub    $0x40,%eax
je     11de <print_io_map+0xae>
jmp    11ba <print_io_map+0x8a>
mov    -0x28(%rbp),%eax
sub    $0x60,%eax
je     11f1 <print_io_map+0xc1>
jmp    11ff <print_io_map+0xcf>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <print_io_map+0xcf>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <print_io_map+0xcf>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1367 <print_io_map+0x237>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     123b <print_io_map+0x10b>
jmp    1374 <print_io_map+0x244>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x4,%eax
and    $0x3,%eax
mov    -0x24(%rbp),%ecx
sar    $0x6,%ecx
and    $0x3,%ecx
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x4,%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    1281 <print_io_map+0x151>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x6,%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    129c <print_io_map+0x16c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
and    $0xf,%ecx
cmp    %ecx,%eax
jg     1362 <print_io_map+0x232>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
jge    12d5 <print_io_map+0x1a5>
jmp    1374 <print_io_map+0x244>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
sar    $0x4,%edi
and    $0x3,%edi
mov    -0x10(%rbp),%rdx
lea    0xd91(%rip),%rsi
xor    %ecx,%ecx
call   1050 <print_num@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%edi
sar    $0x6,%edi
and    $0x3,%edi
mov    -0x10(%rbp),%rdx
lea    0xd75(%rip),%rsi
mov    $0x1,%ecx
call   1050 <print_num@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12a3 <print_io_map+0x173>
jmp    1367 <print_io_map+0x237>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    138a <print_io_map+0x25a>
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_io_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
cmp    %rdi,%rsi
jbe    116f <print_io_map+0x2f>
mov    %rsi,%rbp
mov    0x0(%r13),%esi
and    $0x1f,%esi
je     1177 <print_io_map+0x37>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1185 <print_io_map+0x45>
mov    %r13,%rbx
jmp    12a6 <print_io_map+0x166>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13),%eax
and    $0x60,%eax
cmp    $0x20,%eax
je     11a4 <print_io_map+0x64>
cmp    $0x60,%eax
je     11ad <print_io_map+0x6d>
cmp    $0x40,%eax
jne    11bb <print_io_map+0x7b>
lea    0xeac(%rip),%rdi
jmp    11b4 <print_io_map+0x74>
lea    0xe92(%rip),%rdi
jmp    11b4 <print_io_map+0x74>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x4(%r13),%rbx
testb  $0x80,0x0(%r13)
je     12b2 <print_io_map+0x172>
cmp    %rbp,%rbx
jae    12a6 <print_io_map+0x166>
mov    %rbp,%rdx
mov    0x4(%r13),%r15d
add    $0x8,%r13
mov    %r15d,%edi
shr    $0x4,%edi
and    $0x3,%edi
mov    %r15d,%r12d
shr    $0x6,%r12d
and    $0x3,%r12d
lea    (%r12,%rdi,1),%rax
xor    %ecx,%ecx
mov    %rdi,(%rsp)
cmp    $0x3,%edi
sete   %cl
add    %rax,%rcx
xor    %r14d,%r14d
cmp    $0x3,%r12d
sete   %r14b
add    %rcx,%r14
and    $0xf,%r15d
neg    %r15d
mov    $0x1,%ebp
mov    %r13,%rbx
mov    %rdx,%r13
nop
mov    %r13,%rax
sub    %rbx,%rax
sar    $0x2,%rax
cmp    %r14,%rax
jl     12a6 <print_io_map+0x166>
lea    0xe33(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rdi
lea    0xe34(%rip),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1060 <print_num@plt>
cltq
lea    (%rbx,%rax,4),%rbx
mov    %r12d,%edi
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1060 <print_num@plt>
cltq
lea    (%rbx,%rax,4),%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x2,%eax
jne    1230 <print_io_map+0xf0>
jmp    12b2 <print_io_map+0x172>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\09Card decodes %d address lines\00"
@.str.1 = [30 x i8] c"\09Card provides address decode\00"
@.str.2 = [17 x i8] c", 8 Bit I/O only\00"
@.str.3 = [23 x i8] c", limited 8/16 Bit I/O\00"
@.str.4 = [20 x i8] c", full 8/16 Bit I/O\00"
@.str.5 = [21 x i8] c"\09\09I/O address # %d: \00"
@.str.6 = [19 x i8] c"block start = 0x%x\00"
@.str.7 = [21 x i8] c" block length = 0x%x\00"
@.str.8 = [41 x i8] c"\09Wrong length for I/O mapping sub-tuple\0A\00"
define i32* @print_io_map(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
%9 = load i32*, i32** %5
%10 = load i32*, i32** %4
%11 = icmp ule i32* %9, %10
br i1 %11, label %12, label %13
12: ; preds = %2
br label %117
13: ; preds = %2
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = and i32 %15, 31
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = and i32 %20, 31
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %25
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
%26 = load i32*, i32** %4
%27 = load i32, i32* %26
%28 = and i32 %27, 96
switch i32 %28, label %35 [
i32 32, label %29
i32 64, label %31
i32 96, label %33
]
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %35
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %35
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %25, %33, %31, %29
%36 = call i32 @putchar(i8 signext 10)
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %4
%39 = load i32, i32* %37
%40 = and i32 %39, 128
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %115
42: ; preds = %35
%43 = load i32*, i32** %5
%44 = load i32*, i32** %4
%45 = icmp ule i32* %43, %44
br i1 %45, label %46, label %47
46: ; preds = %42
br label %117
47: ; preds = %42
%48 = load i32*, i32** %4
%49 = getelementptr inbounds i32, i32* %48, i32 1
store i32* %49, i32** %4
%50 = load i32, i32* %48
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = ashr i32 %51, 4
%53 = and i32 %52, 3
%54 = load i32, i32* %8
%55 = ashr i32 %54, 6
%56 = and i32 %55, 3
%57 = add nsw i32 %53, %56
store i32 %57, i32* %7
%58 = load i32, i32* %8
%59 = ashr i32 %58, 4
%60 = and i32 %59, 3
%61 = icmp eq i32 %60, 3
br i1 %61, label %62, label %65
62: ; preds = %47
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %65
65: ; preds = %62, %47
%66 = load i32, i32* %8
%67 = ashr i32 %66, 6
%68 = and i32 %67, 3
%69 = icmp eq i32 %68, 3
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %73
73: ; preds = %70, %65
store i32 0, i32* %6
br label %74
74: ; preds = %111, %73
%75 = load i32, i32* %6
%76 = load i32, i32* %8
%77 = and i32 %76, 15
%78 = icmp sle i32 %75, %77
br i1 %78, label %79, label %114
79: ; preds = %74
%80 = load i32*, i32** %5
%81 = load i32*, i32** %4
%82 = ptrtoint i32* %80 to i64
%83 = ptrtoint i32* %81 to i64
%84 = sub i64 %82, %83
%85 = sdiv exact i64 %84, 4
%86 = load i32, i32* %7
%87 = sext i32 %86 to i64
%88 = icmp slt i64 %85, %87
br i1 %88, label %89, label %90
89: ; preds = %79
br label %117
90: ; preds = %79
%91 = load i32, i32* %6
%92 = add nsw i32 %91, 1
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %8
%95 = ashr i32 %94, 4
%96 = and i32 %95, 3
%97 = load i32*, i32** %4
%98 = call i32 @print_num(i32 %96, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32* %97, i32 0)
%99 = load i32*, i32** %4
%100 = sext i32 %98 to i64
%101 = getelementptr inbounds i32, i32* %99, i64 %100
store i32* %101, i32** %4
%102 = load i32, i32* %8
%103 = ashr i32 %102, 6
%104 = and i32 %103, 3
%105 = load i32*, i32** %4
%106 = call i32 @print_num(i32 %104, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32* %105, i32 1)
%107 = load i32*, i32** %4
%108 = sext i32 %106 to i64
%109 = getelementptr inbounds i32, i32* %107, i64 %108
store i32* %109, i32** %4
%110 = call i32 @putchar(i8 signext 10)
br label %111
111: ; preds = %90
%112 = load i32, i32* %6
%113 = add nsw i32 %112, 1
store i32 %113, i32* %6
br label %74
114: ; preds = %74
br label %115
115: ; preds = %114, %35
%116 = load i32*, i32** %4
store i32* %116, i32** %3
br label %120
117: ; preds = %89, %46, %12
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%119 = load i32*, i32** %4
store i32* %119, i32** %3
br label %120
120: ; preds = %117, %115
%121 = load i32*, i32** %3
ret i32* %121
}

LLVM IR (-O2):
@.str = [31 x i8] c"\09Card decodes %d address lines\00"
@.str.1 = [30 x i8] c"\09Card provides address decode\00"
@.str.2 = [17 x i8] c", 8 Bit I/O only\00"
@.str.3 = [23 x i8] c", limited 8/16 Bit I/O\00"
@.str.4 = [20 x i8] c", full 8/16 Bit I/O\00"
@.str.5 = [21 x i8] c"\09\09I/O address # %d: \00"
@.str.6 = [19 x i8] c"block start = 0x%x\00"
@.str.7 = [21 x i8] c" block length = 0x%x\00"
@str = [40 x i8] c"\09Wrong length for I/O mapping sub-tuple\00"
define i32* @print_io_map(i32* %0, i32* %1) {
%3 = icmp ugt i32* %1, %0
br i1 %3, label %4, label %63
4: ; preds = %2
%5 = load i32, i32* %0
%6 = and i32 %5, 31
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* %0
%14 = and i32 %13, 96
switch i32 %14, label %20 [
i32 32, label %17
i32 64, label %15
i32 96, label %16
]
15: ; preds = %12
br label %17
16: ; preds = %12
br label %17
17: ; preds = %12, %15, %16
%18 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), %16 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %15 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %12 ]
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %18)
br label %20
20: ; preds = %17, %12
%21 = tail call i32 @putchar(i8 signext 10)
%22 = getelementptr inbounds i32, i32* %0, i64 1
%23 = load i32, i32* %0
%24 = and i32 %23, 128
%25 = icmp eq i32 %24, 0
br i1 %25, label %66, label %26
26: ; preds = %20
%27 = icmp ult i32* %22, %1
br i1 %27, label %28, label %63
28: ; preds = %26
%29 = getelementptr inbounds i32, i32* %0, i64 2
%30 = load i32, i32* %22
%31 = lshr i32 %30, 4
%32 = and i32 %31, 3
%33 = lshr i32 %30, 6
%34 = and i32 %33, 3
%35 = add nuw nsw i32 %32, %34
%36 = icmp eq i32 %32, 3
%37 = zext i1 %36 to i32
%38 = add nuw nsw i32 %35, %37
%39 = icmp eq i32 %34, 3
%40 = zext i1 %39 to i32
%41 = add nuw nsw i32 %38, %40
%42 = and i32 %30, 15
%43 = ptrtoint i32* %1 to i64
%44 = zext i32 %41 to i64
br label %45
45: ; preds = %28, %52
%46 = phi i32 [ 0, %28 ], [ %53, %52 ]
%47 = phi i32* [ %29, %28 ], [ %60, %52 ]
%48 = ptrtoint i32* %47 to i64
%49 = sub i64 %43, %48
%50 = ashr exact i64 %49, 2
%51 = icmp slt i64 %50, %44
br i1 %51, label %63, label %52
52: ; preds = %45
%53 = add nuw nsw i32 %46, 1
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = tail call i32 @print_num(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32* %47, i32 0)
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %47, i64 %56
%58 = tail call i32 @print_num(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32* %57, i32 1)
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = tail call i32 @putchar(i8 signext 10)
%62 = icmp eq i32 %46, %42
br i1 %62, label %66, label %45
63: ; preds = %45, %26, %2
%64 = phi i32* [ %0, %2 ], [ %22, %26 ], [ %47, %45 ]
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %66
66: ; preds = %52, %20, %63
%67 = phi i32* [ %64, %63 ], [ %22, %20 ], [ %60, %52 ]
ret i32* %67
}