#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_char(unsigned long start, unsigned long endaddr,
                  unsigned long width) {
  unsigned char r;
  for (; (start < endaddr); start++) {
    r = rd_byte((unsigned char *)start);
    if ((start % width) == 0)
      printf("\n%06lX: ", start);
    printf("%c", ((r >= 0x20) && (r <= 0x7E)) ? r : '.');
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<display_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11cb <display_char+0xab>
mov    -0x8(%rbp),%rdi
call   1040 <rd_byte@plt>
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1176 <display_char+0x56>
mov    -0x8(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jl     119c <display_char+0x7c>
movzbl -0x19(%rbp),%eax
cmp    $0x7e,%eax
jg     119c <display_char+0x7c>
movzbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <display_char+0x89>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <display_char+0x89>
mov    -0x20(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <display_char+0x14>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %rsi,%rdi
jae    11cb <display_char+0x9b>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeac(%rip),%r12
mov    $0x2e,%ebp
jmp    117e <display_char+0x4e>
nopl   0x0(%rax,%rax,1)
lea    -0x20(%r13),%eax
cmp    $0x5f,%al
movzbl %r13b,%eax
cmovae %ebp,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     11cb <display_char+0x9b>
mov    %rbx,%rdi
call   1050 <rd_byte@plt>
mov    %eax,%r13d
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     11b0 <display_char+0x80>
mov    %rbx,%rax
xor    %edx,%edx
div    %r15
test   %rdx,%rdx
jne    1160 <display_char+0x30>
jmp    11bc <display_char+0x8c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
test   %rdx,%rdx
jne    1160 <display_char+0x30>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <display_char+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"\0A%06lX: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @display_char(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
br label %8
8: ; preds = %38, %3
%9 = load i64, i64* %4
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %41
12: ; preds = %8
%13 = load i64, i64* %4
%14 = inttoptr i64 %13 to i8*
%15 = call zeroext i8 @rd_byte(i8* %14)
store i8 %15, i8* %7
%16 = load i64, i64* %4
%17 = load i64, i64* %6
%18 = urem i64 %16, %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i64, i64* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %21)
br label %23
23: ; preds = %20, %12
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = icmp sge i32 %25, 32
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i8, i8* %7
%29 = zext i8 %28 to i32
%30 = icmp sle i32 %29, 126
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8, i8* %7
%33 = zext i8 %32 to i32
br label %35
34: ; preds = %27, %23
br label %35
35: ; preds = %34, %31
%36 = phi i32 [ %33, %31 ], [ 46, %34 ]
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35
%39 = load i64, i64* %4
%40 = add i64 %39, 1
store i64 %40, i64* %4
br label %8
41: ; preds = %8
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"\0A%06lX: \00"
define void @display_char(i64 %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %0, %1
br i1 %4, label %5, label %21
5: ; preds = %3, %13
%6 = phi i64 [ %19, %13 ], [ %0, %3 ]
%7 = inttoptr i64 %6 to i8*
%8 = tail call zeroext i8 @rd_byte(i8* %7)
%9 = urem i64 %6, %2
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %6)
br label %13
13: ; preds = %11, %5
%14 = add i8 %8, -32
%15 = icmp ult i8 %14, 95
%16 = select i1 %15, i8 %8, i8 46
%17 = zext i8 %16 to i32
%18 = tail call i32 @putchar(i32 %17)
%19 = add i64 %6, 1
%20 = icmp eq i64 %19, %1
br i1 %20, label %21, label %5
21: ; preds = %13, %3
%22 = tail call i32 @putchar(i32 10)
ret void
}