#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 *);
void showbits(char n) {
  int i, k, andmask;
  for (i = 7; i >= 0; i--) {
    andmask = 1 << i;
    k = n & andmask;
    k == 0 ? printf("0") : printf("1");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<showbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x7,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     117b <showbits+0x6b>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1161 <showbits+0x51>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
jmp    116d <showbits+0x5d>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <showbits+0x15>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showbits>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
and    $0x80,%eax
cmp    $0x1,%eax
mov    $0x31,%ebp
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x4,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x2,%eax
cmp    $0x1,%eax
sbb    $0x0,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
and    $0x1,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @showbits(i8 signext %0) {
%2 = zext i8 %0 to i32
%3 = and i32 %2, 128
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 48, i32 49
%6 = tail call i32 @putchar(i32 %5)
%7 = and i32 %2, 64
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 48, i32 49
%10 = tail call i32 @putchar(i32 %9)
%11 = and i32 %2, 32
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 48, i32 49
%14 = tail call i32 @putchar(i32 %13)
%15 = and i32 %2, 16
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 48, i32 49
%18 = tail call i32 @putchar(i32 %17)
%19 = and i32 %2, 8
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32 48, i32 49
%22 = tail call i32 @putchar(i32 %21)
%23 = and i32 %2, 4
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i32 48, i32 49
%26 = tail call i32 @putchar(i32 %25)
%27 = and i32 %2, 2
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i32 48, i32 49
%30 = tail call i32 @putchar(i32 %29)
%31 = and i32 %2, 1
%32 = or i32 %31, 48
%33 = tail call i32 @putchar(i32 %32)
%34 = tail call i32 @putchar(i32 10)
ret void
}