#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 u_int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_binary(u_int64_t value) {
  int index = 0;
  int binary_count = sizeof(u_int64_t) * 8;
  while (binary_count-- > 0) {
    u_int64_t tmp = value >> binary_count;
    if ((tmp & 0x01) == 1) {
      printf("1");
    } else {
      printf("0");
    }
    if (++index % 8 == 0) {
      printf(" ");
    }
  }
  printf("==> %lld \n", value);
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x20,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    11a5 <print_binary+0x95>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    116a <print_binary+0x5a>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1178 <print_binary+0x68>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a0 <print_binary+0x90>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1129 <print_binary+0x19>
mov    -0x4(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x1f,%ebp
mov    $0x1,%ebx
jmp    1148 <print_binary+0x28>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
add    $0xffffffff,%ebp
jae    116a <print_binary+0x4a>
bt     %ebp,%r14d
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
test   $0x7,%bl
jne    1140 <print_binary+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <print_binary+0x20>
lea    0xe8f(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@.str.3 = [11 x i8] c"==> %lld \0A\00"
define void @print_binary(i32 %0) {
br label %2
2: ; preds = %1, %15
%3 = phi i32 [ 31, %1 ], [ %16, %15 ]
%4 = phi i32 [ 0, %1 ], [ %10, %15 ]
%5 = shl nuw i32 1, %3
%6 = and i32 %5, %0
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 48, i32 49
%9 = tail call i32 @putchar(i32 %8)
%10 = add nuw nsw i32 %4, 1
%11 = and i32 %10, 7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @putchar(i32 32)
br label %15
15: ; preds = %13, %2
%16 = add nsw i32 %3, -1
%17 = icmp eq i32 %10, 32
br i1 %17, label %18, label %2
18: ; preds = %15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %0)
ret void
}