#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*/ _printk(char *, ...);
void _dump_buf_with_offset(unsigned char *p, int s, unsigned char *base) {
  int i, c;
  if ((unsigned int)s > (unsigned int)p) {
    s = (unsigned int)s - (unsigned int)p;
  }
  while (s > 0) {
    if (base) {
      _printk("%06X: ", (int)p - (int)base);
    } else {
      _printk("%06X: ", p);
    }
    for (i = 0; i < 16; i++) {
      if (i < s) {
        _printk("%02X", p[i] & 0xFF);
      } else {
        _printk("  ");
      }
      if ((i % 2) == 1)
        _printk(" ");
      if ((i % 8) == 7)
        _printk(" ");
    }
    _printk(" |");
    for (i = 0; i < 16; i++) {
      if (i < s) {
        c = p[i] & 0xFF;
        if ((c < 0x20) || (c >= 0x7F))
          c = '.';
      } else {
        c = ' ';
      }
      _printk("%c", c);
    }
    _printk("|\n");
    s -= 16;
    p += 16;
  }
}


x86 assembly (clang, -O0):
<_dump_buf_with_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    %ecx,%eax
jbe    113e <_dump_buf_with_offset+0x2e>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <_dump_buf_with_offset+0x33>
cmpl   $0x0,-0xc(%rbp)
jle    12dd <_dump_buf_with_offset+0x1cd>
cmpq   $0x0,-0x18(%rbp)
je     1177 <_dump_buf_with_offset+0x67>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rax
sub    %eax,%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
jmp    1189 <_dump_buf_with_offset+0x79>
mov    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    1230 <_dump_buf_with_offset+0x120>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cb <_dump_buf_with_offset+0xbb>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
jmp    11d9 <_dump_buf_with_offset+0xc9>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11fb <_dump_buf_with_offset+0xeb>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x7,%edx
jne    121d <_dump_buf_with_offset+0x10d>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
jmp    1222 <_dump_buf_with_offset+0x112>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <_dump_buf_with_offset+0x80>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    12b5 <_dump_buf_with_offset+0x1a5>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128f <_dump_buf_with_offset+0x17f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x20,-0x20(%rbp)
jl     1283 <_dump_buf_with_offset+0x173>
cmpl   $0x7f,-0x20(%rbp)
jl     128a <_dump_buf_with_offset+0x17a>
movl   $0x2e,-0x20(%rbp)
jmp    1296 <_dump_buf_with_offset+0x186>
movl   $0x20,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1245 <_dump_buf_with_offset+0x135>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0xc(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x8(%rbp)
jmp    1143 <_dump_buf_with_offset+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dump_buf_with_offset>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
cmp    %esi,%ebx
cmovb  %ebx,%eax
sub    %eax,%esi
test   %esi,%esi
jle    1289 <_dump_buf_with_offset+0x179>
mov    %esi,%r14d
lea    0xece(%rip),%rbp
lea    0xecd(%rip),%r13
lea    0xecb(%rip),%r15
mov    %rdx,(%rsp)
jmp    117a <_dump_buf_with_offset+0x6a>
nopl   (%rax)
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
lea    -0x10(%r14),%rax
add    $0x10,%rbx
cmp    $0x10,%r14
mov    %rax,%r14
mov    (%rsp),%rdx
mov    %r12,%rbp
jle    1289 <_dump_buf_with_offset+0x179>
test   %rdx,%rdx
je     11a0 <_dump_buf_with_offset+0x90>
mov    %ebx,%esi
sub    %edx,%esi
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
jmp    11b1 <_dump_buf_with_offset+0xa1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe59(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <_printk@plt>
xor    %r12d,%r12d
jmp    11ca <_dump_buf_with_offset+0xba>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    $0x10,%r12
je     1230 <_dump_buf_with_offset+0x120>
cmp    %r14,%r12
jge    11f0 <_dump_buf_with_offset+0xe0>
movzbl (%rbx,%r12,1),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
test   $0x1,%r12b
jne    1204 <_dump_buf_with_offset+0xf4>
jmp    120e <_dump_buf_with_offset+0xfe>
cs nopw 0x0(%rax,%rax,1)
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
test   $0x1,%r12b
je     120e <_dump_buf_with_offset+0xfe>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
mov    %r12d,%eax
not    %eax
test   $0x7,%al
jne    11c0 <_dump_buf_with_offset+0xb0>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
jmp    11c0 <_dump_buf_with_offset+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%r12
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
xor    %ebp,%ebp
jmp    1268 <_dump_buf_with_offset+0x158>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <_printk@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1150 <_dump_buf_with_offset+0x40>
mov    $0x20,%esi
cmp    %r14,%rbp
jge    1250 <_dump_buf_with_offset+0x140>
movzbl (%rbx,%rbp,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa1,%cl
mov    $0x2e,%ecx
cmovb  %ecx,%eax
movzbl %al,%esi
jmp    1250 <_dump_buf_with_offset+0x140>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%06X: \00"
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [3 x i8] c" \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c" |\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [3 x i8] c"|\0A\00"
define void @_dump_buf_with_offset(i8* %0, i32 %1, i8* %2) {
%4 = ptrtoint i8* %0 to i64
%5 = trunc i64 %4 to i32
%6 = icmp ult i32 %5, %1
%7 = select i1 %6, i32 %5, i32 0
%8 = sub i32 %1, %7
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %72
10: ; preds = %3
%11 = icmp eq i8* %2, null
%12 = ptrtoint i8* %2 to i64
%13 = trunc i64 %12 to i32
%14 = zext i32 %8 to i64
br label %15
15: ; preds = %10, %67
%16 = phi i64 [ %14, %10 ], [ %69, %67 ]
%17 = phi i8* [ %0, %10 ], [ %70, %67 ]
br i1 %11, label %23, label %18
18: ; preds = %15
%19 = ptrtoint i8* %17 to i64
%20 = trunc i64 %19 to i32
%21 = sub nsw i32 %20, %13
%22 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %25
23: ; preds = %15
%24 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %25
25: ; preds = %23, %18
br label %26
26: ; preds = %25, %47
%27 = phi i64 [ %48, %47 ], [ 0, %25 ]
%28 = icmp slt i64 %27, %16
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = getelementptr inbounds i8, i8* %17, i64 %27
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %26
%35 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = trunc i64 %27 to i32
%38 = and i32 %37, 1
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = and i32 %37, 7
%44 = icmp eq i32 %43, 7
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %42, %45
%48 = add nuw nsw i64 %27, 1
%49 = icmp eq i64 %48, 16
br i1 %49, label %50, label %26
50: ; preds = %47
%51 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %62
%53 = phi i64 [ 0, %50 ], [ %65, %62 ]
%54 = icmp slt i64 %53, %16
br i1 %54, label %55, label %62
55: ; preds = %52
%56 = getelementptr inbounds i8, i8* %17, i64 %53
%57 = load i8, i8* %56
%58 = add i8 %57, -127
%59 = icmp ult i8 %58, -95
%60 = select i1 %59, i8 46, i8 %57
%61 = zext i8 %60 to i32
br label %62
62: ; preds = %52, %55
%63 = phi i32 [ %61, %55 ], [ 32, %52 ]
%64 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %63)
%65 = add nuw nsw i64 %53, 1
%66 = icmp eq i64 %65, 16
br i1 %66, label %67, label %52
67: ; preds = %62
%68 = tail call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%69 = add nsw i64 %16, -16
%70 = getelementptr inbounds i8, i8* %17, i64 16
%71 = icmp sgt i64 %16, 16
br i1 %71, label %15, label %72
72: ; preds = %67, %3
ret void
}