#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ out;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
void printarr(uint8_t *arr) {
  static char out[20 + 1];
  memset(&out[0], 0, sizeof(out[0]) * sizeof(out));
  out[20] = 0;
  for (int i = 0; i < (20 % 8 == 0 ? 20 / 8 : 20 / 8 + 1); ++i) {
    const uint8_t byte = arr[i];
    for (int j = 0; j < 8; ++j) {
      const uint8_t val = (byte >> j) & 0x1;
      const size_t idx = i * 8 + j;
      if (idx >= 20) {
        break;
      }
      out[idx] = '0' + val;
    }
  }
  printf("%s\n", &out[0]);
}


x86 assembly (clang, -O0):
<printarr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
movb   $0x0,0x2f0e(%rip)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11da <printarr+0xba>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11c7 <printarr+0xa7>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
add    -0x14(%rbp),%eax
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x14,-0x20(%rbp)
jb     11a3 <printarr+0x83>
jmp    11c7 <printarr+0xa7>
mov    -0x18(%rbp),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rcx
lea    0x2e8a(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <printarr+0x4c>
jmp    11cc <printarr+0xac>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <printarr+0x2d>
lea    0xe1f(%rip),%rdi
lea    0x2e58(%rip),%rsi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printarr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f12(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
movb   $0x0,0x2f10(%rip)
mov    (%rbx),%al
mov    %eax,%ecx
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2eec(%rip)
mov    %eax,%ecx
shr    %cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2edd(%rip)
mov    %eax,%ecx
shr    $0x2,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ecd(%rip)
mov    %eax,%ecx
shr    $0x3,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ebd(%rip)
mov    %eax,%ecx
shr    $0x4,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ead(%rip)
mov    %eax,%ecx
shr    $0x5,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e9d(%rip)
mov    %eax,%ecx
shr    $0x6,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e8d(%rip)
shr    $0x7,%al
or     $0x30,%al
mov    %al,0x2e83(%rip)
mov    0x4(%rbx),%al
mov    %eax,%ecx
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e73(%rip)
mov    %eax,%ecx
shr    %cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e64(%rip)
mov    %eax,%ecx
shr    $0x2,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e54(%rip)
mov    %eax,%ecx
shr    $0x3,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e44(%rip)
mov    %eax,%ecx
shr    $0x4,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e34(%rip)
mov    %eax,%ecx
shr    $0x5,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e24(%rip)
mov    %eax,%ecx
shr    $0x6,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e14(%rip)
shr    $0x7,%al
or     $0x30,%al
mov    %al,0x2e0a(%rip)
mov    0x8(%rbx),%al
mov    %eax,%ecx
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2dfa(%rip)
mov    %eax,%ecx
shr    %cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2deb(%rip)
mov    %eax,%ecx
shr    $0x2,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ddb(%rip)
shr    $0x3,%al
and    $0x1,%al
or     $0x30,%al
mov    %al,0x2dcf(%rip)
lea    0xd75(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@printarr.out = internal global [21 x i8] zeroinitializer
@.str = [4 x i8] c"%s\0A\00"
define void @printarr(i32* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 0), i32 0, i32 21)
store i8 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 20)
%3 = load i32, i32* %0
%4 = trunc i32 %3 to i8
%5 = and i8 %4, 1
%6 = or i8 %5, 48
store i8 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 0)
%7 = trunc i32 %3 to i8
%8 = lshr i8 %7, 1
%9 = and i8 %8, 1
%10 = or i8 %9, 48
store i8 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 1)
%11 = trunc i32 %3 to i8
%12 = lshr i8 %11, 2
%13 = and i8 %12, 1
%14 = or i8 %13, 48
store i8 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 2)
%15 = trunc i32 %3 to i8
%16 = lshr i8 %15, 3
%17 = and i8 %16, 1
%18 = or i8 %17, 48
store i8 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 3)
%19 = trunc i32 %3 to i8
%20 = lshr i8 %19, 4
%21 = and i8 %20, 1
%22 = or i8 %21, 48
store i8 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 4)
%23 = trunc i32 %3 to i8
%24 = lshr i8 %23, 5
%25 = and i8 %24, 1
%26 = or i8 %25, 48
store i8 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 5)
%27 = trunc i32 %3 to i8
%28 = lshr i8 %27, 6
%29 = and i8 %28, 1
%30 = or i8 %29, 48
store i8 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 6)
%31 = trunc i32 %3 to i8
%32 = lshr i8 %31, 7
%33 = or i8 %32, 48
store i8 %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 7)
%34 = getelementptr inbounds i32, i32* %0, i64 1
%35 = load i32, i32* %34
%36 = trunc i32 %35 to i8
%37 = and i8 %36, 1
%38 = or i8 %37, 48
store i8 %38, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 8)
%39 = trunc i32 %35 to i8
%40 = lshr i8 %39, 1
%41 = and i8 %40, 1
%42 = or i8 %41, 48
store i8 %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 9)
%43 = trunc i32 %35 to i8
%44 = lshr i8 %43, 2
%45 = and i8 %44, 1
%46 = or i8 %45, 48
store i8 %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 10)
%47 = trunc i32 %35 to i8
%48 = lshr i8 %47, 3
%49 = and i8 %48, 1
%50 = or i8 %49, 48
store i8 %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 11)
%51 = trunc i32 %35 to i8
%52 = lshr i8 %51, 4
%53 = and i8 %52, 1
%54 = or i8 %53, 48
store i8 %54, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 12)
%55 = trunc i32 %35 to i8
%56 = lshr i8 %55, 5
%57 = and i8 %56, 1
%58 = or i8 %57, 48
store i8 %58, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 13)
%59 = trunc i32 %35 to i8
%60 = lshr i8 %59, 6
%61 = and i8 %60, 1
%62 = or i8 %61, 48
store i8 %62, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 14)
%63 = trunc i32 %35 to i8
%64 = lshr i8 %63, 7
%65 = or i8 %64, 48
store i8 %65, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 15)
%66 = getelementptr inbounds i32, i32* %0, i64 2
%67 = load i32, i32* %66
%68 = trunc i32 %67 to i8
%69 = and i8 %68, 1
%70 = or i8 %69, 48
store i8 %70, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 16)
%71 = trunc i32 %67 to i8
%72 = lshr i8 %71, 1
%73 = and i8 %72, 1
%74 = or i8 %73, 48
store i8 %74, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 17)
%75 = trunc i32 %67 to i8
%76 = lshr i8 %75, 2
%77 = and i8 %76, 1
%78 = or i8 %77, 48
store i8 %78, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 18)
%79 = trunc i32 %67 to i8
%80 = lshr i8 %79, 3
%81 = and i8 %80, 1
%82 = or i8 %81, 48
store i8 %82, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 19)
%83 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @printarr.out, i64 0, i64 0))
ret void
}