#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 *, char *);
void printbits(unsigned long num) {
  char bbuf[33];
  int i, j;
  for (i = 32; i >= 0;) {
    j = 32 - i;
    bbuf[j] = (((num >> --i) & 1) == 1 ? '1' : '0');
  }
  bbuf[32 - i] = '\0';
  printf(" %s", bbuf);
}


x86 assembly (clang, -O0):
<printbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x20,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     1170 <printbits+0x60>
mov    $0x20,%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
mov    %eax,%eax
mov    %eax,%ecx
shr    %cl,%rdx
and    $0x1,%rdx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x1,%rdx
cmove  %ecx,%eax
mov    %al,%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
jmp    1123 <printbits+0x13>
mov    $0x20,%eax
sub    -0x34(%rbp),%eax
cltq
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbits>:
sub    $0x28,%rsp
movq   %rdi,%xmm0
pshufd $0x44,%xmm0,%xmm1
movdqa 0xed9(%rip),%xmm9
pand   %xmm1,%xmm9
movdqa 0xedb(%rip),%xmm10
pand   %xmm1,%xmm10
movdqa 0xede(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xee2(%rip),%xmm5
pand   %xmm1,%xmm5
movdqa 0xee6(%rip),%xmm6
pand   %xmm1,%xmm6
movdqa 0xeea(%rip),%xmm7
pand   %xmm1,%xmm7
movdqa 0xeee(%rip),%xmm0
pand   %xmm1,%xmm0
movdqa 0xef2(%rip),%xmm2
pand   %xmm1,%xmm2
pxor   %xmm8,%xmm8
pcmpeqd %xmm8,%xmm2
pshufd $0xb1,%xmm2,%xmm3
pand   %xmm2,%xmm3
pcmpeqd %xmm8,%xmm0
pshufd $0xb1,%xmm0,%xmm2
pand   %xmm0,%xmm2
packssdw %xmm3,%xmm2
pcmpeqd %xmm8,%xmm7
pshufd $0xb1,%xmm7,%xmm0
pand   %xmm7,%xmm0
pcmpeqd %xmm8,%xmm6
pshufd $0xb1,%xmm6,%xmm7
pand   %xmm6,%xmm7
packssdw %xmm0,%xmm7
packssdw %xmm2,%xmm7
pcmpeqd %xmm8,%xmm5
pshufd $0xb1,%xmm5,%xmm0
pand   %xmm5,%xmm0
pcmpeqd %xmm8,%xmm4
pshufd $0xb1,%xmm4,%xmm2
pand   %xmm4,%xmm2
packssdw %xmm0,%xmm2
pcmpeqd %xmm8,%xmm10
pshufd $0xb1,%xmm10,%xmm0
pand   %xmm10,%xmm0
pcmpeqd %xmm8,%xmm9
pshufd $0xb1,%xmm9,%xmm3
pand   %xmm9,%xmm3
packssdw %xmm0,%xmm3
packssdw %xmm2,%xmm3
packsswb %xmm7,%xmm3
movdqa 0xe60(%rip),%xmm9
paddb  %xmm9,%xmm3
movdqa %xmm3,(%rsp)
movdqa 0xe5d(%rip),%xmm10
pand   %xmm1,%xmm10
movdqa 0xe5f(%rip),%xmm11
pand   %xmm1,%xmm11
movdqa 0xe62(%rip),%xmm5
pand   %xmm1,%xmm5
movdqa 0xe66(%rip),%xmm6
pand   %xmm1,%xmm6
movdqa 0xe6a(%rip),%xmm0
pand   %xmm1,%xmm0
movdqa 0xe6e(%rip),%xmm7
pand   %xmm1,%xmm7
movdqa 0xe72(%rip),%xmm2
pand   %xmm1,%xmm2
pand   0xe76(%rip),%xmm1
pcmpeqd %xmm8,%xmm1
pshufd $0xb1,%xmm1,%xmm3
pand   %xmm1,%xmm3
pcmpeqd %xmm8,%xmm2
pshufd $0xb1,%xmm2,%xmm4
pand   %xmm2,%xmm4
packssdw %xmm3,%xmm4
pcmpeqd %xmm8,%xmm7
pshufd $0xb1,%xmm7,%xmm2
pand   %xmm7,%xmm2
pcmpeqd %xmm8,%xmm0
pshufd $0xb1,%xmm0,%xmm1
pand   %xmm0,%xmm1
packssdw %xmm2,%xmm1
packssdw %xmm4,%xmm1
pcmpeqd %xmm8,%xmm6
pshufd $0xb1,%xmm6,%xmm0
pand   %xmm6,%xmm0
pcmpeqd %xmm8,%xmm5
pshufd $0xb1,%xmm5,%xmm2
pand   %xmm5,%xmm2
packssdw %xmm0,%xmm2
pcmpeqd %xmm8,%xmm11
pshufd $0xb1,%xmm11,%xmm0
pand   %xmm11,%xmm0
pcmpeqd %xmm8,%xmm10
pshufd $0xb1,%xmm10,%xmm3
pand   %xmm10,%xmm3
packssdw %xmm0,%xmm3
packssdw %xmm2,%xmm3
packsswb %xmm1,%xmm3
paddb  %xmm9,%xmm3
movdqa %xmm3,0x10(%rsp)
movb   $0x0,0x21(%rsp)
lea    0xddf(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %s\00"
define void @printbits(i64 %0) {
%2 = alloca i64
%3 = alloca [33 x i8]
%4 = alloca i32
%5 = alloca i32
store i64 %0, i64* %2
store i32 32, i32* %4
br label %6
6: ; preds = %9, %1
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sub nsw i32 32, %10
store i32 %11, i32* %5
%12 = load i64, i64* %2
%13 = load i32, i32* %4
%14 = add nsw i32 %13, -1
store i32 %14, i32* %4
%15 = zext i32 %14 to i64
%16 = lshr i64 %12, %15
%17 = and i64 %16, 1
%18 = icmp eq i64 %17, 1
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 49, i32 48
%21 = trunc i32 %20 to i8
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 %23
store i8 %21, i8* %24
br label %6
25: ; preds = %6
%26 = load i32, i32* %4
%27 = sub nsw i32 32, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" %s\00"
define void @printbits(i64 %0) {
%2 = alloca [33 x i8]
%3 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%4 = insertelement <16 x i64> poison, i64 %0, i64 0
%5 = shufflevector <16 x i64> %4, <16 x i64> poison, <16 x i32> zeroinitializer
%6 = and <16 x i64> %5, <i64 2147483648, i64 1073741824, i64 536870912, i64 268435456, i64 134217728, i64 67108864, i64 33554432, i64 16777216, i64 8388608, i64 4194304, i64 2097152, i64 1048576, i64 524288, i64 262144, i64 131072, i64 65536>
%7 = icmp eq <16 x i64> %6, zeroinitializer
%8 = select <16 x i1> %7, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%9 = bitcast [33 x i8]* %2 to <16 x i8>*
store <16 x i8> %8, <16 x i8>* %9
%10 = and <16 x i64> %5, <i64 32768, i64 16384, i64 8192, i64 4096, i64 2048, i64 1024, i64 512, i64 256, i64 128, i64 64, i64 32, i64 16, i64 8, i64 4, i64 2, i64 1>
%11 = icmp eq <16 x i64> %10, zeroinitializer
%12 = select <16 x i1> %11, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%13 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 16
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %14
%15 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 33
store i8 0, i8* %15
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}