#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 binary_print(unsigned int value) {
  unsigned int mask = 0xff000000;
  unsigned int shift = 256 * 256 * 256;
  unsigned int byte, byte_iterator, bit_iterator;
  for (byte_iterator = 0; byte_iterator < 4; byte_iterator++) {
    byte = (value & mask) / shift;
    printf(" ");
    for (bit_iterator = 0; bit_iterator < 8; bit_iterator++) {
      if (byte & 0x80)
        printf("1");
      else
        printf("0");
      byte *= 2;
    }
    mask /= 256;
    shift /= 256;
  }
}


x86 assembly (clang, -O0):
<binary_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xff000000,-0x8(%rbp)
movl   $0x1000000,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jae    11ca <binary_print+0xba>
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %eax,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jae    11aa <binary_print+0x9a>
mov    -0x10(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1187 <binary_print+0x77>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <binary_print+0x83>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <binary_print+0x4b>
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <binary_print+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary_print>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0xff000000,%ebx
mov    $0x1000000,%r15d
mov    $0x4,%r12d
nopl   0x0(%rax)
mov    %ebx,%eax
and    %r14d,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x80,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
and    $0x1,%ebp
or     $0x30,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
shr    $0x8,%ebx
shr    $0x8,%r15d
add    $0xffffffff,%r12d
jne    1130 <binary_print+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\00"
define void @binary_print(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
store i32 -16777216, i32* %3
store i32 16777216, i32* %4
store i32 0, i32* %6
br label %8
8: ; preds = %40, %1
%9 = load i32, i32* %6
%10 = icmp ult i32 %9, 4
br i1 %10, label %11, label %43
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = and i32 %12, %13
%15 = load i32, i32* %4
%16 = udiv i32 %14, %15
store i32 %16, i32* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %18
18: ; preds = %32, %11
%19 = load i32, i32* %7
%20 = icmp ult i32 %19, 8
br i1 %20, label %21, label %35
21: ; preds = %18
%22 = load i32, i32* %5
%23 = and i32 %22, 128
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %5
%31 = mul i32 %30, 2
store i32 %31, i32* %5
br label %32
32: ; preds = %29
%33 = load i32, i32* %7
%34 = add i32 %33, 1
store i32 %34, i32* %7
br label %18
35: ; preds = %18
%36 = load i32, i32* %3
%37 = udiv i32 %36, 256
store i32 %37, i32* %3
%38 = load i32, i32* %4
%39 = udiv i32 %38, 256
store i32 %39, i32* %4
br label %40
40: ; preds = %35
%41 = load i32, i32* %6
%42 = add i32 %41, 1
store i32 %42, i32* %6
br label %8
43: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @binary_print(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %42, %2 ]
%4 = phi i32 [ 16777216, %1 ], [ %41, %2 ]
%5 = phi i32 [ -16777216, %1 ], [ %40, %2 ]
%6 = and i32 %5, %0
%7 = udiv i32 %6, %4
%8 = tail call i32 @putchar(i32 32)
%9 = and i32 %7, 128
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i32 48, i32 49
%12 = tail call i32 @putchar(i32 %11)
%13 = and i32 %7, 64
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 48, i32 49
%16 = tail call i32 @putchar(i32 %15)
%17 = and i32 %7, 32
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 48, i32 49
%20 = tail call i32 @putchar(i32 %19)
%21 = and i32 %7, 16
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i32 48, i32 49
%24 = tail call i32 @putchar(i32 %23)
%25 = and i32 %7, 8
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i32 48, i32 49
%28 = tail call i32 @putchar(i32 %27)
%29 = and i32 %7, 4
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i32 48, i32 49
%32 = tail call i32 @putchar(i32 %31)
%33 = and i32 %7, 2
%34 = icmp eq i32 %33, 0
%35 = select i1 %34, i32 48, i32 49
%36 = tail call i32 @putchar(i32 %35)
%37 = and i32 %7, 1
%38 = or i32 %37, 48
%39 = tail call i32 @putchar(i32 %38)
%40 = lshr i32 %5, 8
%41 = lshr i32 %4, 8
%42 = add nuw nsw i32 %3, 1
%43 = icmp eq i32 %42, 4
br i1 %43, label %44, label %2
44: ; preds = %2
ret void
}