#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 */
scalar_t__ malloc(int);
char *separate_bits(char *bit_array) {
  char *bits = (char *)malloc((sizeof(char) * 2) * 10);
  int i = 0;
  int j = 0;
  while (i < 10) {
    bits[j] = bit_array[i];
    bits[j + 1] = '\0';
    i++;
    j += 2;
  }
  return bits;
}


x86 assembly (clang, -O0):
<separate_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1180 <separate_bits+0x70>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <separate_bits+0x28>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<separate_bits>:
push   %rbx
mov    %rdi,%rbx
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    (%rbx),%cl
mov    %cl,(%rax)
movb   $0x0,0x1(%rax)
mov    0x1(%rbx),%cl
mov    %cl,0x2(%rax)
movb   $0x0,0x3(%rax)
mov    0x2(%rbx),%cl
mov    %cl,0x4(%rax)
movb   $0x0,0x5(%rax)
mov    0x3(%rbx),%cl
mov    %cl,0x6(%rax)
movb   $0x0,0x7(%rax)
mov    0x4(%rbx),%cl
mov    %cl,0x8(%rax)
movb   $0x0,0x9(%rax)
mov    0x5(%rbx),%cl
mov    %cl,0xa(%rax)
movb   $0x0,0xb(%rax)
mov    0x6(%rbx),%cl
mov    %cl,0xc(%rax)
movb   $0x0,0xd(%rax)
mov    0x7(%rbx),%cl
mov    %cl,0xe(%rax)
movb   $0x0,0xf(%rax)
mov    0x8(%rbx),%cl
mov    %cl,0x10(%rax)
movb   $0x0,0x11(%rax)
mov    0x9(%rbx),%cl
mov    %cl,0x12(%rax)
movb   $0x0,0x13(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @separate_bits(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i64 @malloc(i32 20)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %11, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
store i8 0, i8* %25
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 2
store i32 %29, i32* %5
br label %8
30: ; preds = %8
%31 = load i8*, i8** %3
ret i8* %31
}

LLVM IR (-O2):
define i8* @separate_bits(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 20)
%3 = inttoptr i64 %2 to i8*
%4 = load i8, i8* %0
store i8 %4, i8* %3
%5 = getelementptr inbounds i8, i8* %3, i64 1
store i8 0, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %3, i64 2
store i8 %7, i8* %8
%9 = getelementptr inbounds i8, i8* %3, i64 3
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %3, i64 4
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %3, i64 5
store i8 0, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %3, i64 6
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %3, i64 7
store i8 0, i8* %17
%18 = getelementptr inbounds i8, i8* %0, i64 4
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %3, i64 8
store i8 %19, i8* %20
%21 = getelementptr inbounds i8, i8* %3, i64 9
store i8 0, i8* %21
%22 = getelementptr inbounds i8, i8* %0, i64 5
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %3, i64 10
store i8 %23, i8* %24
%25 = getelementptr inbounds i8, i8* %3, i64 11
store i8 0, i8* %25
%26 = getelementptr inbounds i8, i8* %0, i64 6
%27 = load i8, i8* %26
%28 = getelementptr inbounds i8, i8* %3, i64 12
store i8 %27, i8* %28
%29 = getelementptr inbounds i8, i8* %3, i64 13
store i8 0, i8* %29
%30 = getelementptr inbounds i8, i8* %0, i64 7
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %3, i64 14
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %3, i64 15
store i8 0, i8* %33
%34 = getelementptr inbounds i8, i8* %0, i64 8
%35 = load i8, i8* %34
%36 = getelementptr inbounds i8, i8* %3, i64 16
store i8 %35, i8* %36
%37 = getelementptr inbounds i8, i8* %3, i64 17
store i8 0, i8* %37
%38 = getelementptr inbounds i8, i8* %0, i64 9
%39 = load i8, i8* %38
%40 = getelementptr inbounds i8, i8* %3, i64 18
store i8 %39, i8* %40
%41 = getelementptr inbounds i8, i8* %3, i64 19
store i8 0, i8* %41
ret i8* %3
}