#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 */
typedef int /*<<< orphan*/ n;

/* Variables and functions */
int CHAR_BIT;
int /*<<< orphan*/ putchar(char);
void dec_to_bin(int n) {
  unsigned int mask = 1 << sizeof(n) * CHAR_BIT - 1;
  int sp = 1;
  while (mask) {
    putchar(mask & n ? '1' : '0');
    if (sp++ % 4 == 0)
      putchar(' ');
    mask >>= 1;
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<dec_to_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
movslq (%rax),%rax
shl    $0x2,%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     119c <dec_to_bin+0x8c>
mov    -0x8(%rbp),%edx
and    -0x4(%rbp),%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118e <dec_to_bin+0x7e>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <dec_to_bin+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dec_to_bin>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    0x2ec2(%rip),%rax
mov    (%rax),%cl
shl    $0x2,%cl
add    $0xff,%cl
mov    $0x1,%ebp
mov    $0x1,%ebx
shl    %cl,%ebx
jmp    114e <dec_to_bin+0x3e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
shr    %eax
add    $0x1,%ebp
cmp    $0x1,%ebx
mov    %eax,%ebx
jbe    1175 <dec_to_bin+0x65>
mov    %ebx,%eax
and    %r14d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
test   $0x3,%bpl
jne    1140 <dec_to_bin+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <dec_to_bin+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

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

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