#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 *, ...);
void dump_buffer(char *buffer, size_t size, const char *page_marker) {
  size_t i;
  for (i = 0; i < size; ++i) {
    if (i % 30 == 0)
      printf("\n");
    if (i % (1 << 12) == 0)
      printf("[%s]", page_marker);
    printf("%c ", buffer[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b1 <dump_buffer+0xa1>
mov    -0x20(%rbp),%rax
mov    $0x1e,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    1160 <dump_buffer+0x50>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
and    $0xfff,%rax
cmp    $0x0,%rax
jne    1186 <dump_buffer+0x76>
mov    -0x18(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <dump_buffer+0x1c>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11c3 <dump_buffer+0xa3>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movabs $0x8888888888888889,%r12
88 88 88
lea    0xeb7(%rip),%r13
xor    %ebp,%ebp
jmp    1180 <dump_buffer+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   $0xfff,%ebp
je     11b0 <dump_buffer+0x90>
movsbl (%r15,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11c3 <dump_buffer+0xa3>
mov    %rbp,%rax
mul    %r12
shr    $0x4,%rdx
mov    %rdx,%rax
shl    $0x5,%rax
sub    %rdx,%rax
sub    %rdx,%rax
cmp    %rbp,%rax
jne    1160 <dump_buffer+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1160 <dump_buffer+0x40>
nopl   0x0(%rax,%rax,1)
lea    0xe49(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <dump_buffer+0x48>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [5 x i8] c"[%s]\00"
@.str.2 = [4 x i8] c"%c \00"
define void @dump_buffer(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
store i64 0, i64* %7
br label %8
8: ; preds = %32, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = load i64, i64* %7
%14 = urem i64 %13, 30
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = load i64, i64* %7
%20 = urem i64 %19, 4096
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %18
%26 = load i8*, i8** %4
%27 = load i64, i64* %7
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25
%33 = load i64, i64* %7
%34 = add i64 %33, 1
store i64 %34, i64* %7
br label %8
35: ; preds = %8
%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 = [5 x i8] c"[%s]\00"
@.str.2 = [4 x i8] c"%c \00"
define void @dump_buffer(i8* nocapture %0, i64 %1, i8* %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %23, label %5
5: ; preds = %3, %16
%6 = phi i64 [ %21, %16 ], [ 0, %3 ]
%7 = urem i64 %6, 30
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @putchar(i32 10)
br label %11
11: ; preds = %9, %5
%12 = and i64 %6, 4095
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %16
16: ; preds = %14, %11
%17 = getelementptr inbounds i8, i8* %0, i64 %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = add nuw i64 %6, 1
%22 = icmp eq i64 %21, %1
br i1 %22, label %23, label %5
23: ; preds = %16, %3
%24 = tail call i32 @putchar(i32 10)
ret void
}