#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__ isprint(unsigned char const);
int /*<<< orphan*/ printf(char *, ...);
void dump(const char *str) {
  const unsigned char *ptr = (const unsigned char *)str;
  int n = 0;
  while (*ptr) {
    if (n >= 16) {
      printf("\n");
      n = 0;
    }
    printf(" %.2x(%c)", (int)*ptr, (isprint(*ptr) ? *ptr : ' '));
    ptr++;
    n++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d1 <dump+0xb1>
cmpl   $0x10,-0x14(%rbp)
jl     1167 <dump+0x47>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1196 <dump+0x76>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <dump+0x83>
mov    $0x20,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a3 <dump+0x83>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <dump+0x1b>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11a7 <dump+0x77>
mov    %rdi,%rbx
lea    0xeb9(%rip),%r14
xor    %ebp,%ebp
jmp    1180 <dump+0x50>
nopl   0x0(%rax,%rax,1)
movzbl %al,%r15d
mov    %r15d,%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     11a0 <dump+0x70>
movzbl (%rbx),%edx
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11a7 <dump+0x77>
cmp    $0x10,%ebp
jl     1150 <dump+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
xor    %ebp,%ebp
jmp    1150 <dump+0x20>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edx
jmp    1164 <dump+0x34>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [10 x i8] c" %.2x(%c)\00"
define void @dump(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %1, %21
%5 = phi i8 [ %26, %21 ], [ %2, %1 ]
%6 = phi i32 [ %25, %21 ], [ 0, %1 ]
%7 = phi i8* [ %24, %21 ], [ %0, %1 ]
%8 = icmp sgt i32 %6, 15
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @putchar(i32 10)
%11 = load i8, i8* %7
br label %12
12: ; preds = %9, %4
%13 = phi i8 [ %11, %9 ], [ %5, %4 ]
%14 = phi i32 [ 0, %9 ], [ %6, %4 ]
%15 = zext i8 %13 to i32
%16 = tail call i64 @isprint(i8 zeroext %13)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
br label %21
21: ; preds = %12, %18
%22 = phi i32 [ %20, %18 ], [ 32, %12 ]
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %22)
%24 = getelementptr inbounds i8, i8* %7, i64 1
%25 = add nsw i32 %14, 1
%26 = load i8, i8* %24
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %4
28: ; preds = %21, %1
%29 = tail call i32 @putchar(i32 10)
ret void
}