#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 /*<<< orphan*/ conv_6str_to_8str(char *, int, char *, int *);
int /*<<< orphan*/ conv_8str_to_6str(char *, int, char *, int *);
int est_6mem_for_8str(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ print_hex(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  char *my_str = "HELLO! THIS IS A TEST OF MY ENCODING";
  int my_str_len = strlen(my_str);
  char *my_encoded = (char *)malloc(est_6mem_for_8str(my_str_len));
  int my_encoded_len;
  char *my_decoded = (char *)malloc(my_str_len + 1);
  int my_decoded_len;
  printf("Orig: %s\n", my_str);
  printf("Orig Len: %d\n", my_str_len);
  print_hex(my_str, my_str_len);
  conv_8str_to_6str(my_str, my_str_len, my_encoded, &my_encoded_len);
  printf("\n");
  printf("Enc Len: %d\n", my_encoded_len);
  print_hex(my_encoded, my_encoded_len);
  conv_6str_to_8str(my_encoded, my_encoded_len, my_decoded, &my_decoded_len);
  printf("\n");
  printf("Decoded: %s\n", my_decoded);
  printf("Dec Len: %d\n", my_decoded_len);
  print_hex(my_decoded, my_decoded_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <est_6mem_for_8str@plt>
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <print_hex@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1060 <conv_8str_to_6str@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <print_hex@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
call   1050 <conv_6str_to_8str@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <print_hex@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe71(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   10a0 <est_6mem_for_8str@plt>
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0x1(%rbx),%edi
call   1090 <malloc@plt>
mov    %rax,%r14
lea    0xe69(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1080 <print_hex@plt>
mov    %rsp,%rcx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r12,%rdx
call   1070 <conv_8str_to_6str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%esi
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
mov    %r12,%rdi
call   1080 <print_hex@plt>
mov    (%rsp),%esi
lea    0x4(%rsp),%rcx
mov    %r12,%rdi
mov    %r14,%rdx
call   1060 <conv_6str_to_8str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe10(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1080 <print_hex@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"HELLO! THIS IS A TEST OF MY ENCODING\00"
@.str.1 = [10 x i8] c"Orig: %s\0A\00"
@.str.2 = [14 x i8] c"Orig Len: %d\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [13 x i8] c"Enc Len: %d\0A\00"
@.str.5 = [13 x i8] c"Decoded: %s\0A\00"
@.str.6 = [13 x i8] c"Dec Len: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @est_6mem_for_8str(i32 %10)
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %4
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %6
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = call i32 @print_hex(i8* %22, i32 %23)
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = load i8*, i8** %4
%28 = call i32 @conv_8str_to_6str(i8* %25, i32 %26, i8* %27, i32* %5)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %4
%33 = load i32, i32* %5
%34 = call i32 @print_hex(i8* %32, i32 %33)
%35 = load i8*, i8** %4
%36 = load i32, i32* %5
%37 = load i8*, i8** %6
%38 = call i32 @conv_6str_to_8str(i8* %35, i32 %36, i8* %37, i32* %7)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = load i8*, i8** %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %6
%45 = load i32, i32* %7
%46 = call i32 @print_hex(i8* %44, i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"HELLO! THIS IS A TEST OF MY ENCODING\00"
@.str.1 = [10 x i8] c"Orig: %s\0A\00"
@.str.2 = [14 x i8] c"Orig Len: %d\0A\00"
@.str.4 = [13 x i8] c"Enc Len: %d\0A\00"
@.str.5 = [13 x i8] c"Decoded: %s\0A\00"
@.str.6 = [13 x i8] c"Dec Len: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @est_6mem_for_8str(i32 %3)
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = bitcast i32* %1 to i8*
%8 = add nsw i32 %3, 1
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = bitcast i32* %2 to i8*
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%14 = tail call i32 @print_hex(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %3)
%15 = call i32 @conv_8str_to_6str(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %6, i32* %1)
%16 = call i32 @putchar(i32 10)
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = call i32 @print_hex(i8* %6, i32 %19)
%21 = load i32, i32* %1
%22 = call i32 @conv_6str_to_8str(i8* %6, i32 %21, i8* %10, i32* %2)
%23 = call i32 @putchar(i32 10)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = call i32 @print_hex(i8* %10, i32 %27)
ret i32 0
}