#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*/ printf(char *, ...);
unsigned char rd_byte(unsigned char *);
void display_byte(unsigned long start, unsigned long endaddr,
                  unsigned long width) {
  int index;
  unsigned char r;
  char pc[16];
  for (;;) {
    if (start < endaddr) {
      r = rd_byte((unsigned char *)start);
      if ((start % width) == 0)
        printf("%06lX: ", start);
      pc[start % width] = r;
      start++;
      printf("%02X%c", r, ' ');
      if ((start % width) == 0) {
        printf(" ");
        for (index = 0; (index < width); index++) {
          r = pc[index];
          printf("%c", ((r >= 0x20) && (r <= 0x7E)) ? r : '.');
        }
        printf("\n");
      }
    } else {
      if (start % width) {
        for (index = 0; (index < (3 * (width - start % width))); index++)
          printf(" ");
        printf(" ");
        for (index = 0; (index < (start % width)); index++) {
          r = pc[index];
          printf("%c", ((r >= 0x20) && (r <= 0x7E)) ? r : '.');
        }
        printf("\n");
      }
      goto endbyte;
    }
  }
endbyte:
  return;
}


x86 assembly (clang, -O0):
<display_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    125b <display_byte+0x13b>
mov    -0x8(%rbp),%rdi
call   1040 <rd_byte@plt>
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1176 <display_byte+0x56>
mov    -0x8(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
mov    %al,-0x31(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    -0x31(%rbp),%al
mov    %al,-0x30(%rbp,%rdx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movzbl -0x1d(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x20,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1256 <display_byte+0x136>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1248 <display_byte+0x128>
movslq -0x1c(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%al
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jl     121c <display_byte+0xfc>
movzbl -0x1d(%rbp),%eax
cmp    $0x7e,%eax
jg     121c <display_byte+0xfc>
movzbl -0x1d(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1229 <display_byte+0x109>
mov    $0x2e,%eax
mov    %eax,-0x38(%rbp)
jmp    1229 <display_byte+0x109>
mov    -0x38(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dd <display_byte+0xbd>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1364 <display_byte+0x244>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
je     135f <display_byte+0x23f>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
xor    %edx,%edx
divq   -0x18(%rbp)
mov    -0x40(%rbp),%rax
sub    %rdx,%rcx
imul   $0x3,%rcx,%rcx
cmp    %rcx,%rax
jae    12be <display_byte+0x19e>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1278 <display_byte+0x158>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    -0x48(%rbp),%rax
cmp    %rdx,%rax
jae    1351 <display_byte+0x231>
movslq -0x1c(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%al
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jl     1325 <display_byte+0x205>
movzbl -0x1d(%rbp),%eax
cmp    $0x7e,%eax
jg     1325 <display_byte+0x205>
movzbl -0x1d(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1332 <display_byte+0x212>
mov    $0x2e,%eax
mov    %eax,-0x4c(%rbp)
jmp    1332 <display_byte+0x212>
mov    -0x4c(%rbp),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12d3 <display_byte+0x1b3>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1369 <display_byte+0x249>
jmp    1134 <display_byte+0x14>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
cmp    %rsi,%rdi
jae    1267 <display_byte+0x137>
mov    %rsi,%r15
mov    $0x2e,%r13d
jmp    1173 <display_byte+0x43>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r15,%r14
je     1264 <display_byte+0x134>
mov    %r14,%rdi
call   1050 <rd_byte@plt>
mov    %eax,%ebp
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11f0 <display_byte+0xc0>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rdx,%r12
test   %r12,%r12
jne    11aa <display_byte+0x7a>
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %bpl,(%rsp,%r12,1)
add    $0x1,%r14
movzbl %bpl,%esi
lea    0xe4b(%rip),%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1210 <display_byte+0xe0>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    116a <display_byte+0x3a>
jmp    1220 <display_byte+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%r12d
test   %r12,%r12
jne    11aa <display_byte+0x7a>
jmp    1199 <display_byte+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    116a <display_byte+0x3a>
mov    $0x20,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
je     1160 <display_byte+0x30>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rsp,%rbp,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r13d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <display_byte+0x110>
jmp    1160 <display_byte+0x30>
mov    %r15,%r14
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1317 <display_byte+0x1e7>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rdx,%r14
test   %r14,%r14
je     132a <display_byte+0x1fa>
sub    %r14,%rbx
lea    (%rbx,%rbx,2),%rbx
test   %rbx,%rbx
je     12b3 <display_byte+0x183>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
ja     12a0 <display_byte+0x170>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r14
mov    $0x1,%ebx
cmovae %r14,%rbx
xor    %ebp,%ebp
mov    $0x2e,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rsp,%rbp,1),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r14d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
jne    12e0 <display_byte+0x1b0>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%r14d
test   %r14,%r14
jne    128b <display_byte+0x15b>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%06lX: \00"
@.str.1 = [7 x i8] c"%02X%c\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @display_byte(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
%9 = alloca [16 x i8]
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
br label %10
10: ; preds = %127, %3
%11 = load i64, i64* %4
%12 = load i64, i64* %5
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %72
14: ; preds = %10
%15 = load i64, i64* %4
%16 = inttoptr i64 %15 to i8*
%17 = call zeroext i8 @rd_byte(i8* %16)
store i8 %17, i8* %8
%18 = load i64, i64* %4
%19 = load i64, i64* %6
%20 = urem i64 %18, %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = load i64, i64* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %22, %14
%26 = load i8, i8* %8
%27 = load i64, i64* %4
%28 = load i64, i64* %6
%29 = urem i64 %27, %28
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %29
store i8 %26, i8* %30
%31 = load i64, i64* %4
%32 = add i64 %31, 1
store i64 %32, i64* %4
%33 = load i8, i8* %8
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 32)
%36 = load i64, i64* %4
%37 = load i64, i64* %6
%38 = urem i64 %36, %37
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %71
40: ; preds = %25
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %42
42: ; preds = %66, %40
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = load i64, i64* %6
%46 = icmp ult i64 %44, %45
br i1 %46, label %47, label %69
47: ; preds = %42
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %49
%51 = load i8, i8* %50
store i8 %51, i8* %8
%52 = load i8, i8* %8
%53 = zext i8 %52 to i32
%54 = icmp sge i32 %53, 32
br i1 %54, label %55, label %62
55: ; preds = %47
%56 = load i8, i8* %8
%57 = zext i8 %56 to i32
%58 = icmp sle i32 %57, 126
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i8, i8* %8
%61 = zext i8 %60 to i32
br label %63
62: ; preds = %55, %47
br label %63
63: ; preds = %62, %59
%64 = phi i32 [ %61, %59 ], [ 46, %62 ]
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %42
69: ; preds = %42
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %69, %25
br label %127
72: ; preds = %10
%73 = load i64, i64* %4
%74 = load i64, i64* %6
%75 = urem i64 %73, %74
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %126
77: ; preds = %72
store i32 0, i32* %7
br label %78
78: ; preds = %90, %77
%79 = load i32, i32* %7
%80 = sext i32 %79 to i64
%81 = load i64, i64* %6
%82 = load i64, i64* %4
%83 = load i64, i64* %6
%84 = urem i64 %82, %83
%85 = sub i64 %81, %84
%86 = mul i64 3, %85
%87 = icmp ult i64 %80, %86
br i1 %87, label %88, label %93
88: ; preds = %78
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %90
90: ; preds = %88
%91 = load i32, i32* %7
%92 = add nsw i32 %91, 1
store i32 %92, i32* %7
br label %78
93: ; preds = %78
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %95
95: ; preds = %121, %93
%96 = load i32, i32* %7
%97 = sext i32 %96 to i64
%98 = load i64, i64* %4
%99 = load i64, i64* %6
%100 = urem i64 %98, %99
%101 = icmp ult i64 %97, %100
br i1 %101, label %102, label %124
102: ; preds = %95
%103 = load i32, i32* %7
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %104
%106 = load i8, i8* %105
store i8 %106, i8* %8
%107 = load i8, i8* %8
%108 = zext i8 %107 to i32
%109 = icmp sge i32 %108, 32
br i1 %109, label %110, label %117
110: ; preds = %102
%111 = load i8, i8* %8
%112 = zext i8 %111 to i32
%113 = icmp sle i32 %112, 126
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load i8, i8* %8
%116 = zext i8 %115 to i32
br label %118
117: ; preds = %110, %102
br label %118
118: ; preds = %117, %114
%119 = phi i32 [ %116, %114 ], [ 46, %117 ]
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %119)
br label %121
121: ; preds = %118
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 1
store i32 %123, i32* %7
br label %95
124: ; preds = %95
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %126
126: ; preds = %124, %72
br label %128
127: ; preds = %71
br label %10
128: ; preds = %126
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%06lX: \00"
@.str.1 = [7 x i8] c"%02X%c\00"
define void @display_byte(i64 %0, i64 %1, i64 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = icmp ult i64 %0, %1
br i1 %6, label %7, label %39
7: ; preds = %3
%8 = icmp eq i64 %2, 0
br label %9
9: ; preds = %7, %68
%10 = phi i64 [ %0, %7 ], [ %19, %68 ]
%11 = inttoptr i64 %10 to i8*
%12 = tail call zeroext i8 @rd_byte(i8* %11)
%13 = urem i64 %10, %2
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %10)
br label %17
17: ; preds = %15, %9
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %13
store i8 %12, i8* %18
%19 = add i64 %10, 1
%20 = zext i8 %12 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 32)
%22 = urem i64 %19, %2
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %68
24: ; preds = %17
%25 = tail call i32 @putchar(i32 32)
br i1 %8, label %37, label %26
26: ; preds = %24, %26
%27 = phi i64 [ %35, %26 ], [ 0, %24 ]
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = add i8 %29, -32
%31 = icmp ult i8 %30, 95
%32 = select i1 %31, i8 %29, i8 46
%33 = zext i8 %32 to i32
%34 = tail call i32 @putchar(i32 %33)
%35 = add nuw i64 %27, 1
%36 = icmp eq i64 %35, %2
br i1 %36, label %37, label %26
37: ; preds = %26, %24
%38 = tail call i32 @putchar(i32 10)
br label %68
39: ; preds = %68, %3
%40 = phi i64 [ %0, %3 ], [ %1, %68 ]
%41 = urem i64 %40, %2
%42 = icmp eq i64 %41, 0
br i1 %42, label %70, label %43
43: ; preds = %39
%44 = sub i64 %2, %41
%45 = mul i64 %44, 3
%46 = icmp eq i64 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %43, %47
%48 = phi i64 [ %50, %47 ], [ 0, %43 ]
%49 = tail call i32 @putchar(i32 32)
%50 = add nuw i64 %48, 1
%51 = icmp ugt i64 %45, %50
br i1 %51, label %47, label %52
52: ; preds = %47, %43
%53 = tail call i32 @putchar(i32 32)
%54 = call i64 @llvm.umax.i64(i64 %41, i64 1)
br label %55
55: ; preds = %52, %55
%56 = phi i64 [ 0, %52 ], [ %64, %55 ]
%57 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = add i8 %58, -32
%60 = icmp ult i8 %59, 95
%61 = select i1 %60, i8 %58, i8 46
%62 = zext i8 %61 to i32
%63 = tail call i32 @putchar(i32 %62)
%64 = add nuw i64 %56, 1
%65 = icmp eq i64 %64, %54
br i1 %65, label %66, label %55
66: ; preds = %55
%67 = tail call i32 @putchar(i32 10)
br label %70
68: ; preds = %17, %37
%69 = icmp eq i64 %19, %1
br i1 %69, label %39, label %9
70: ; preds = %39, %66
ret void
}