#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 *, ...);
int showbits(int s_num) {
  int bit_size;
  int count;
  count = 0;
  bit_size = 8 * sizeof(void *);
  for (; bit_size >= 1; bit_size--) {
    printf("%d", (1 & (s_num >> (bit_size - 1))));
    count++;
    if (count % 8 == 0)
      printf(" ");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<showbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x40,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     118d <showbits+0x7d>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117a <showbits+0x6a>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117f <showbits+0x6f>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <showbits+0x19>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showbits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    $0x3f,%ebp
mov    $0x1,%ebx
lea    0xec5(%rip),%r14
jmp    1148 <showbits+0x28>
nopl   (%rax)
add    $0x1,%ebx
add    $0xffffffff,%ebp
jae    116d <showbits+0x4d>
mov    %r15d,%esi
mov    %ebp,%ecx
shr    %cl,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x7,%bl
jne    1140 <showbits+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <showbits+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @showbits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
store i32 64, i32* %3
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 1
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = ashr i32 %9, %11
%13 = and i32 1, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = srem i32 %17, 8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %8
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %5
26: ; preds = %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @showbits(i32 %0) {
br label %2
2: ; preds = %1, %14
%3 = phi i32 [ 0, %1 ], [ %9, %14 ]
%4 = phi i32 [ 64, %1 ], [ %5, %14 ]
%5 = add nsw i32 %4, -1
%6 = lshr i32 %0, %5
%7 = and i32 %6, 1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = add nuw nsw i32 %3, 1
%10 = and i32 %9, 7
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @putchar(i32 32)
br label %14
14: ; preds = %2, %12
%15 = icmp eq i32 %9, 64
br i1 %15, label %16, label %2
16: ; preds = %14
%17 = tail call i32 @putchar(i32 10)
ret i32 0
}