#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);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
unsigned char *translate_char_to_binary_string(unsigned char);
unsigned char *generate_binary_message_string(unsigned char *message) {
  int message_size = strlen((char *)message);
  unsigned char *binary_message_string =
      (unsigned char *)malloc(message_size * 8 * sizeof(char) + 1);
  unsigned char *binary_char_string;
  for (int i = 0; i < 8; i++) {
    binary_char_string = translate_char_to_binary_string(message[i]);
    if (i == 0) {
      strcpy((char *)binary_message_string, (char *)binary_char_string);
    } else {
      strncat((char *)binary_message_string, (char *)binary_char_string, 8);
    }
  }
  binary_message_string[message_size * 8] = '\0';
  return binary_message_string;
}


x86 assembly (clang, -O0):
<generate_binary_message_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jge    11ea <generate_binary_message_string+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11c5 <generate_binary_message_string+0x75>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11d7 <generate_binary_message_string+0x87>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
jmp    11dc <generate_binary_message_string+0x8c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <generate_binary_message_string+0x3a>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_binary_message_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
movslq %eax,%r15
lea    0x0(,%r15,8),%rdi
or     $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movzbl (%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movzbl 0x1(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x2(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x3(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x4(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x5(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x6(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movzbl 0x7(%r14),%edi
call   1060 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1050 <strncat@plt>
movb   $0x0,(%rbx,%r15,8)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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