#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 showbits(unsigned int x) {
  for (int i = 11; i >= 0; i--) {
    if ((x & (1 << i))) {
      putchar('1');
    } else {
      putchar('0');
    }
    if (((i % 3) == 0) && (i != 0) && (i != 15)) {
      putchar(' ');
    }
  }
}


x86 assembly (clang, -O0):
<showbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xb,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11a4 <showbits+0x94>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1155 <showbits+0x45>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    115f <showbits+0x4f>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1191 <showbits+0x81>
cmpl   $0x0,-0x8(%rbp)
je     1191 <showbits+0x81>
cmpl   $0xf,-0x8(%rbp)
je     1191 <showbits+0x81>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1196 <showbits+0x86>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <showbits+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showbits>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0xb,%ebx
jmp    1129 <showbits+0x19>
nopl   0x0(%rax)
lea    -0x1(%rbx),%eax
test   %ebx,%ebx
mov    %eax,%ebx
jle    115b <showbits+0x4b>
bt     %ebx,%ebp
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
imul   $0xaaaaaaab,%ebx,%eax
cmp    $0x55555555,%eax
ja     1120 <showbits+0x10>
test   %ebx,%ebx
je     1120 <showbits+0x10>
cmp    $0xf,%ebx
je     1120 <showbits+0x10>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1120 <showbits+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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