#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 bitprint(int a) {
  int n = sizeof(int) * CHAR_BIT;
  int mask = 1 << (n - 1);
  int i;
  for (i = 1; i <= n; ++i) {
    putchar((!(a & mask)) ? '0' : '1');
    a <<= 1;
    if (!(i % CHAR_BIT) && i < n) {
      putchar(' ');
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<bitprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11be <bitprint+0xae>
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
cmp    $0x0,%eax
setne  %dl
xor    $0xff,%dl
mov    $0x31,%eax
mov    $0x30,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e57(%rip),%rcx
cltd
idivl  (%rcx)
cmp    $0x0,%edx
jne    11ab <bitprint+0x9b>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ab <bitprint+0x9b>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11b0 <bitprint+0xa0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <bitprint+0x33>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitprint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2ebe(%rip),%r14
mov    (%r14),%r15d
shl    $0x2,%r15d
lea    -0x1(%r15),%ecx
mov    $0x1,%ebx
mov    $0x1,%r12d
shl    %cl,%r12d
test   %r15d,%r15d
jle    1195 <bitprint+0x85>
mov    %edi,%ebp
mov    %r15d,%r13d
neg    %r13d
jmp    1165 <bitprint+0x55>
nopw   0x0(%rax,%rax,1)
add    %ebp,%ebp
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     1195 <bitprint+0x85>
mov    %ebp,%eax
and    %r12d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
cltd
idivl  (%r14)
test   %edx,%edx
jne    1150 <bitprint+0x40>
cmp    %r15d,%ebx
jge    1150 <bitprint+0x40>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1150 <bitprint+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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