#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_char_as_binary(char input) {
  int i;
  for (i = 0; i < 8; i++) {
    char shift_byte = 0x01 << (7 - i);
    if (shift_byte & input) {
      printf("1");
    } else {
      printf("0");
    }
  }
}


x86 assembly (clang, -O0):
<print_char_as_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1184 <print_char_as_binary+0x74>
mov    $0x7,%ecx
sub    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
movsbl -0x1(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1165 <print_char_as_binary+0x55>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1171 <print_char_as_binary+0x61>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <print_char_as_binary+0x66>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <print_char_as_binary+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char_as_binary>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
test   %bl,%bl
setns  %dil
xor    $0x31,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
and    $0x40,%eax
cmp    $0x1,%eax
mov    $0x31,%ebp
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
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

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

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