#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
scalar_t__ isprint(char);
int /*<<< orphan*/ printf(char *, ...);
void print_raw(char *b, uint64_t size) {
  uint32_t i, j, z;
  j = 0;
  do {
    for (i = 0; i < 16 && i + j < size; i++) {
      if (i == 8) {
        printf("  ");
      }
      printf("%02hhx ", b[j + i]);
    }
    printf("   ");
    if (i < 16) {
      z = (16 - i) * 3;
      if (i <= 8)
        z += 2;
      printf("%*c", z, ' ');
    }
    for (i = 0; i < 16 && i + j < size; i++) {
      if (i == 8) {
        printf("  ");
      }
      printf("%c ", isprint(b[j + i]) ? b[j + i] : '.');
    }
    printf("\n");
    j += i;
  } while (j < size);
}


x86 assembly (clang, -O0):
<print_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x10(%rbp)
mov    %al,-0x19(%rbp)
jge    115b <print_raw+0x3b>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    116b <print_raw+0x4b>
jmp    11b0 <print_raw+0x90>
cmpl   $0x8,-0x10(%rbp)
jne    1183 <print_raw+0x63>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <print_raw+0x1d>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x10,-0x10(%rbp)
jge    11ff <print_raw+0xdf>
mov    $0x10,%eax
sub    -0x10(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x8,-0x10(%rbp)
jg     11e9 <print_raw+0xc9>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x20,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x10(%rbp)
mov    %al,-0x1a(%rbp)
jge    1224 <print_raw+0x104>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1234 <print_raw+0x114>
jmp    12b1 <print_raw+0x191>
cmpl   $0x8,-0x10(%rbp)
jne    124c <print_raw+0x12c>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1285 <print_raw+0x165>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
jmp    1292 <print_raw+0x172>
mov    $0x2e,%eax
mov    %eax,-0x20(%rbp)
jmp    1292 <print_raw+0x172>
mov    -0x20(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1206 <print_raw+0xe6>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1136 <print_raw+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
lea    0xeb6(%rip),%r12
xor    %r15d,%r15d
mov    %esi,0x8(%rsp)
jmp    1180 <print_raw+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%eax
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %ebx,%r15d
mov    0x8(%rsp),%esi
cmp    %esi,%r15d
jge    12b7 <print_raw+0x187>
mov    %r15d,%eax
cmp    %esi,%r15d
mov    %esi,%r14d
cmovg  %r15d,%r14d
sub    %r15d,%r14d
mov    %r15d,%r15d
mov    0x10(%rsp),%rax
lea    (%rax,%r15,1),%r13
xor    %ebx,%ebx
jmp    11ba <print_raw+0x8a>
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1220 <print_raw+0xf0>
cmp    %rbx,%r14
je     11e0 <print_raw+0xb0>
cmp    $0x8,%rbx
jne    11a0 <print_raw+0x70>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <print_raw+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x10,%eax
sub    %r14d,%eax
lea    (%rax,%rax,2),%ecx
cmp    $0x9,%r14d
lea    0x2(%rax,%rax,2),%esi
cmovae %ecx,%esi
lea    0xe01(%rip),%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122e <print_raw+0xfe>
nopl   0x0(%rax)
lea    0xde1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xf,%r14d
mov    $0xf,%ebx
cmovb  %r14d,%ebx
lea    0x1(%rbx),%eax
mov    %eax,0xc(%rsp)
xor    %ebp,%ebp
jmp    1282 <print_raw+0x152>
cs nopw 0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbp,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     12b0 <print_raw+0x180>
movsbl 0x0(%r13,%rbp,1),%esi
lea    0xda3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1160 <print_raw+0x30>
cmp    %rbp,%r14
je     1166 <print_raw+0x36>
cmp    $0x8,%rbp
jne    1250 <print_raw+0x120>
lea    0xd71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1250 <print_raw+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2e,%esi
jmp    1266 <print_raw+0x136>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" \00"
@.str.1 = [8 x i8] c"%02hhx \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [4 x i8] c"%*c\00"
@.str.4 = [4 x i8] c"%c \00"
define void @print_raw(i8* nocapture %0, i32 %1) {
br label %3
3: ; preds = %58, %2
%4 = phi i32 [ 0, %2 ], [ %61, %58 ]
%5 = zext i32 %4 to i64
%6 = call i32 @llvm.smax.i32(i32 %4, i32 %1)
%7 = sub i32 %6, %4
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %3, %17
%10 = phi i64 [ 0, %3 ], [ %22, %17 ]
%11 = add nuw nsw i64 %10, %5
%12 = icmp eq i64 %10, %8
br i1 %12, label %24, label %13
13: ; preds = %9
%14 = icmp eq i64 %10, 8
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = getelementptr inbounds i8, i8* %0, i64 %11
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, 16
br i1 %23, label %32, label %9
24: ; preds = %9
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = sub nuw nsw i32 16, %7
%27 = mul nuw nsw i32 %26, 3
%28 = icmp ult i32 %7, 9
%29 = add nuw nsw i32 %27, 2
%30 = select i1 %28, i32 %29, i32 %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 32)
br label %34
32: ; preds = %17
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %24
%35 = call i32 @llvm.umin.i32(i32 %7, i32 15)
%36 = add nuw nsw i32 %35, 1
br label %37
37: ; preds = %34, %53
%38 = phi i64 [ 0, %34 ], [ %56, %53 ]
%39 = add nuw nsw i64 %38, %5
%40 = icmp eq i64 %38, %8
br i1 %40, label %58, label %41
41: ; preds = %37
%42 = icmp eq i64 %38, 8
br i1 %42, label %43, label %45
43: ; preds = %41
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = getelementptr inbounds i8, i8* %0, i64 %39
%47 = load i8, i8* %46
%48 = tail call i64 @isprint(i8 signext %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %45
%51 = load i8, i8* %46
%52 = sext i8 %51 to i32
br label %53
53: ; preds = %45, %50
%54 = phi i32 [ %52, %50 ], [ 46, %45 ]
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = add nuw nsw i64 %38, 1
%57 = icmp eq i64 %56, 16
br i1 %57, label %58, label %37
58: ; preds = %53, %37
%59 = phi i32 [ %36, %53 ], [ %35, %37 ]
%60 = tail call i32 @putchar(i32 10)
%61 = add nuw nsw i32 %59, %4
%62 = icmp slt i32 %61, %1
br i1 %62, label %3, label %63
63: ; preds = %58
ret void
}