#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 CHAR_BIT;
int /*<<< orphan*/ putchar(char);
void printCharPattern(char c) {
  int mask = 0x01 << (CHAR_BIT - 1);
  int i;
  for (i = CHAR_BIT; i > 0; --i) {
    int code = c & mask;
    if (code) {
      putchar('1');
    } else {
      putchar('0');
    }
    mask >>= 1;
  }
}


x86 assembly (clang, -O0):
<printCharPattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    0x2ebb(%rip),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    118e <printCharPattern+0x7e>
movsbl -0x1(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116d <printCharPattern+0x5d>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    1177 <printCharPattern+0x67>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <printCharPattern+0x30>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printCharPattern>:
push   %rbp
push   %r14
push   %rbx
mov    0x2ec5(%rip),%rax
mov    (%rax),%ebx
test   %ebx,%ebx
jle    115f <printCharPattern+0x4f>
lea    -0x1(%rbx),%ecx
mov    $0x1,%ebp
shl    %cl,%ebp
movsbl %dil,%r14d
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%eax
and    %r14d,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
sar    %ebp
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1140 <printCharPattern+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @printCharPattern(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %2
%6 = load i32, i32* @CHAR_BIT
%7 = sub nsw i32 %6, 1
%8 = shl i32 1, %7
store i32 %8, i32* %3
%9 = load i32, i32* @CHAR_BIT
store i32 %9, i32* %4
br label %10
10: ; preds = %27, %1
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %30
13: ; preds = %10
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = load i32, i32* %3
%17 = and i32 %15, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @putchar(i8 signext 49)
br label %24
22: ; preds = %13
%23 = call i32 @putchar(i8 signext 48)
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* %3
%26 = ashr i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %24
%28 = load i32, i32* %4
%29 = add nsw i32 %28, -1
store i32 %29, i32* %4
br label %10
30: ; preds = %10
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @printCharPattern(i8 signext %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = add nsw i32 %2, -1
%6 = shl nuw i32 1, %5
%7 = sext i8 %0 to i32
br label %8
8: ; preds = %4, %8
%9 = phi i32 [ %6, %4 ], [ %15, %8 ]
%10 = phi i32 [ %2, %4 ], [ %16, %8 ]
%11 = and i32 %9, %7
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 48, i8 49
%14 = tail call i32 @putchar(i8 signext %13)
%15 = ashr i32 %9, 1
%16 = add nsw i32 %10, -1
%17 = icmp sgt i32 %10, 1
br i1 %17, label %8, label %18
18: ; preds = %8, %1
ret void
}