#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_binary(void *p, int size, const char *name) {
  int i;
  for (i = size - 1; i >= 0; i--) {
    printf("%u", *(int *)p >> i & 1);
    if ((i) % 8 == 0 && i)
      printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     1191 <print_binary+0x81>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x1c(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117e <print_binary+0x6e>
cmpl   $0x0,-0x1c(%rbp)
je     117e <print_binary+0x6e>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1183 <print_binary+0x73>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    112c <print_binary+0x1c>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1178 <print_binary+0x58>
mov    %esi,%ebx
mov    %rdi,%r14
add    $0xffffffff,%ebx
lea    0xec8(%rip),%r15
jmp    114d <print_binary+0x2d>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%eax
add    $0x1,%ebx
cmp    $0x1,%ebx
mov    %eax,%ebx
jbe    1178 <print_binary+0x58>
mov    (%r14),%esi
mov    %ebx,%ecx
shr    %cl,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     1140 <print_binary+0x20>
mov    %ebx,%eax
and    $0x7,%eax
jne    1140 <print_binary+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <print_binary+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
define void @print_binary(i8* nocapture %0, i32 %1, i8* nocapture readnone %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = bitcast i8* %0 to i32*
br label %7
7: ; preds = %5, %20
%8 = phi i32 [ %1, %5 ], [ %9, %20 ]
%9 = add nsw i32 %8, -1
%10 = load i32, i32* %6
%11 = lshr i32 %10, %9
%12 = and i32 %11, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = and i32 %9, 7
%15 = icmp eq i32 %14, 0
%16 = icmp ne i32 %9, 0
%17 = and i1 %16, %15
br i1 %17, label %18, label %20
18: ; preds = %7
%19 = tail call i32 @putchar(i32 32)
br label %20
20: ; preds = %7, %18
%21 = icmp ugt i32 %8, 1
br i1 %21, label %7, label %22
22: ; preds = %20, %3
%23 = tail call i32 @putchar(i32 10)
ret void
}