#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*/ putchar(char);
void print_bits(unsigned int a) {
  unsigned int i;
  for (i = 32; i > 0; i--) {
    if (a & (0x1 << (i - 1))) {
      putchar('1');
    } else {
      putchar('0');
    }
    if (i % 4 == 1) {
      putchar(' ');
    }
  }
}


x86 assembly (clang, -O0):
<print_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jbe    118e <print_bits+0x7e>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1158 <print_bits+0x48>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    1162 <print_bits+0x52>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
and    $0x3,%eax
cmp    $0x1,%eax
jne    117b <print_bits+0x6b>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1180 <print_bits+0x70>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print_bits+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bits>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    $0x20,%ebp
jmp    1124 <print_bits+0x14>
xchg   %ax,%ax
test   %ebp,%ebp
je     114e <print_bits+0x3e>
mov    %ebp,%ebx
lea    -0x1(%rbx),%ebp
bt     %ebp,%r14d
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
and    $0x3,%ebx
cmp    $0x1,%ebx
jne    1120 <print_bits+0x10>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1120 <print_bits+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @print_bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 32, i32* %3
br label %4
4: ; preds = %25, %1
%5 = load i32, i32* %3
%6 = icmp ugt i32 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = sub i32 %9, 1
%11 = shl i32 1, %10
%12 = and i32 %8, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @putchar(i8 signext 49)
br label %18
16: ; preds = %7
%17 = call i32 @putchar(i8 signext 48)
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %3
%20 = urem i32 %19, 4
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @putchar(i8 signext 32)
br label %24
24: ; preds = %22, %18
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add i32 %26, -1
store i32 %27, i32* %3
br label %4
28: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @print_bits(i32 %0) {
br label %2
2: ; preds = %1, %14
%3 = phi i32 [ 32, %1 ], [ %4, %14 ]
%4 = add nsw 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)
%10 = and i32 %3, 3
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @putchar(i8 signext 32)
br label %14
14: ; preds = %2, %12
%15 = icmp eq i32 %4, 0
br i1 %15, label %16, label %2
16: ; preds = %14
ret void
}