#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*/ fprintf(int /*<<< orphan*/, char const *, ...);
scalar_t__ isprint(unsigned char const);
int /*<<< orphan*/ stdout;
void printBlob(const unsigned char *aData, int nData) {
  int i, j;
  const char *zOfstFmt;
  const int perLine = 16;
  if ((nData & ~0xfff) == 0) {
    zOfstFmt = " %03x: ";
  } else if ((nData & ~0xffff) == 0) {
    zOfstFmt = " %04x: ";
  } else if ((nData & ~0xfffff) == 0) {
    zOfstFmt = " %05x: ";
  } else if ((nData & ~0xffffff) == 0) {
    zOfstFmt = " %06x: ";
  } else {
    zOfstFmt = " %08x: ";
  }
  for (i = 0; i < nData; i += perLine) {
    fprintf(stdout, zOfstFmt, i);
    for (j = 0; j < perLine; j++) {
      if (i + j > nData) {
        fprintf(stdout, "   ");
      } else {
        fprintf(stdout, "%02x ", aData[i + j]);
      }
    }
    for (j = 0; j < perLine; j++) {
      if (i + j > nData) {
        fprintf(stdout, " ");
      } else {
        fprintf(stdout, "%c", isprint(aData[i + j]) ? aData[i + j] : '.');
      }
    }
    fprintf(stdout, "\n");
  }
}


x86 assembly (clang, -O0):
<printBlob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x10,-0x24(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfffff000,%eax
cmp    $0x0,%eax
jne    1157 <printBlob+0x37>
lea    0xeb2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d4 <printBlob+0xb4>
mov    -0xc(%rbp),%eax
and    $0xffff0000,%eax
cmp    $0x0,%eax
jne    1178 <printBlob+0x58>
lea    0xe99(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11cf <printBlob+0xaf>
mov    -0xc(%rbp),%eax
and    $0xfff00000,%eax
cmp    $0x0,%eax
jne    1199 <printBlob+0x79>
lea    0xe80(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ca <printBlob+0xaa>
mov    -0xc(%rbp),%eax
and    $0xff000000,%eax
cmp    $0x0,%eax
jne    11ba <printBlob+0x9a>
lea    0xe67(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c5 <printBlob+0xa5>
lea    0xe5f(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ca <printBlob+0xaa>
jmp    11cf <printBlob+0xaf>
jmp    11d4 <printBlob+0xb4>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    134f <printBlob+0x22f>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1275 <printBlob+0x155>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    123a <printBlob+0x11a>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1262 <printBlob+0x142>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1267 <printBlob+0x147>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1205 <printBlob+0xe5>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    132a <printBlob+0x20a>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    12b1 <printBlob+0x191>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1317 <printBlob+0x1f7>
mov    0x2d28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     12f6 <printBlob+0x1d6>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
jmp    1303 <printBlob+0x1e3>
mov    $0x2e,%eax
mov    %eax,-0x2c(%rbp)
jmp    1303 <printBlob+0x1e3>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%edx
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    131c <printBlob+0x1fc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    127c <printBlob+0x15c>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    11db <printBlob+0xbb>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBlob>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
cmp    $0x1000,%esi
jae    114d <printBlob+0x2d>
lea    0xec0(%rip),%rax
mov    %rax,(%rsp)
test   %esi,%esi
jg     119b <printBlob+0x7b>
jmp    12a7 <printBlob+0x187>
cmp    $0x10000,%esi
jae    1162 <printBlob+0x42>
lea    0xeac(%rip),%rax
mov    %rax,(%rsp)
jmp    119b <printBlob+0x7b>
cmp    $0x100000,%esi
jae    1177 <printBlob+0x57>
lea    0xe9f(%rip),%rax
mov    %rax,(%rsp)
jmp    119b <printBlob+0x7b>
cmp    $0x1000000,%esi
lea    0xe94(%rip),%rax
lea    0xe95(%rip),%rcx
cmovb  %rax,%rcx
mov    %rcx,(%rsp)
test   %esi,%esi
jle    12a7 <printBlob+0x187>
mov    %esi,%r13d
mov    0x2e3b(%rip),%rbp
xor    %r15d,%r15d
mov    %esi,0xc(%rsp)
jmp    11db <printBlob+0xbb>
xchg   %ax,%ax
mov    0x0(%rbp),%edi
lea    0xe7b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x10,%r15
mov    0x10(%rsp),%r14
add    $0x10,%r14
mov    0xc(%rsp),%esi
cmp    %esi,%r15d
jge    12a7 <printBlob+0x187>
mov    0x0(%rbp),%edi
mov    (%rsp),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %ebx,%ebx
jmp    120d <printBlob+0xed>
movzbl (%r14,%rbx,1),%edx
lea    0xe30(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1230 <printBlob+0x110>
lea    (%r15,%rbx,1),%rax
mov    0x0(%rbp),%edi
cmp    %r13,%rax
jle    11f0 <printBlob+0xd0>
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1203 <printBlob+0xe3>
nopl   0x0(%rax)
mov    %r14,0x10(%rsp)
xor    %r14d,%r14d
jmp    1262 <printBlob+0x142>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%edi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rbp
add    $0x1,%r14
cmp    $0x10,%r14
je     11b0 <printBlob+0x90>
lea    (%r15,%r14,1),%rax
mov    %rbp,%rbx
mov    0x0(%rbp),%r12d
cmp    %r13,%rax
jg     1240 <printBlob+0x120>
mov    0x10(%rsp),%rbp
movzbl 0x0(%rbp,%r14,1),%edi
call   1040 <isprint@plt>
test   %rax,%rax
je     128f <printBlob+0x16f>
movzbl 0x0(%rbp,%r14,1),%edx
jmp    1294 <printBlob+0x174>
mov    $0x2e,%edx
mov    %r12d,%edi
lea    0xd94(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1251 <printBlob+0x131>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c" %03x: \00"
@.str.1 = [8 x i8] c" %04x: \00"
@.str.2 = [8 x i8] c" %05x: \00"
@.str.3 = [8 x i8] c" %06x: \00"
@.str.4 = [8 x i8] c" %08x: \00"
@stdout = global i32 0
@.str.5 = [4 x i8] c" \00"
@.str.6 = [6 x i8] c"%02x \00"
@.str.7 = [2 x i8] c" \00"
@.str.8 = [3 x i8] c"%c\00"
@.str.9 = [2 x i8] c"\0A\00"
define void @printBlob(i8* nocapture %0, i32 %1) {
%3 = icmp ult i32 %1, 4096
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp ult i32 %1, 65536
br i1 %5, label %14, label %6
6: ; preds = %4
%7 = icmp ult i32 %1, 1048576
br i1 %7, label %14, label %8
8: ; preds = %6
%9 = icmp ult i32 %1, 16777216
%10 = select i1 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
br label %11
11: ; preds = %8, %2
%12 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ], [ %10, %8 ]
%13 = icmp sgt i32 %1, 0
br i1 %13, label %14, label %64
14: ; preds = %4, %6, %11
%15 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ]
%16 = zext i32 %1 to i64
br label %17
17: ; preds = %14, %58
%18 = phi i64 [ 0, %14 ], [ %61, %58 ]
%19 = load i32, i32* @stdout
%20 = trunc i64 %18 to i32
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* %15, i32 %20)
br label %22
22: ; preds = %17, %34
%23 = phi i64 [ 0, %17 ], [ %35, %34 ]
%24 = add nuw nsw i64 %23, %18
%25 = icmp sgt i64 %24, %16
%26 = load i32, i32* @stdout
br i1 %25, label %27, label %29
27: ; preds = %22
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %34
29: ; preds = %22
%30 = getelementptr inbounds i8, i8* %0, i64 %24
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27, %29
%35 = add nuw nsw i64 %23, 1
%36 = icmp eq i64 %35, 16
br i1 %36, label %37, label %22
37: ; preds = %34, %55
%38 = phi i64 [ %56, %55 ], [ 0, %34 ]
%39 = add nuw nsw i64 %38, %18
%40 = icmp sgt i64 %39, %16
%41 = load i32, i32* @stdout
br i1 %40, label %42, label %44
42: ; preds = %37
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %55
44: ; preds = %37
%45 = getelementptr inbounds i8, i8* %0, i64 %39
%46 = load i8, i8* %45
%47 = tail call i64 @isprint(i8 zeroext %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %44
%50 = load i8, i8* %45
%51 = zext i8 %50 to i32
br label %52
52: ; preds = %44, %49
%53 = phi i32 [ %51, %49 ], [ 46, %44 ]
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %42, %52
%56 = add nuw nsw i64 %38, 1
%57 = icmp eq i64 %56, 16
br i1 %57, label %58, label %37
58: ; preds = %55
%59 = load i32, i32* @stdout
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%61 = add nuw i64 %18, 16
%62 = trunc i64 %61 to i32
%63 = icmp slt i32 %62, %1
br i1 %63, label %17, label %64
64: ; preds = %58, %11
ret void
}