#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 ce_print_binary(int val) {
  const int size = sizeof(int) * 8;
  int index = 0;
  for (index = size - 1; index >= 0; --index) {
    if ((1 << index) & val) {
      printf("1");
    } else {
      printf("0");
    }
    if (((index % 4) == 0)) {
      printf(" ");
    }
  }
}


x86 assembly (clang, -O0):
<ce_print_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1f,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11a0 <ce_print_binary+0x90>
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    -0x4(%rbp),%eax
cmp    $0x0,%eax
je     1161 <ce_print_binary+0x51>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
jmp    116d <ce_print_binary+0x5d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118d <ce_print_binary+0x7d>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    1192 <ce_print_binary+0x82>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1130 <ce_print_binary+0x20>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ce_print_binary>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x1f,%ebp
jmp    1125 <ce_print_binary+0x15>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
jae    1147 <ce_print_binary+0x37>
bt     %ebp,%ebx
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
test   $0x3,%bpl
jne    1120 <ce_print_binary+0x10>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1120 <ce_print_binary+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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