#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
void print_binary_bits(unsigned long data, unsigned size) {
  while (size-- > 0) {
    if ((data >> size) & 0x1ull)
      fprintf(stdout, "1");
    else
      fprintf(stdout, "0");
  }
  fprintf(stdout, "B\n");
}


x86 assembly (clang, -O0):
<print_binary_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jbe    117f <print_binary_bits+0x6f>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shr    %cl,%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1165 <print_binary_bits+0x55>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1030 <fprintf@plt>
jmp    117a <print_binary_bits+0x6a>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
jmp    111f <print_binary_bits+0xf>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary_bits>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
je     1159 <print_binary_bits+0x49>
mov    %rdi,%r14
mov    %esi,%ebx
add    $0xffffffffffffffff,%rbx
mov    0x2eb3(%rip),%r15
lea    0xece(%rip),%r12
lea    0xec5(%rip),%r13
nopl   0x0(%rax,%rax,1)
bt     %rbx,%r14
mov    (%r15),%edi
mov    %r13,%rsi
cmovae %r12,%rsi
call   1030 <fprintf@plt>
add    $0xffffffffffffffff,%rbx
jb     1140 <print_binary_bits+0x30>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [3 x i8] c"B\0A\00"
define void @print_binary_bits(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
br label %5
5: ; preds = %22, %2
%6 = load i32, i32* %4
%7 = add i32 %6, -1
store i32 %7, i32* %4
%8 = icmp ugt i32 %6, 0
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i64, i64* %3
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = lshr i64 %10, %12
%14 = and i64 %13, 1
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* @stdout
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
19: ; preds = %9
%20 = load i32, i32* @stdout
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %19, %16
br label %5
23: ; preds = %5
%24 = load i32, i32* @stdout
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [3 x i8] c"B\0A\00"
define void @print_binary_bits(i64 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %5, %4 ], [ %8, %6 ]
%8 = add nsw i64 %7, -1
%9 = shl nuw i64 1, %8
%10 = and i64 %9, %0
%11 = icmp eq i64 %10, 0
%12 = load i32, i32* @stdout
%13 = select i1 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%14 = tail call i32 @fprintf(i32 %12, i8* %13)
%15 = icmp eq i64 %8, 0
br i1 %15, label %16, label %6
16: ; preds = %6, %2
%17 = load i32, i32* @stdout
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}