#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*/ bits_dump_indent(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void bits_dump(char *name, unsigned *buff, unsigned length, unsigned level) {
  unsigned byte;
  bits_dump_indent(level);
  printf("%s :\n", name);
  bits_dump_indent(level + 1);
  for (byte = 0; byte < length; ++byte) {
    if (byte % 32 == 0) {
      printf("%04x: ", byte);
    }
    printf("%02x ", buff[byte]);
    if (byte % 8 == 7) {
      printf(" - ");
    }
    if (byte % 32 == 31) {
      printf("\n");
      bits_dump_indent(level + 1);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<bits_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <bits_dump_indent@plt>
mov    -0x8(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
call   1040 <bits_dump_indent@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11fe <bits_dump+0xde>
mov    -0x1c(%rbp),%eax
and    $0x1f,%eax
cmp    $0x0,%eax
jne    118e <bits_dump+0x6e>
mov    -0x1c(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    11c3 <bits_dump+0xa3>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
and    $0x1f,%eax
cmp    $0x1f,%eax
jne    11eb <bits_dump+0xcb>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
call   1040 <bits_dump_indent@plt>
jmp    11f0 <bits_dump+0xd0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <bits_dump+0x42>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bits_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %ecx,%edi
call   1050 <bits_dump_indent@plt>
lea    0xeab(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
mov    %r13d,%edi
call   1050 <bits_dump_indent@plt>
test   %r14d,%r14d
je     11df <bits_dump+0xaf>
mov    %r14d,%r14d
lea    0xe93(%rip),%r15
xor    %ebp,%ebp
jmp    1189 <bits_dump+0x59>
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %rbp,%r14
je     11df <bits_dump+0xaf>
mov    %ebp,%r12d
and    $0x1f,%r12d
jne    11a2 <bits_dump+0x72>
lea    0xe6d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    11c5 <bits_dump+0x95>
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1f,%r12d
jne    1180 <bits_dump+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13d,%edi
call   1050 <bits_dump_indent@plt>
jmp    1180 <bits_dump+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s :\0A\00"
@.str.1 = [7 x i8] c"%04x: \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" - \00"
@.str.4 = [2 x i8] c"\0A\00"
define void @bits_dump(i8* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = call i32 @bits_dump_indent(i32 %10)
%12 = load i8*, i8** %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %8
%15 = add i32 %14, 1
%16 = call i32 @bits_dump_indent(i32 %15)
store i32 0, i32* %9
br label %17
17: ; preds = %50, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %53
21: ; preds = %17
%22 = load i32, i32* %9
%23 = urem i32 %22, 32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %21
%29 = load i32*, i32** %6
%30 = load i32, i32* %9
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %9
%36 = urem i32 %35, 8
%37 = icmp eq i32 %36, 7
br i1 %37, label %38, label %40
38: ; preds = %28
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %28
%41 = load i32, i32* %9
%42 = urem i32 %41, 32
%43 = icmp eq i32 %42, 31
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %8
%47 = add i32 %46, 1
%48 = call i32 @bits_dump_indent(i32 %47)
br label %49
49: ; preds = %44, %40
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = add i32 %51, 1
store i32 %52, i32* %9
br label %17
53: ; preds = %17
%54 = 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 = [6 x i8] c"%s :\0A\00"
@.str.1 = [7 x i8] c"%04x: \00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" - \00"
define void @bits_dump(i8* %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 @bits_dump_indent(i32 %3)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = add i32 %3, 1
%8 = tail call i32 @bits_dump_indent(i32 %7)
%9 = icmp eq i32 %2, 0
br i1 %9, label %35, label %10
10: ; preds = %4
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %10, %32
%13 = phi i64 [ 0, %10 ], [ %33, %32 ]
%14 = trunc i64 %13 to i32
%15 = and i32 %14, 31
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %19
19: ; preds = %17, %12
%20 = getelementptr inbounds i32, i32* %1, i64 %13
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = and i32 %14, 7
%24 = icmp eq i32 %23, 7
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
%28 = icmp eq i32 %15, 31
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = tail call i32 @putchar(i32 10)
%31 = tail call i32 @bits_dump_indent(i32 %7)
br label %32
32: ; preds = %27, %29
%33 = add nuw nsw i64 %13, 1
%34 = icmp eq i64 %33, %11
br i1 %34, label %35, label %12
35: ; preds = %32, %4
%36 = tail call i32 @putchar(i32 10)
ret void
}