#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 *, unsigned int, ...);
int /*<<< orphan*/ putchar(char);
unsigned int print_bits(void *in_ptr, unsigned int in_bytes) {
  unsigned int total_width = sizeof(void *);
  unsigned int i, j;
  char compare;
  printf("Pointer size: %d bits\nPrinting from %p for %u bytes:\n\n",
         total_width * 8, in_ptr, in_bytes);
  for (i = 0; i < in_bytes; i++) {
    if (!(i && i % total_width))
      printf("%d:\t", i);
    if (!1) {
      compare = (char)0x80;
      for (j = 0; j < 8; j++) {
        if (*(char *)in_ptr & compare)
          putchar('1');
        else
          putchar('0');
        compare = (compare >> 1) & 0x7F;
      }
    } else
      printf("%02x", (unsigned int)*(char *)in_ptr & 0xFF);
    (i + 1) % total_width ? putchar('\t') : putchar('\n');
    in_ptr = (char *)in_ptr + 1;
  }
  putchar('\n');
  return in_bytes;
}


x86 assembly (clang, -O0):
<print_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0x10(%rbp),%esi
shl    $0x3,%esi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11f2 <print_bits+0xd2>
cmpl   $0x0,-0x14(%rbp)
je     117f <print_bits+0x5f>
mov    -0x14(%rbp),%eax
xor    %edx,%edx
divl   -0x10(%rbp)
cmp    $0x0,%edx
jne    1190 <print_bits+0x70>
mov    -0x14(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
and    $0xff,%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
xor    %edx,%edx
divl   -0x10(%rbp)
cmp    $0x0,%edx
je     11ce <print_bits+0xae>
mov    $0x9,%edi
call   1030 <putchar@plt>
jmp    11d8 <print_bits+0xb8>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <print_bits+0x38>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bits>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r13
lea    0xec8(%rip),%rdi
mov    $0x40,%esi
mov    %r13,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     11b1 <print_bits+0x91>
mov    %r14d,%ebx
lea    0xede(%rip),%r15
lea    0xedc(%rip),%r12
xor    %ebp,%ebp
jmp    119d <print_bits+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x0(%r13,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
mov    %ebp,%eax
and    $0x7,%eax
cmp    $0x1,%eax
mov    $0x9,%edi
adc    $0x0,%edi
call   1030 <putchar@plt>
cmp    %ebp,%ebx
je     11b1 <print_bits+0x91>
test   $0x7,%bpl
jne    1170 <print_bits+0x50>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <print_bits+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Pointer size: %d bits\0APrinting from %p for %u bytes:\0A\0A\00"
@.str.1 = [5 x i8] c"%d:\09\00"
@.str.2 = [5 x i8] c"%02x\00"
define i32 @print_bits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 8, i32* %5
%9 = load i32, i32* %5
%10 = mul i32 %9, 8
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11, i32 %12)
store i32 0, i32* %6
br label %14
14: ; preds = %48, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %51
18: ; preds = %14
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = urem i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21, %18
%27 = load i32, i32* %6
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %21
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = and i32 %32, 255
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %6
%36 = add i32 %35, 1
%37 = load i32, i32* %5
%38 = urem i32 %36, %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = call i32 @putchar(i8 signext 9)
br label %44
42: ; preds = %29
%43 = call i32 @putchar(i8 signext 10)
br label %44
44: ; preds = %42, %40
%45 = phi i32 [ %41, %40 ], [ %43, %42 ]
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 1
store i8* %47, i8** %3
br label %48
48: ; preds = %44
%49 = load i32, i32* %6
%50 = add i32 %49, 1
store i32 %50, i32* %6
br label %14
51: ; preds = %14
%52 = call i32 @putchar(i8 signext 10)
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@.str = [55 x i8] c"Pointer size: %d bits\0APrinting from %p for %u bytes:\0A\0A\00"
@.str.1 = [5 x i8] c"%d:\09\00"
@.str.2 = [5 x i8] c"%02x\00"
define i32 @print_bits(i8* %0, i32 returned %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 64, i8* %0, i32 %1)
%4 = icmp eq i32 %1, 0
br i1 %4, label %23, label %5
5: ; preds = %2, %12
%6 = phi i8* [ %21, %12 ], [ %0, %2 ]
%7 = phi i32 [ %16, %12 ], [ 0, %2 ]
%8 = and i32 %7, 7
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %12
12: ; preds = %5, %10
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = add nuw i32 %7, 1
%17 = and i32 %16, 7
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8 10, i8 9
%20 = tail call i32 @putchar(i8 signext %19)
%21 = getelementptr inbounds i8, i8* %6, i64 1
%22 = icmp eq i32 %16, %1
br i1 %22, label %23, label %5
23: ; preds = %12, %2
%24 = tail call i32 @putchar(i8 signext 10)
ret i32 %1
}