#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isprint(char);
void dump_line(FILE *out, const char *addr, const long len) {
  int i;
  fprintf(out, "|");
  for (i = 0; i < 16; i++) {
    if (i < len) {
      fprintf(out, " %02X", ((unsigned char *)addr)[i]);
    } else {
      fprintf(out, " ..");
    }
    if (!((i + 1) % 8)) {
      fprintf(out, " |");
    }
  }
  fprintf(out, "\t");
  for (i = 0; i < 16; i++) {
    char c = 0x7f & ((unsigned char *)addr)[i];
    if (i < len && isprint(c)) {
      fprintf(out, "%c", c);
    } else {
      fprintf(out, ".");
    }
  }
}


x86 assembly (clang, -O0):
<dump_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11d6 <dump_line+0xb6>
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1188 <dump_line+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    119a <dump_line+0x7a>
mov    -0x8(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c3 <dump_line+0xa3>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c8 <dump_line+0xa8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <dump_line+0x2d>
mov    -0x8(%rbp),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    126c <dump_line+0x14c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x7f,%eax
mov    %al,-0x1d(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1247 <dump_line+0x127>
movsbl -0x1d(%rbp),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1247 <dump_line+0x127>
mov    -0x8(%rbp),%rdi
movsbl -0x1d(%rbp),%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1259 <dump_line+0x139>
mov    -0x8(%rbp),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    125e <dump_line+0x13e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ef <dump_line+0xcf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x7c,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
lea    0xe98(%rip),%rbx
lea    0xe97(%rip),%rbp
xor    %r13d,%r13d
jmp    1186 <dump_line+0x46>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x10,%r13
je     11da <dump_line+0x9a>
cmp    %r15,%r13
jge    11a0 <dump_line+0x60>
movzbl (%r14,%r13,1),%edx
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11b5 <dump_line+0x75>
nop
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r12,%rcx
call   1060 <fwrite@plt>
add    $0x1,%r13
test   $0x7,%r13b
jne    1180 <dump_line+0x40>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe3a(%rip),%rdi
mov    %r12,%rcx
call   1060 <fwrite@plt>
jmp    1180 <dump_line+0x40>
mov    $0x9,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
xor    %ebp,%ebp
jmp    1202 <dump_line+0xc2>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     122a <dump_line+0xea>
mov    $0x2e,%edi
cmp    %r15,%rbp
jge    11f0 <dump_line+0xb0>
movzbl (%r14,%rbp,1),%ebx
and    $0x7f,%ebx
movzbl %bl,%edi
call   1050 <isprint@plt>
mov    $0x2e,%edi
test   %rax,%rax
je     11f0 <dump_line+0xb0>
mov    %ebx,%edi
jmp    11f0 <dump_line+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@.str.1 = [6 x i8] c" %02X\00"
@.str.2 = [4 x i8] c" ..\00"
@.str.3 = [3 x i8] c" |\00"
@.str.4 = [2 x i8] c"\09\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [2 x i8] c".\00"
define void @dump_line(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i32*, i32** %4
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %11
11: ; preds = %40, %3
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = load i64, i64* %6
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = load i32*, i32** %4
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %31
28: ; preds = %14
%29 = load i32*, i32** %4
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %28, %19
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
%34 = srem i32 %33, 8
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %31
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %36, %31
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %11
43: ; preds = %11
%44 = load i32*, i32** %4
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %46
46: ; preds = %75, %43
%47 = load i32, i32* %7
%48 = icmp slt i32 %47, 16
br i1 %48, label %49, label %78
49: ; preds = %46
%50 = load i8*, i8** %5
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = and i32 127, %55
%57 = trunc i32 %56 to i8
store i8 %57, i8* %8
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = load i64, i64* %6
%61 = icmp slt i64 %59, %60
br i1 %61, label %62, label %71
62: ; preds = %49
%63 = load i8, i8* %8
%64 = call i64 @isprint(i8 signext %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %62
%67 = load i32*, i32** %4
%68 = load i8, i8* %8
%69 = sext i8 %68 to i32
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %74
71: ; preds = %62, %49
%72 = load i32*, i32** %4
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %74
74: ; preds = %71, %66
br label %75
75: ; preds = %74
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %46
78: ; preds = %46
ret void
}

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