#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 is_bit_set(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
void print_bits(unsigned char *c, int size) {
  int i;
  for (i = 0; i < size * 8; i++)
    printf("%d ", is_bit_set(c, i));
  printf("\n");
}


x86 assembly (clang, -O0):
<print_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jge    1171 <print_bits+0x51>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <is_bit_set@plt>
mov    %eax,%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <print_bits+0x16>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    117d <print_bits+0x4d>
mov    %rdi,%r15
shl    $0x3,%esi
cmp    $0x2,%esi
mov    $0x1,%ebx
cmovge %esi,%ebx
lea    0xead(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %ebp,%esi
call   1050 <is_bit_set@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1160 <print_bits+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_bits(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %16, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = mul nsw i32 %8, 8
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = call i32 @is_bit_set(i8* %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %6
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @print_bits(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = shl i32 %1, 3
%6 = call i32 @llvm.smax.i32(i32 %5, i32 1)
br label %7
7: ; preds = %4, %7
%8 = phi i32 [ %11, %7 ], [ 0, %4 ]
%9 = tail call i32 @is_bit_set(i8* %0, i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i32 %8, 1
%12 = icmp eq i32 %11, %6
br i1 %12, label %13, label %7
13: ; preds = %7, %2
%14 = tail call i32 @putchar(i32 10)
ret void
}