#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*/ printf(char *, ...);
void bindump(unsigned char *b, int len) {
  unsigned int i, j;
  for (j = 0; j < len; j++) {
    if (j % 4 == 0)
      printf("%.4x\t", j);
    for (i = 7; i >= 0; i--) {
      if ((1 << i) & b[j])
        printf("1");
      else
        printf("0");
    }
    printf(" ");
    if ((j + 1) < len && (j + 1) % 4 == 0)
      printf("\n");
  }
  if (j % 4 != 0)
    printf("\n");
}


x86 assembly (clang, -O0):
<bindump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1207 <bindump+0xf7>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    1152 <bindump+0x42>
mov    -0x14(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jb     11b7 <bindump+0xa7>
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
mov    -0x14(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1196 <bindump+0x86>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <bindump+0x94>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <bindump+0x99>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <bindump+0x49>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0xc(%rbp),%eax
jae    11f4 <bindump+0xe4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
and    $0x3,%eax
cmp    $0x0,%eax
jne    11f4 <bindump+0xe4>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <bindump+0xe9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <bindump+0x16>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
cmp    $0x0,%eax
je     1224 <bindump+0x114>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bindump>:
push   %rbp
push   %rbx
push   %rax
test   %esi,%esi
je     1158 <bindump+0x38>
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7,%ebp
nop
movzbl (%rbx),%eax
bt     %ebp,%eax
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jmp    1140 <bindump+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%.4x\09\00"
define void @bindump(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 0)
br label %6
6: ; preds = %6, %4
%7 = phi i32 [ 7, %4 ], [ %15, %6 ]
%8 = shl nuw i32 1, %7
%9 = load i8, i8* %0
%10 = zext i8 %9 to i32
%11 = and i32 %8, %10
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 48, i32 49
%14 = tail call i32 @putchar(i32 %13)
%15 = add i32 %7, -1
br label %6
16: ; preds = %2
ret void
}