#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*/ binwrite(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void bindump(unsigned char *bytes, int offset, int num) {
  int i;
  unsigned char c;
  printf("%04x  ", offset);
  for (i = 0; i < num; i++) {
    binwrite(bytes[i]);
  };
  printf(" ");
  for (i = 0; i < num; i++) {
    c = bytes[i];
    if ((c > 31) && (c < 128))
      printf("%c", c);
    else
      printf(".");
  };
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<bindump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1175 <bindump+0x55>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <binwrite@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <bindump+0x2a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f8 <bindump+0xd8>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
cmp    $0x1f,%eax
jle    11d7 <bindump+0xb7>
movzbl -0x15(%rbp),%eax
cmp    $0x80,%eax
jge    11d7 <bindump+0xb7>
movzbl -0x15(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e5 <bindump+0xc5>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ea <bindump+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <bindump+0x6a>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bindump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rdi,%r15
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
jle    11ae <bindump+0x7e>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r15,%rbx,1),%edi
call   1040 <binwrite@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <bindump+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    11b8 <bindump+0x88>
xor    %ebx,%ebx
mov    $0x2e,%r14d
nopw   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%eax
cmp    $0x20,%al
cmovl  %r14d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1190 <bindump+0x60>
jmp    11b8 <bindump+0x88>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%04x \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @bindump(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %22, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @binwrite(i8 zeroext %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %11
25: ; preds = %11
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %27
27: ; preds = %51, %25
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %54
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
store i8 %36, i8* %8
%37 = load i8, i8* %8
%38 = zext i8 %37 to i32
%39 = icmp sgt i32 %38, 31
br i1 %39, label %40, label %48
40: ; preds = %31
%41 = load i8, i8* %8
%42 = zext i8 %41 to i32
%43 = icmp slt i32 %42, 128
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8, i8* %8
%46 = zext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %50
48: ; preds = %40, %31
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %27
54: ; preds = %27
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%04x \00"
define void @bindump(i8* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @putchar(i32 32)
br label %31
8: ; preds = %3
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @binwrite(i8 zeroext %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = tail call i32 @putchar(i32 32)
br i1 %5, label %19, label %31
19: ; preds = %17
%20 = zext i32 %2 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %29, %21 ]
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = icmp sgt i8 %24, 31
%26 = select i1 %25, i8 %24, i8 46
%27 = zext i8 %26 to i32
%28 = tail call i32 @putchar(i32 %27)
%29 = add nuw nsw i64 %22, 1
%30 = icmp eq i64 %29, %20
br i1 %30, label %31, label %21
31: ; preds = %21, %6, %17
%32 = tail call i32 @putchar(i32 10)
ret void
}