#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 *, ...);
_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    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    %ecx,%eax
jbe    113e <_dump_buf_with_offset+0x2e>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <_dump_buf_with_offset+0x33>
cmpl   $0x0,-0x14(%rbp)
jle    12dd <_dump_buf_with_offset+0x1cd>
cmpq   $0x0,-0x20(%rbp)
je     1177 <_dump_buf_with_offset+0x67>
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x20(%rbp),%rax
sub    %eax,%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
jmp    1189 <_dump_buf_with_offset+0x79>
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    1230 <_dump_buf_with_offset+0x120>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cb <_dump_buf_with_offset+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x24(%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    -0x24(%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    -0x24(%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    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1190 <_dump_buf_with_offset+0x80>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    12b5 <_dump_buf_with_offset+0x1a5>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128f <_dump_buf_with_offset+0x17f>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xff,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x20,-0x28(%rbp)
jl     1283 <_dump_buf_with_offset+0x173>
cmpl   $0x7f,-0x28(%rbp)
jl     128a <_dump_buf_with_offset+0x17a>
movl   $0x2e,-0x28(%rbp)
jmp    1296 <_dump_buf_with_offset+0x186>
movl   $0x20,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1245 <_dump_buf_with_offset+0x135>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <_printk@plt>
mov    -0x14(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1143 <_dump_buf_with_offset+0x33>
mov    -0x4(%rbp),%eax
add    $0x30,%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 i32 @_dump_buf_with_offset(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%10 = load i32, i32* %6
%11 = load i8*, i8** %5
%12 = ptrtoint i8* %11 to i32
%13 = icmp ugt i32 %10, %12
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i32, i32* %6
%16 = load i8*, i8** %5
%17 = ptrtoint i8* %16 to i32
%18 = sub i32 %15, %17
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %3
br label %20
20: ; preds = %102, %19
%21 = load i32, i32* %6
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %108
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = ptrtoint i8* %27 to i32
%29 = load i8*, i8** %7
%30 = ptrtoint i8* %29 to i32
%31 = sub nsw i32 %28, %30
%32 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %36
33: ; preds = %23
%34 = load i8*, i8** %5
%35 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33, %26
store i32 0, i32* %8
br label %37
37: ; preds = %68, %36
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 16
br i1 %39, label %40, label %71
40: ; preds = %37
%41 = load i32, i32* %8
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %53
44: ; preds = %40
%45 = load i8*, i8** %5
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = and i32 %50, 255
%52 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %55
53: ; preds = %40
%54 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53, %44
%56 = load i32, i32* %8
%57 = srem i32 %56, 2
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
%62 = load i32, i32* %8
%63 = srem i32 %62, 8
%64 = icmp eq i32 %63, 7
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %61
br label %68
68: ; preds = %67
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %37
71: ; preds = %37
%72 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %73
73: ; preds = %99, %71
%74 = load i32, i32* %8
%75 = icmp slt i32 %74, 16
br i1 %75, label %76, label %102
76: ; preds = %73
%77 = load i32, i32* %8
%78 = load i32, i32* %6
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %95
80: ; preds = %76
%81 = load i8*, i8** %5
%82 = load i32, i32* %8
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = and i32 %86, 255
store i32 %87, i32* %9
%88 = load i32, i32* %9
%89 = icmp slt i32 %88, 32
br i1 %89, label %93, label %90
90: ; preds = %80
%91 = load i32, i32* %9
%92 = icmp sge i32 %91, 127
br i1 %92, label %93, label %94
93: ; preds = %90, %80
store i32 46, i32* %9
br label %94
94: ; preds = %93, %90
br label %96
95: ; preds = %76
store i32 32, i32* %9
br label %96
96: ; preds = %95, %94
%97 = load i32, i32* %9
%98 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %97)
br label %99
99: ; preds = %96
%100 = load i32, i32* %8
%101 = add nsw i32 %100, 1
store i32 %101, i32* %8
br label %73
102: ; preds = %73
%103 = call i32 (i8*, ...) @_printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%104 = load i32, i32* %6
%105 = sub nsw i32 %104, 16
store i32 %105, i32* %6
%106 = load i8*, i8** %5
%107 = getelementptr inbounds i8, i8* %106, i64 16
store i8* %107, i8** %5
br label %20
108: ; preds = %20
%109 = load i32, i32* %4
ret i32 %109
}

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 i32 @_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 i32 undef
}