#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, char *);
void print_char_bits(char a, char *desc) {
  char s[9], b;
  int i;
  memset(s, '0', 9);
  s[8] = '\0';
  for (i = 0; a >> i && i <= 7; i++) {
    b = (a & (1 << i)) != 0 ? '1' : '0';
    s[7 - i] = b;
  }
  printf("  %s: %s\n", desc, s);
}


x86 assembly (clang, -O0):
<print_char_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x19(%rbp),%rdi
mov    $0x30,%esi
mov    $0x9,%edx
call   1040 <memset@plt>
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x20(%rbp)
movsbl -0x1(%rbp),%eax
mov    -0x20(%rbp),%ecx
sar    %cl,%eax
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1173 <print_char_bits+0x53>
cmpl   $0x7,-0x20(%rbp)
setle  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1183 <print_char_bits+0x63>
jmp    11c5 <print_char_bits+0xa5>
movsbl -0x1(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%cl
mov    $0x7,%eax
sub    -0x20(%rbp),%eax
cltq
mov    %cl,-0x19(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1150 <print_char_bits+0x30>
mov    -0x10(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char_bits>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xf(%rsp),%rdi
mov    $0x30,%esi
mov    $0x9,%edx
call   1040 <memset@plt>
movb   $0x0,0x17(%rsp)
test   %bpl,%bpl
je     11f8 <print_char_bits+0xd8>
mov    %ebp,%eax
and    $0x1,%al
or     $0x30,%al
mov    %al,0x16(%rsp)
cmp    $0x2,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%al
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x15(%rsp)
cmp    $0x4,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%ecx
and    $0x4,%ecx
cmp    $0x1,%ecx
sbb    $0x0,%al
mov    %al,0x14(%rsp)
cmp    $0x8,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%eax
and    $0x8,%eax
cmp    $0x1,%eax
mov    $0x31,%al
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x13(%rsp)
cmp    $0x10,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%ecx
and    $0x10,%ecx
cmp    $0x1,%ecx
sbb    $0x0,%al
mov    %al,0x12(%rsp)
cmp    $0x20,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%eax
and    $0x20,%eax
cmp    $0x1,%eax
mov    $0x31,%al
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x11(%rsp)
cmp    $0x40,%bpl
jb     11f8 <print_char_bits+0xd8>
mov    %ebp,%ecx
and    $0x40,%ecx
cmp    $0x1,%ecx
sbb    $0x0,%al
mov    %al,0x10(%rsp)
test   %bpl,%bpl
jns    11f8 <print_char_bits+0xd8>
and    $0x80,%ebp
cmp    $0x1,%ebp
mov    $0x31,%al
sbb    $0x0,%al
mov    %al,0xf(%rsp)
lea    0xe01(%rip),%rdi
lea    0xf(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" %s: %s\0A\00"
define void @print_char_bits(i8 signext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca [9 x i8]
%6 = alloca i8
%7 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 48, i32 9)
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 8
store i8 0, i8* %10
store i32 0, i32* %7
br label %11
11: ; preds = %37, %2
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = load i32, i32* %7
%15 = ashr i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i32, i32* %7
%19 = icmp sle i32 %18, 7
br label %20
20: ; preds = %17, %11
%21 = phi i1 [ false, %11 ], [ %19, %17 ]
br i1 %21, label %22, label %40
22: ; preds = %20
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = load i32, i32* %7
%26 = shl i32 1, %25
%27 = and i32 %24, %26
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 49, i32 48
%31 = trunc i32 %30 to i8
store i8 %31, i8* %6
%32 = load i8, i8* %6
%33 = load i32, i32* %7
%34 = sub nsw i32 7, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %22
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %11
40: ; preds = %20
%41 = load i8*, i8** %4
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %41, i8* %42)
ret void
}

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