#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(char byte) {
  int i;
  for (i = 0; i < 8; i++) {
    printf("%d", ((byte << i) & 0x80) != 0);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1164 <print_char+0x54>
movsbl -0x1(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    %cl,%eax
and    $0x80,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <print_char+0x15>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
movzbl %bl,%ebp
mov    %ebp,%esi
shr    $0x7,%esi
lea    0xecb(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
shr    %ebp
and    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_char(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = load i32, i32* %3
%11 = shl i32 %9, %10
%12 = and i32 %11, 128
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %4
19: ; preds = %4
%20 = 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 = [3 x i8] c"%d\00"
define void @print_char(i8 signext %0) {
%2 = zext i8 %0 to i32
%3 = lshr i32 %2, 7
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = lshr i32 %2, 6
%6 = and i32 %5, 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = lshr i32 %2, 5
%9 = and i32 %8, 1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = lshr i32 %2, 4
%12 = and i32 %11, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = lshr i32 %2, 3
%15 = and i32 %14, 1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = lshr i32 %2, 2
%18 = and i32 %17, 1
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = lshr i32 %2, 1
%21 = and i32 %20, 1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = and i32 %2, 1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = tail call i32 @putchar(i32 10)
ret void
}