#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*/ printf(char *, char const *, char const, ...);
void print_mem(const void *src, size_t n) {
  size_t i;
  const char *mem;
  i = 0;
  mem = src;
  while (i < n) {
    if (mem[i] > 32 && mem[i] < 126)
      printf("%p   %8u		%c\n", &mem[i], mem[i], mem[i]);
    else {
      if (mem[i] == '\0')
        printf("%p   %8u		\\0\n", &mem[i], mem[i]);
      else
        printf("%p   %8u		.\n", &mem[i], mem[i]);
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<print_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1211 <print_mem+0x101>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jle    119d <print_mem+0x8d>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jge    119d <print_mem+0x8d>
mov    -0x20(%rbp),%rsi
add    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
lea    0xe72(%rip),%rdi
movsbl %al,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <print_mem+0xf0>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11d9 <print_mem+0xc9>
mov    -0x20(%rbp),%rsi
add    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
lea    0xe45(%rip),%rdi
movsbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <print_mem+0xeb>
mov    -0x20(%rbp),%rsi
add    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
lea    0xe2c(%rip),%rdi
movsbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <print_mem+0xf0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1130 <print_mem+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mem>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
je     1184 <print_mem+0x74>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xed5(%rip),%r15
lea    0xedc(%rip),%r12
lea    0xee3(%rip),%r13
jmp    115a <print_mem+0x4a>
nopl   0x0(%rax,%rax,1)
movsbl %cl,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%r14
je     1184 <print_mem+0x74>
movzbl (%rbx),%ecx
lea    -0x21(%rcx),%eax
cmp    $0x5c,%al
jbe    1140 <print_mem+0x30>
test   %ecx,%ecx
je     1173 <print_mem+0x63>
movsbl %cl,%edx
mov    %r13,%rdi
mov    %rbx,%rsi
jmp    117b <print_mem+0x6b>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <print_mem+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%p %8u\09\09%c\0A\00"
@.str.1 = [14 x i8] c"%p %8u\09\09\\0\0A\00"
@.str.2 = [13 x i8] c"%p %8u\09\09.\0A\00"
define void @print_mem(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
%7 = load i8*, i8** %3
store i8* %7, i8** %6
br label %8
8: ; preds = %66, %2
%9 = load i64, i64* %5
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %69
12: ; preds = %8
%13 = load i8*, i8** %6
%14 = load i64, i64* %5
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp sgt i32 %17, 32
br i1 %18, label %19, label %40
19: ; preds = %12
%20 = load i8*, i8** %6
%21 = load i64, i64* %5
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp slt i32 %24, 126
br i1 %25, label %26, label %40
26: ; preds = %19
%27 = load i8*, i8** %6
%28 = load i64, i64* %5
%29 = getelementptr inbounds i8, i8* %27, i64 %28
%30 = load i8*, i8** %6
%31 = load i64, i64* %5
%32 = getelementptr inbounds i8, i8* %30, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %6
%35 = load i64, i64* %5
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %29, i8 signext %33, i32 %38)
br label %66
40: ; preds = %19, %12
%41 = load i8*, i8** %6
%42 = load i64, i64* %5
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %56
47: ; preds = %40
%48 = load i8*, i8** %6
%49 = load i64, i64* %5
%50 = getelementptr inbounds i8, i8* %48, i64 %49
%51 = load i8*, i8** %6
%52 = load i64, i64* %5
%53 = getelementptr inbounds i8, i8* %51, i64 %52
%54 = load i8, i8* %53
%55 = call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %50, i8 signext %54)
br label %65
56: ; preds = %40
%57 = load i8*, i8** %6
%58 = load i64, i64* %5
%59 = getelementptr inbounds i8, i8* %57, i64 %58
%60 = load i8*, i8** %6
%61 = load i64, i64* %5
%62 = getelementptr inbounds i8, i8* %60, i64 %61
%63 = load i8, i8* %62
%64 = call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %59, i8 signext %63)
br label %65
65: ; preds = %56, %47
br label %66
66: ; preds = %65, %26
%67 = load i64, i64* %5
%68 = add i64 %67, 1
store i64 %68, i64* %5
br label %8
69: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%p %8u\09\09%c\0A\00"
@.str.1 = [14 x i8] c"%p %8u\09\09\\0\0A\00"
@.str.2 = [13 x i8] c"%p %8u\09\09.\0A\00"
define void @print_mem(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %22, label %4
4: ; preds = %2, %19
%5 = phi i64 [ %20, %19 ], [ 0, %2 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = add i8 %7, -33
%9 = icmp ult i8 %8, 93
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = zext i8 %7 to i32
%12 = tail call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %6, i8 signext %7, i32 %11)
br label %19
13: ; preds = %4
%14 = icmp eq i8 %7, 0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8 signext 0)
br label %19
17: ; preds = %13
%18 = tail call i32 (i8*, i8*, i8, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8 signext %7)
br label %19
19: ; preds = %15, %17, %10
%20 = add nuw i64 %5, 1
%21 = icmp eq i64 %20, %1
br i1 %21, label %22, label %4
22: ; preds = %19, %2
ret void
}