#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
void sans_dump(void *buf, size_t len) {
  for (size_t i = 0; i < len; i++) {
    printf("%02x ", *(uint8_t *)(buf + i));
    if (i % 16 == 15) {
      putchar('\n');
    }
  }
  if (len % 16 != 0) {
    putchar('\n');
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<sans_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119f <sans_dump+0x6f>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%esi
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0xf,%rax
jne    1189 <sans_dump+0x59>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    118e <sans_dump+0x5e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1148 <sans_dump+0x18>
mov    -0x10(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
je     11bb <sans_dump+0x8b>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sans_dump>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1189 <sans_dump+0x59>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0xeb4(%rip),%r15
jmp    1159 <sans_dump+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     1179 <sans_dump+0x49>
mov    (%r14,%rbx,1),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1150 <sans_dump+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <sans_dump+0x20>
test   $0xf,%r12b
je     1189 <sans_dump+0x59>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%02x \00"
@stdout = global i32 0
define void @sans_dump(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %23, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i64, i64* %5
%13 = getelementptr i8, i8* %11, i64 %12
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i64, i64* %5
%18 = urem i64 %17, 16
%19 = icmp eq i64 %18, 15
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 @putchar(i8 signext 10)
br label %22
22: ; preds = %20, %10
br label %23
23: ; preds = %22
%24 = load i64, i64* %5
%25 = add i64 %24, 1
store i64 %25, i64* %5
br label %6
26: ; preds = %6
%27 = load i64, i64* %4
%28 = urem i64 %27, 16
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @putchar(i8 signext 10)
br label %32
32: ; preds = %30, %26
%33 = load i32, i32* @stdout
%34 = call i32 @fflush(i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%02x \00"
@stdout = global i32 0
define void @sans_dump(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %22, label %7
4: ; preds = %17
%5 = and i64 %1, 15
%6 = icmp eq i64 %5, 0
br i1 %6, label %22, label %20
7: ; preds = %2, %17
%8 = phi i64 [ %18, %17 ], [ 0, %2 ]
%9 = getelementptr i8, i8* %0, i64 %8
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = and i64 %8, 15
%14 = icmp eq i64 %13, 15
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 @putchar(i8 signext 10)
br label %17
17: ; preds = %7, %15
%18 = add nuw i64 %8, 1
%19 = icmp eq i64 %18, %1
br i1 %19, label %4, label %7
20: ; preds = %4
%21 = tail call i32 @putchar(i8 signext 10)
br label %22
22: ; preds = %2, %20, %4
%23 = load i32, i32* @stdout
%24 = tail call i32 @fflush(i32 %23)
ret void
}