#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 CHAR_BIT;
int /*<<< orphan*/ putchar(char);
void print_binary(unsigned n) {
  unsigned i = 1 << (sizeof(unsigned) * CHAR_BIT - 1);
  unsigned j = 0;
  for (; i != 0; j++, i >>= 1) {
    if (j > 0 && j % CHAR_BIT == 0) {
      putchar(' ');
    }
    putchar(n & i ? '1' : '0');
  }
}


x86 assembly (clang, -O0):
<print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11aa <print_binary+0x9a>
cmpl   $0x0,-0xc(%rbp)
jbe    1175 <print_binary+0x65>
mov    -0xc(%rbp),%eax
mov    0x2e82(%rip),%rcx
xor    %edx,%edx
divl   (%rcx)
cmp    $0x0,%edx
jne    1175 <print_binary+0x65>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edx
and    -0x8(%rbp),%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <print_binary+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_binary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
mov    0x2ebe(%rip),%r14
mov    (%r14),%cl
shl    $0x2,%cl
add    $0xff,%cl
mov    $0x1,%ebp
mov    $0x1,%r12d
shl    %cl,%r12d
movzbl %cl,%eax
bt     %eax,%edi
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
mov    %r12d,%ebx
jmp    1181 <print_binary+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
and    %r15d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x3,%r12d
mov    %ebx,%r12d
jbe    119a <print_binary+0x8a>
shr    %ebx
mov    %ebp,%eax
xor    %edx,%edx
divl   (%r14)
test   %edx,%edx
jne    1160 <print_binary+0x50>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1160 <print_binary+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @print_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* @CHAR_BIT
%6 = sext i32 %5 to i64
%7 = mul i64 4, %6
%8 = sub i64 %7, 1
%9 = trunc i64 %8 to i32
%10 = shl i32 1, %9
store i32 %10, i32* %3
store i32 0, i32* %4
br label %11
11: ; preds = %33, %1
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp ugt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %4
%19 = load i32, i32* @CHAR_BIT
%20 = urem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @putchar(i8 signext 32)
br label %24
24: ; preds = %22, %17, %14
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = and i32 %25, %26
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 49, i32 48
%31 = trunc i32 %30 to i8
%32 = call i32 @putchar(i8 signext %31)
br label %33
33: ; preds = %24
%34 = load i32, i32* %4
%35 = add i32 %34, 1
store i32 %35, i32* %4
%36 = load i32, i32* %3
%37 = lshr i32 %36, 1
store i32 %37, i32* %3
br label %11
38: ; preds = %11
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @print_binary(i32 %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = shl i32 %2, 2
%4 = add i32 %3, -1
%5 = shl nuw i32 1, %4
%6 = and i32 %5, %0
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 48, i8 49
%9 = tail call i32 @putchar(i8 signext %8)
br label %10
10: ; preds = %19, %1
%11 = phi i32 [ 1, %1 ], [ %24, %19 ]
%12 = phi i32 [ %5, %1 ], [ %13, %19 ]
%13 = lshr i32 %12, 1
%14 = load i32, i32* @CHAR_BIT
%15 = urem i32 %11, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = tail call i32 @putchar(i8 signext 32)
br label %19
19: ; preds = %17, %10
%20 = and i32 %13, %0
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8 48, i8 49
%23 = tail call i32 @putchar(i8 signext %22)
%24 = add nuw nsw i32 %11, 1
%25 = icmp ult i32 %12, 4
br i1 %25, label %26, label %10
26: ; preds = %19
ret void
}