#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void hexdump_bin(const void *data, size_t length, size_t count) {
  uint32_t v = *((uint32_t *)data);
  int shift, i;
  for (i = 1, shift = 31; shift >= 0; ++i, --shift) {
    printf("%c", ((v >> shift) & 1) ? '1' : '0');
    if ((i % 8) == 0)
      printf(" ");
  }
}


x86 assembly (clang, -O0):
<hexdump_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1f,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     11ae <hexdump_bin+0x9e>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0x1,%ecx
mov    $0x30,%esi
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1192 <hexdump_bin+0x82>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <hexdump_bin+0x87>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    113b <hexdump_bin+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump_bin>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%r14d
mov    $0x1f,%ebp
mov    $0x1,%ebx
jmp    1138 <hexdump_bin+0x28>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
add    $0xffffffff,%ebp
jae    115a <hexdump_bin+0x4a>
bt     %ebp,%r14d
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
test   $0x7,%bl
jne    1130 <hexdump_bin+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1130 <hexdump_bin+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
define void @hexdump_bin(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
store i32 %12, i32* %7
store i32 1, i32* %9
store i32 31, i32* %8
br label %13
13: ; preds = %31, %3
%14 = load i32, i32* %8
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = ashr i32 %17, %18
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 49, i32 48
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %9
%26 = srem i32 %25, 8
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %16
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
%34 = load i32, i32* %8
%35 = add nsw i32 %34, -1
store i32 %35, i32* %8
br label %13
36: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @hexdump_bin(i8* nocapture %0, i64 %1, i64 %2) {
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
br label %6
6: ; preds = %3, %18
%7 = phi i32 [ 1, %3 ], [ %19, %18 ]
%8 = phi i32 [ 31, %3 ], [ %20, %18 ]
%9 = shl nuw i32 1, %8
%10 = and i32 %9, %5
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 48, i32 49
%13 = tail call i32 @putchar(i32 %12)
%14 = and i32 %7, 7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %6
%17 = tail call i32 @putchar(i32 32)
br label %18
18: ; preds = %6, %16
%19 = add nuw nsw i32 %7, 1
%20 = add nsw i32 %8, -1
%21 = icmp eq i32 %19, 33
br i1 %21, label %22, label %6
22: ; preds = %18
ret void
}