#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 */
scalar_t__ isgraph(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void displayHexRecord(char *data, int count, int record_length) {
  int i;
  for (i = 0; i < count; i++)
    printf("%02x ", data[i] & 0xff);
  for (; i < record_length; i++)
    printf("   ");
  printf(": ");
  for (i = 0; i < count; i++) {
    if (isgraph(data[i]))
      putchar(data[i]);
    else
      putchar('.');
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<displayHexRecord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1183 <displayHexRecord+0x53>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <displayHexRecord+0x19>
jmp    1188 <displayHexRecord+0x58>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b0 <displayHexRecord+0x80>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <displayHexRecord+0x58>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121f <displayHexRecord+0xef>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isgraph@plt>
cmp    $0x0,%rax
je     1202 <displayHexRecord+0xd2>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    120c <displayHexRecord+0xdc>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    1211 <displayHexRecord+0xe1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c5 <displayHexRecord+0x95>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayHexRecord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r13
mov    %esi,%r12d
test   %esi,%esi
jle    1182 <displayHexRecord+0x52>
lea    0xeaf(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <displayHexRecord+0x30>
mov    %r14d,%eax
cmp    %ebp,%eax
jl     1188 <displayHexRecord+0x58>
jmp    11af <displayHexRecord+0x7f>
xor    %eax,%eax
cmp    %ebp,%eax
jge    11af <displayHexRecord+0x7f>
sub    %eax,%ebp
lea    0xe75(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    11a0 <displayHexRecord+0x70>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jle    11fb <displayHexRecord+0xcb>
xor    %ebp,%ebp
jmp    11e7 <displayHexRecord+0xb7>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rbp,1),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
je     11fb <displayHexRecord+0xcb>
movsbl 0x0(%r13,%rbp,1),%edi
call   1050 <isgraph@plt>
test   %rax,%rax
jne    11d0 <displayHexRecord+0xa0>
mov    $0x2e,%al
jmp    11d6 <displayHexRecord+0xa6>
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 = [6 x i8] c"%02x \00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [3 x i8] c": \00"
define void @displayHexRecord(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %21, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = and i32 %18, 255
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %12
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %8
24: ; preds = %8
br label %25
25: ; preds = %31, %24
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %25
34: ; preds = %25
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %36
36: ; preds = %58, %34
%37 = load i32, i32* %7
%38 = load i32, i32* %5
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %61
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = call i64 @isgraph(i8 signext %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %40
%49 = load i8*, i8** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = call i32 @putchar(i8 signext %53)
br label %57
55: ; preds = %40
%56 = call i32 @putchar(i8 signext 46)
br label %57
57: ; preds = %55, %48
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %36
61: ; preds = %36
%62 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%02x \00"
@.str.1 = [4 x i8] c" \00"
@.str.2 = [3 x i8] c": \00"
define void @displayHexRecord(i8* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %10
7: ; preds = %10, %3
%8 = phi i32 [ 0, %3 ], [ %1, %10 ]
%9 = icmp slt i32 %8, %2
br i1 %9, label %18, label %23
10: ; preds = %5, %10
%11 = phi i64 [ 0, %5 ], [ %16, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %7, label %10
18: ; preds = %7, %18
%19 = phi i32 [ %21, %18 ], [ %8, %7 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = add nuw i32 %19, 1
%22 = icmp eq i32 %21, %2
br i1 %22, label %23, label %18
23: ; preds = %18, %7
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br i1 %4, label %25, label %40
25: ; preds = %23
%26 = zext i32 %1 to i64
br label %27
27: ; preds = %25, %35
%28 = phi i64 [ 0, %25 ], [ %38, %35 ]
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = load i8, i8* %29
%31 = tail call i64 @isgraph(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %27
%34 = load i8, i8* %29
br label %35
35: ; preds = %27, %33
%36 = phi i8 [ %34, %33 ], [ 46, %27 ]
%37 = tail call i32 @putchar(i8 signext %36)
%38 = add nuw nsw i64 %28, 1
%39 = icmp eq i64 %38, %26
br i1 %39, label %40, label %27
40: ; preds = %35, %23
%41 = tail call i32 @putchar(i8 signext 10)
ret void
}