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


x86 assembly (clang, -O0):
<generate_binary_key_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x41,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11c1 <generate_binary_key_string+0x81>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    119c <generate_binary_key_string+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11ae <generate_binary_key_string+0x6e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
jmp    11b3 <generate_binary_key_string+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1161 <generate_binary_key_string+0x21>
mov    -0x10(%rbp),%rax
movb   $0x0,0x40(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_binary_key_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x41,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movzbl (%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
movzbl 0x1(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x2(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x3(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x4(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x5(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x6(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movzbl 0x7(%r14),%edi
call   1050 <translate_char_to_binary_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <strncat@plt>
movb   $0x0,0x40(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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