#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void printBits64(int64_t a) {
  int i, k, mask;
  for (i = 63; i >= 0; i--) {
    if (!((i + 1) % 8))
      printf(" ");
    mask = 1 << i;
    k = a & mask;
    if (k == 0)
      printf("0");
    else
      printf("1");
  }
}


x86 assembly (clang, -O0):
<printBits64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3f,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     119f <printBits64+0x8f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    114f <printBits64+0x3f>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1180 <printBits64+0x70>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    118c <printBits64+0x7c>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    1191 <printBits64+0x81>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <printBits64+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBits64>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x40,%ebx
jmp    1136 <printBits64+0x26>
xchg   %ax,%ax
bt     %ebp,%r14d
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
je     114a <printBits64+0x3a>
lea    -0x1(%rbx),%ebp
test   $0x7,%bl
jne    1120 <printBits64+0x10>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1120 <printBits64+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"1\00"
define void @printBits64(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 63, i32* %3
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
%12 = srem i32 %11, 8
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* %3
%18 = shl i32 1, %17
store i32 %18, i32* %5
%19 = load i32, i32* %2
%20 = load i32, i32* %5
%21 = and i32 %19, %20
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
26: ; preds = %16
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %6
32: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @printBits64(i32 %0) {
br label %2
2: ; preds = %1, %9
%3 = phi i32 [ 63, %1 ], [ %15, %9 ]
%4 = add nuw nsw i32 %3, 1
%5 = and i32 %4, 7
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @putchar(i32 32)
br label %9
9: ; preds = %7, %2
%10 = shl nuw i32 1, %3
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 48, i32 49
%14 = tail call i32 @putchar(i32 %13)
%15 = add nsw i32 %3, -1
%16 = icmp eq i32 %3, 0
br i1 %16, label %17, label %2
17: ; preds = %9
ret void
}