#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 for1BLim(int);
int strlen(char *);
void stringToBinary(char *x, char *texto) {
  for (int i = 0; i < strlen(x); i++)
    texto[(int)(i / 8)] =
        (texto[(int)(i / 8)] | ((x[i] & 0x1) << (7 - for1BLim(i)))) & 0xff;
}


x86 assembly (clang, -O0):
<stringToBinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11dd <stringToBinary+0xbd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <for1BLim@plt>
mov    -0x2c(%rbp),%edx
mov    %eax,%esi
mov    -0x28(%rbp),%eax
mov    $0x7,%ecx
sub    %esi,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
and    $0xff,%eax
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x21(%rbp),%dl
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <stringToBinary+0x17>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringToBinary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    117b <stringToBinary+0x5b>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%r12d
shr    $0x3,%r12d
movzbl (%r14,%r12,1),%r13d
movzbl (%r15,%rbx,1),%ebp
and    $0x1,%ebp
mov    %ebx,%edi
call   1040 <for1BLim@plt>
mov    $0x7,%cl
sub    %al,%cl
shl    %cl,%ebp
or     %r13b,%bpl
mov    %bpl,(%r14,%r12,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1140 <stringToBinary+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @stringToBinary(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %38, %2
%7 = load i32, i32* %5
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %41
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = sdiv i32 %13, 8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = and i32 %24, 1
%26 = load i32, i32* %5
%27 = call i32 @for1BLim(i32 %26)
%28 = sub nsw i32 7, %27
%29 = shl i32 %25, %28
%30 = or i32 %18, %29
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = sdiv i32 %34, 8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8 %32, i8* %37
br label %38
38: ; preds = %11
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %6
41: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @stringToBinary(i8* %0, i8* nocapture %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %6, %2
ret void
6: ; preds = %2, %6
%7 = phi i64 [ %22, %6 ], [ 0, %2 ]
%8 = trunc i64 %7 to i32
%9 = lshr i64 %7, 3
%10 = and i64 %9, 536870911
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 %7
%14 = load i8, i8* %13
%15 = and i8 %14, 1
%16 = zext i8 %15 to i32
%17 = tail call i32 @for1BLim(i32 %8)
%18 = sub nsw i32 7, %17
%19 = shl nuw i32 %16, %18
%20 = trunc i32 %19 to i8
%21 = or i8 %12, %20
store i8 %21, i8* %11
%22 = add nuw nsw i64 %7, 1
%23 = tail call i32 @strlen(i8* %0)
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %6, label %5
}