#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 print_bits(unsigned int *buff, unsigned int pos, unsigned int n,
                const char *prev) {
  unsigned int i;
  unsigned int last = n + pos;
  printf("%s[%d bits ==>", prev, n);
  for (i = pos; i < last; i++) {
    if ((((buff)[(i) / (32)] >> ((i) % (32))) & 1))
      printf("1");
    else
      printf("0");
  }
  printf("]");
}


x86 assembly (clang, -O0):
<print_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    11ad <print_bits+0x9d>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shr    $0x5,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
mov    -0x1c(%rbp),%ecx
and    $0x1f,%ecx
shr    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     118c <print_bits+0x7c>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <print_bits+0x8a>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <print_bits+0x8f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <print_bits+0x3a>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
lea    (%r14,%rbx,1),%ebp
lea    0xec6(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%ebp
jbe    1172 <print_bits+0x52>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
shr    $0x5,%eax
mov    (%r15,%rax,4),%eax
bt     %ebx,%eax
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    $0xffffffff,%r14d
jne    1150 <print_bits+0x30>
mov    $0x5d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%s[%d bits ==>\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [2 x i8] c"]\00"
define void @print_bits(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = add i32 %11, %12
store i32 %13, i32* %10
%14 = load i8*, i8** %8
%15 = load i32, i32* %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i32, i32* %6
store i32 %17, i32* %9
br label %18
18: ; preds = %39, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i32*, i32** %5
%24 = load i32, i32* %9
%25 = udiv i32 %24, 32
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %9
%30 = urem i32 %29, 32
%31 = lshr i32 %28, %30
%32 = and i32 %31, 1
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %22
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %38
36: ; preds = %22
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %18
42: ; preds = %18
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%s[%d bits ==>\00"
define void @print_bits(i32* nocapture %0, i32 %1, i32 %2, i8* %3) {
%5 = add i32 %2, %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %2)
%7 = icmp ugt i32 %5, %1
br i1 %7, label %8, label %22
8: ; preds = %4, %8
%9 = phi i32 [ %20, %8 ], [ %1, %4 ]
%10 = lshr i32 %9, 5
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = and i32 %9, 31
%15 = shl nuw i32 1, %14
%16 = and i32 %13, %15
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 48, i32 49
%19 = tail call i32 @putchar(i32 %18)
%20 = add i32 %9, 1
%21 = icmp eq i32 %20, %5
br i1 %21, label %22, label %8
22: ; preds = %8, %4
%23 = tail call i32 @putchar(i32 93)
ret void
}