#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 */
char *calloc(int, int);
char *convert_binary_integer_array_to_character_array(int *binary_integer_array,
                                                      int number_of_elements) {
  char *converted_array = calloc(2 * number_of_elements + 1, sizeof(char));
  for (int i = 0; i < number_of_elements; ++i) {
    converted_array[2 * i] = binary_integer_array[i] ? '1' : '0';
    converted_array[2 * i + 1] = ' ';
  }
  converted_array[2 * number_of_elements - 1] = '\0';
  return converted_array;
}


x86 assembly (clang, -O0):
<convert_binary_integer_array_to_character_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1198 <convert_binary_integer_array_to_character_array+0x88>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <convert_binary_integer_array_to_character_array+0x2d>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_binary_integer_array_to_character_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
movslq %esi,%rbp
mov    %rbp,%r14
add    %rbp,%r14
lea    0x1(%r14),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
test   %ebp,%ebp
jle    11da <convert_binary_integer_array_to_character_array+0xca>
mov    %r15d,%ebp
cmp    $0x8,%r15d
jae    1149 <convert_binary_integer_array_to_character_array+0x39>
xor    %edx,%edx
jmp    11c0 <convert_binary_integer_array_to_character_array+0xb0>
mov    %ebp,%edx
and    $0xfffffff8,%edx
mov    %rbp,%rsi
add    %rbp,%rsi
and    $0xfffffffffffffff0,%rsi
xor    %edi,%edi
pxor   %xmm0,%xmm0
movdqa 0xe9a(%rip),%xmm1
movdqa 0xea2(%rip),%xmm2
xchg   %ax,%ax
movdqu (%rbx,%rdi,2),%xmm3
movdqu 0x10(%rbx,%rdi,2),%xmm4
pcmpeqd %xmm0,%xmm3
packssdw %xmm3,%xmm3
packsswb %xmm3,%xmm3
paddb  %xmm1,%xmm3
pcmpeqd %xmm0,%xmm4
packssdw %xmm4,%xmm4
packsswb %xmm4,%xmm4
paddb  %xmm1,%xmm4
punpcklbw %xmm2,%xmm3
punpcklbw %xmm2,%xmm4
punpcklqdq %xmm4,%xmm3
movdqu %xmm3,(%rax,%rdi,1)
add    $0x10,%rdi
cmp    %rdi,%rsi
jne    1170 <convert_binary_integer_array_to_character_array+0x60>
cmp    %rbp,%rdx
je     11da <convert_binary_integer_array_to_character_array+0xca>
nopw   0x0(%rax,%rax,1)
cmpl   $0x1,(%rbx,%rdx,4)
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,(%rax,%rdx,2)
movb   $0x20,0x1(%rax,%rdx,2)
add    $0x1,%rdx
cmp    %rdx,%rbp
jne    11c0 <convert_binary_integer_array_to_character_array+0xb0>
movb   $0x0,-0x1(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @convert_binary_integer_array_to_character_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = mul nsw i32 2, %7
%9 = add nsw i32 %8, 1
%10 = call i8* @calloc(i32 %9, i32 1)
store i8* %10, i8** %5
store i32 0, i32* %6
br label %11
11: ; preds = %36, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 49, i32 48
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = mul nsw i32 2, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8 %24, i8* %29
%30 = load i8*, i8** %5
%31 = load i32, i32* %6
%32 = mul nsw i32 2, %31
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 32, i8* %35
br label %36
36: ; preds = %15
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %11
39: ; preds = %11
%40 = load i8*, i8** %5
%41 = load i32, i32* %4
%42 = mul nsw i32 2, %41
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %40, i64 %44
store i8 0, i8* %45
%46 = load i8*, i8** %5
ret i8* %46
}

LLVM IR (-O2):
define noalias i8* @convert_binary_integer_array_to_character_array(i32* nocapture %0, i32 %1) {
%3 = shl nsw i32 %1, 1
%4 = or i32 %3, 1
%5 = tail call i8* @calloc(i32 %4, i32 1)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %42
7: ; preds = %2
%8 = zext i32 %1 to i64
%9 = icmp ult i32 %1, 8
br i1 %9, label %40, label %10
10: ; preds = %7
%11 = and i64 %8, 4294967288
%12 = getelementptr inbounds i8, i8* %5, i64 -1
%13 = getelementptr inbounds i8, i8* %5, i64 -1
br label %14
14: ; preds = %14, %10
%15 = phi i64 [ 0, %10 ], [ %36, %14 ]
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = bitcast i32* %16 to <4 x i32>*
%18 = load <4 x i32>, <4 x i32>* %17
%19 = getelementptr inbounds i32, i32* %16, i64 4
%20 = bitcast i32* %19 to <4 x i32>*
%21 = load <4 x i32>, <4 x i32>* %20
%22 = icmp eq <4 x i32> %18, zeroinitializer
%23 = icmp eq <4 x i32> %21, zeroinitializer
%24 = select <4 x i1> %22, <4 x i8> <i8 48, i8 48, i8 48, i8 48>, <4 x i8> <i8 49, i8 49, i8 49, i8 49>
%25 = select <4 x i1> %23, <4 x i8> <i8 48, i8 48, i8 48, i8 48>, <4 x i8> <i8 49, i8 49, i8 49, i8 49>
%26 = shl nuw nsw i64 %15, 1
%27 = shl i64 %15, 1
%28 = or i64 %26, 1
%29 = or i64 %27, 9
%30 = getelementptr inbounds i8, i8* %12, i64 %28
%31 = bitcast i8* %30 to <8 x i8>*
%32 = getelementptr inbounds i8, i8* %13, i64 %29
%33 = bitcast i8* %32 to <8 x i8>*
%34 = shufflevector <4 x i8> %24, <4 x i8> <i8 32, i8 32, i8 32, i8 32>, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
store <8 x i8> %34, <8 x i8>* %31
%35 = shufflevector <4 x i8> %25, <4 x i8> <i8 32, i8 32, i8 32, i8 32>, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
store <8 x i8> %35, <8 x i8>* %33
%36 = add nuw i64 %15, 8
%37 = icmp eq i64 %36, %11
br i1 %37, label %38, label %14
38: ; preds = %14
%39 = icmp eq i64 %11, %8
br i1 %39, label %42, label %40
40: ; preds = %7, %38
%41 = phi i64 [ 0, %7 ], [ %11, %38 ]
br label %46
42: ; preds = %46, %38, %2
%43 = add nsw i32 %3, -1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %5, i64 %44
store i8 0, i8* %45
ret i8* %5
46: ; preds = %40, %46
%47 = phi i64 [ %56, %46 ], [ %41, %40 ]
%48 = getelementptr inbounds i32, i32* %0, i64 %47
%49 = load i32, i32* %48
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i8 48, i8 49
%52 = shl nuw nsw i64 %47, 1
%53 = getelementptr inbounds i8, i8* %5, i64 %52
store i8 %51, i8* %53
%54 = or i64 %52, 1
%55 = getelementptr inbounds i8, i8* %5, i64 %54
store i8 32, i8* %55
%56 = add nuw nsw i64 %47, 1
%57 = icmp eq i64 %56, %8
br i1 %57, label %42, label %46
}