#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 printArray(unsigned char msg[]) {
  unsigned char n;
  for (unsigned char k = 0; k < 4; k++) {
    n = msg[k];
    for (unsigned char i = 7; i >= 0; i--) {
      if ((n >> i) & 1) {
        printf("1");
      } else {
        printf("0");
      }
    }
    printf("");
  }
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
cmp    $0x4,%eax
jge    11aa <printArray+0x9a>
mov    -0x8(%rbp),%rax
movzbl -0xa(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
movb   $0x7,-0xb(%rbp)
movzbl -0xb(%rbp),%eax
cmp    $0x0,%eax
jl     1191 <printArray+0x81>
movzbl -0x9(%rbp),%eax
movzbl -0xb(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1173 <printArray+0x63>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    117f <printArray+0x6f>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    1184 <printArray+0x74>
mov    -0xb(%rbp),%al
add    $0xff,%al
mov    %al,-0xb(%rbp)
jmp    113f <printArray+0x2f>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
jmp    1120 <printArray+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %rbx
push   %rax
movzbl (%rdi),%ebx
mov    $0x7,%bpl
nopl   0x0(%rax)
movzbl %bpl,%ebp
bt     %ebp,%ebx
mov    $0x31,%edi
adc    $0xffffffff,%edi
call   1030 <putchar@plt>
add    $0xff,%bpl
jmp    1120 <printArray+0x10>

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

LLVM IR (-O2):
define void @printArray(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
br label %4
4: ; preds = %4, %1
%5 = phi i8 [ 7, %1 ], [ %12, %4 ]
%6 = zext i8 %5 to i32
%7 = shl nuw i32 1, %6
%8 = and i32 %7, %3
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 48, i32 49
%11 = tail call i32 @putchar(i32 %10)
%12 = add i8 %5, -1
br label %4
}