#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 disp_bin(void *data, size_t data_size) {
  printf("  bin: ");
  int i;
  for (i = 0; i < data_size; i++) {
    unsigned char *d = (unsigned char *)data;
    d += (data_size - i - 1);
    printf("%d%d%d%d%d%d%d%d ", ((*d & 0x80) >> 7), ((*d & 0x40) >> 6),
           ((*d & 0x20) >> 5), ((*d & 0x10) >> 4), ((*d & 0x08) >> 3),
           ((*d & 0x04) >> 2), ((*d & 0x02) >> 1), ((*d & 0x01) >> 0));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<disp_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1202 <disp_bin+0xf2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%esi
and    $0x80,%esi
sar    $0x7,%esi
mov    -0x20(%rbp),%rax
movzbl (%rax),%edx
and    $0x40,%edx
sar    $0x6,%edx
mov    -0x20(%rbp),%rax
movzbl (%rax),%ecx
and    $0x20,%ecx
sar    $0x5,%ecx
mov    -0x20(%rbp),%rax
movzbl (%rax),%r8d
and    $0x10,%r8d
sar    $0x4,%r8d
mov    -0x20(%rbp),%rax
movzbl (%rax),%r9d
and    $0x8,%r9d
sar    $0x3,%r9d
mov    -0x20(%rbp),%rax
movzbl (%rax),%r11d
and    $0x4,%r11d
sar    $0x2,%r11d
mov    -0x20(%rbp),%rax
movzbl (%rax),%r10d
and    $0x2,%r10d
sar    $0x1,%r10d
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
and    $0x1,%eax
sar    $0x0,%eax
lea    0xe28(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <disp_bin+0x25>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disp_bin>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     11b6 <disp_bin+0x96>
lea    0xec0(%rip),%r15
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%r14,%r12,1),%ebx
mov    %ebx,%esi
shr    $0x7,%esi
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x1,%edx
mov    %ebx,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
mov    %ebx,%r8d
shr    $0x4,%r8d
and    $0x1,%r8d
mov    %ebx,%r9d
shr    $0x3,%r9d
and    $0x1,%r9d
mov    %ebx,%r10d
shr    $0x2,%r10d
and    $0x1,%r10d
mov    %ebx,%r11d
shr    %r11d
and    $0x1,%r11d
and    $0x1,%ebx
sub    $0x8,%rsp
mov    %r15,%rdi
xor    %eax,%eax
push   %rbx
push   %r11
push   %r10
call   1040 <printf@plt>
add    $0x20,%rsp
add    $0xffffffffffffffff,%r12
jne    1150 <disp_bin+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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