#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 print_bin(char x) {
  printf("bin: "
         "%d%d%d%d%d%d%d%d"
         "\n",
         (x & 0x80 ? 1 : 0), (x & 0x40 ? 1 : 0), (x & 0x20 ? 1 : 0),
         (x & 0x10 ? 1 : 0), (x & 0x08 ? 1 : 0), (x & 0x04 ? 1 : 0),
         (x & 0x02 ? 1 : 0), (x & 0x01 ? 1 : 0));
  printf("\n");
}


x86 assembly (clang, -O0):
<print_bin>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x28,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
and    $0x80,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
movsbl -0x9(%rbp),%ecx
and    $0x40,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
movsbl -0x9(%rbp),%edi
and    $0x20,%edi
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%ecx
movsbl -0x9(%rbp),%edi
and    $0x10,%edi
xor    %r8d,%r8d
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%r8d
movsbl -0x9(%rbp),%edi
and    $0x8,%edi
xor    %r9d,%r9d
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%r9d
movsbl -0x9(%rbp),%edi
and    $0x4,%edi
xor    %r11d,%r11d
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%r11d
movsbl -0x9(%rbp),%edi
and    $0x2,%edi
xor    %r10d,%r10d
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%r10d
movsbl -0x9(%rbp),%ebx
and    $0x1,%ebx
xor    %eax,%eax
mov    $0x1,%edi
cmp    $0x0,%ebx
cmovne %edi,%eax
lea    0xe2f(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_bin>:
push   %rbx
mov    %edi,%r10d
movzbl %r10b,%r11d
mov    %r11d,%esi
shr    $0x7,%esi
mov    %r11d,%edx
shr    $0x6,%edx
and    $0x1,%edx
mov    %r11d,%ecx
shr    $0x5,%ecx
and    $0x1,%ecx
mov    %r11d,%r8d
shr    $0x4,%r8d
and    $0x1,%r8d
mov    %r11d,%r9d
shr    $0x3,%r9d
and    $0x1,%r9d
mov    %r11d,%ebx
shr    $0x2,%ebx
and    $0x1,%ebx
shr    %r11d
and    $0x1,%r11d
and    $0x1,%r10d
sub    $0x8,%rsp
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
push   %r10
push   %r11
push   %rbx
call   1040 <printf@plt>
add    $0x20,%rsp
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"bin: %d%d%d%d%d%d%d%d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_bin(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = and i32 %4, 128
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 1, i32 0
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = and i32 %10, 64
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 1, i32 0
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = and i32 %16, 32
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 1, i32 0
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = and i32 %22, 16
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 1, i32 0
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = and i32 %28, 8
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = and i32 %34, 4
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 1, i32 0
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = and i32 %40, 2
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i64
%44 = select i1 %42, i32 1, i32 0
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 1, i32 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %14, i32 %20, i32 %26, i32 %32, i32 %38, i32 %44, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"bin: %d%d%d%d%d%d%d%d\0A\00"
define void @print_bin(i8 signext %0) {
%2 = zext i8 %0 to i32
%3 = lshr i32 %2, 7
%4 = lshr i32 %2, 6
%5 = and i32 %4, 1
%6 = lshr i32 %2, 5
%7 = and i32 %6, 1
%8 = lshr i32 %2, 4
%9 = and i32 %8, 1
%10 = lshr i32 %2, 3
%11 = and i32 %10, 1
%12 = lshr i32 %2, 2
%13 = and i32 %12, 1
%14 = lshr i32 %2, 1
%15 = and i32 %14, 1
%16 = and i32 %2, 1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5, i32 %7, i32 %9, i32 %11, i32 %13, i32 %15, i32 %16)
%18 = tail call i32 @putchar(i32 10)
ret void
}