#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 agile_bit_get(unsigned char const *, int);
int /*<<< orphan*/ printf(char *, ...);
void dump_bits(const unsigned char *bits, int size) {
  int bit;
  for (int i = 0; i < size; ++i) {
    bit = agile_bit_get(bits, i);
    if (i / 8 > 0 && i % 8 == 0)
      printf(" %d", bit);
    else
      printf("%d", bit);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_bits>:
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
jge    11b3 <dump_bits+0x93>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <agile_bit_get@plt>
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    118f <dump_bits+0x6f>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118f <dump_bits+0x6f>
mov    -0x10(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <dump_bits+0x80>
mov    -0x10(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <dump_bits+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <dump_bits+0x16>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_bits>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    118d <dump_bits+0x5d>
mov    %esi,%r12d
mov    %rdi,%r14
lea    0xeb7(%rip),%r15
lea    0xeb1(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <agile_bit_get@plt>
test   $0x7,%bpl
mov    %rbx,%rdi
cmove  %r15,%rdi
cmp    $0x8,%ebp
cmovb  %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1160 <dump_bits+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_bits(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 = %29, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %6
%14 = call i32 @agile_bit_get(i8* %12, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %6
%16 = sdiv i32 %15, 8
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load i32, i32* %6
%20 = srem i32 %19, 8
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %28
25: ; preds = %18, %11
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %22
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %7
32: ; preds = %7
%33 = 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 = [4 x i8] c" %d\00"
@.str.1 = [3 x i8] c"%d\00"
define void @dump_bits(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %6, %2
%5 = tail call i32 @putchar(i32 10)
ret void
6: ; preds = %2, %6
%7 = phi i32 [ %15, %6 ], [ 0, %2 ]
%8 = tail call i32 @agile_bit_get(i8* %0, i32 %7)
%9 = icmp ugt i32 %7, 7
%10 = and i32 %7, 7
%11 = icmp eq i32 %10, 0
%12 = and i1 %9, %11
%13 = select i1 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, i32 %8)
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, %1
br i1 %16, label %4, label %6
}