#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 *, int);
int main(void) {
  int count, size, direction, to;
  for (count = 0; count < 1000; ++count) {
    size = count;
    printf("\n%.3d: ", count);
    do
      printf("%d", size % 2);
    while (size = size >> 1);
    if (count % 2)
      to = count - 2;
    else
      to = (count >> 1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    11b1 <main+0xa1>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    1148 <main+0x38>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1195 <main+0x85>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x8e>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a3 <main+0x93>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
lea    0xede(%rip),%r14
lea    0xedf(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r15d,%ebx
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%esi
and    $0x1,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
shr    %ebp
cmp    $0x1,%ebx
mov    %ebp,%ebx
ja     1150 <main+0x40>
add    $0x1,%r15d
cmp    $0x3e8,%r15d
jne    1130 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"\0A%.3d: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ 0, %0 ], [ %11, %10 ]
%3 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %2, %1 ], [ %8, %4 ]
%6 = and i32 %5, 1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = lshr i32 %5, 1
%9 = icmp ult i32 %5, 2
br i1 %9, label %10, label %4
10: ; preds = %4
%11 = add nuw nsw i32 %2, 1
%12 = icmp eq i32 %11, 1000
br i1 %12, label %13, label %1
13: ; preds = %10
ret i32 0
}