#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 atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
scalar_t__ is_printable(unsigned char);
int /*<<< orphan*/ stderr;
void dump_bytes(unsigned char *buf, int len) {
  int i, j, seek = 0;
  int inc = 16;
  char *ptr = getenv("SNFBYTES");
  if (ptr) {
    int tmp = atoi(ptr);
    if (tmp < len)
      len = tmp;
  }
  for (i = 0; i < len; i += inc) {
    fprintf(stderr, "0x%08x | ", seek + i);
    for (j = i; j < i + inc; j++) {
      if (j >= len) {
        fprintf(stderr, "   ");
        continue;
      }
      fprintf(stderr, "%02x ", buf[j]);
    }
    fprintf(stderr, "  ");
    for (j = i; j < i + inc; j++) {
      if (j >= len)
        fprintf(stderr, " ");
      else if (is_printable(buf[j]))
        fprintf(stderr, "%c", buf[j]);
      else
        fprintf(stderr, ".");
    }
    fprintf(stderr, "\n");
  }
  fflush(stderr);
}


x86 assembly (clang, -O0):
<dump_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x10,-0x1c(%rbp)
lea    0xe8c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ab <dump_bytes+0x5b>
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <dump_bytes+0x56>
mov    -0x2c(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <dump_bytes+0x5b>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1338 <dump_bytes+0x1e8>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
add    -0x10(%rbp),%edx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    124b <dump_bytes+0xfb>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     121a <dump_bytes+0xca>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    123d <dump_bytes+0xed>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xde1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e1 <dump_bytes+0x91>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    1313 <dump_bytes+0x1c3>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     12a1 <dump_bytes+0x151>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1300 <dump_bytes+0x1b0>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <is_printable@plt>
cmp    $0x0,%rax
je     12e4 <dump_bytes+0x194>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xd45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    12fb <dump_bytes+0x1ab>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1300 <dump_bytes+0x1b0>
jmp    1305 <dump_bytes+0x1b5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1268 <dump_bytes+0x118>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b2 <dump_bytes+0x62>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xe96(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1181 <dump_bytes+0x31>
mov    %rax,%rdi
call   1070 <atoi@plt>
cmp    %ebx,%eax
cmovl  %eax,%ebx
test   %ebx,%ebx
jle    12d4 <dump_bytes+0x184>
mov    %ebx,%r14d
mov    0x2e4d(%rip),%r12
lea    0xe7d(%rip),%r13
xor    %ebp,%ebp
mov    %ebx,0xc(%rsp)
jmp    11e0 <dump_bytes+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp),%rax
add    $0x10,%rax
mov    %rbp,%r12
mov    %rax,%rbp
mov    (%r12),%edi
lea    0xe58(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    %ebp,%ebx
lea    0xe3d(%rip),%r13
jle    12d4 <dump_bytes+0x184>
mov    (%r12),%edi
lea    0xe1e(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbp,%rbx
mov    $0x10,%ebp
mov    %rbx,0x10(%rsp)
jmp    1229 <dump_bytes+0xd9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r15,%rbx,1),%edx
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
je     1250 <dump_bytes+0x100>
mov    (%r12),%edi
cmp    %r14,%rbx
jl     1210 <dump_bytes+0xc0>
lea    0xdda(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    121f <dump_bytes+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rbp
mov    (%r12),%edi
lea    0xdb6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x10,%r12d
mov    0x10(%rsp),%r13
mov    0xc(%rsp),%ebx
jmp    129f <dump_bytes+0x14f>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp),%edi
lea    0xd8b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r13
add    $0xffffffffffffffff,%r12
je     11b0 <dump_bytes+0x60>
cmp    %r14,%r13
jge    1280 <dump_bytes+0x130>
movzbl (%r15,%r13,1),%edi
call   1040 <is_printable@plt>
mov    0x0(%rbp),%edi
test   %rax,%rax
je     12cb <dump_bytes+0x17b>
movzbl (%r15,%r13,1),%edx
lea    0xd5b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1291 <dump_bytes+0x141>
lea    0xd4e(%rip),%rsi
jmp    128a <dump_bytes+0x13a>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fflush@plt>

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

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