#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*/ debug(char *, ...);
int decode_data(char *, char *, int);
int encode_data(char *, char *, char *);
int /*<<< orphan*/ gen_tabs();
scalar_t__ strcmp(char *, char *);
char *strlen(char *);
int test_encoder_decoder(int argc, char *argv[]) {
  gen_tabs();
  char *src =
      "Hello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\nHello This is a test.\nHello This is a "
      "test.\nHello This is a test.\n";
  debug("strlen(src) : %d\n", strlen(src));
  char encoded[1024];
  char decoded[1024];
  int len = encode_data(encoded, src, strlen(src));
  debug("len : %d\n", len);
  int len2 = decode_data(decoded, encoded, len);
  debug("len2 : %d\n", len2);
  decoded[len2] = '\0';
  debug("--1--\n");
  debug("decoded : %s\n", decoded);
  debug("strlen(decoded) : %d\n", strlen(decoded));
  debug("src and decoded are %s.\n",
        strcmp(src, decoded) == 0 ? "equal" : "not equal");
  return 0;
}


x86 assembly (clang, -O0):
<test_encoder_decoder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <gen_tabs@plt>
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rsi
lea    0x121c(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x838(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x838(%rbp),%rdi
mov    -0x830(%rbp),%rsi
mov    %rax,%rdx
call   1030 <encode_data@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%esi
lea    0x11dc(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
lea    -0x820(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x824(%rbp),%edx
call   1080 <decode_data@plt>
mov    %eax,-0x828(%rbp)
mov    -0x828(%rbp),%esi
lea    0x11b3(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
movslq -0x828(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    0x11a1(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
lea    -0x820(%rbp),%rsi
lea    0x1193(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rsi
lea    0x1184(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
mov    -0x18(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
lea    0x1192(%rip),%rsi
lea    0x118f(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rsi
lea    0x1163(%rip),%rdi
mov    $0x0,%al
call   1050 <debug@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_encoder_decoder>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
xor    %eax,%eax
call   1070 <gen_tabs@plt>
lea    0xe85(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1229(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <debug@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x400(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <encode_data@plt>
mov    %eax,%ebp
lea    0x120a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <debug@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1080 <decode_data@plt>
mov    %eax,%ebp
lea    0x11f2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <debug@plt>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0x11e6(%rip),%rdi
xor    %eax,%eax
call   1050 <debug@plt>
lea    0x11df(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <debug@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x11d4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <debug@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0x11e8(%rip),%rax
lea    0x11dd(%rip),%rsi
cmove  %rax,%rsi
lea    0x11b9(%rip),%rdi
xor    %eax,%eax
call   1050 <debug@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [947 x i8] c"Hello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0A\00"
@.str.1 = [18 x i8] c"strlen(src) : %d\0A\00"
@.str.2 = [10 x i8] c"len : %d\0A\00"
@.str.3 = [11 x i8] c"len2 : %d\0A\00"
@.str.4 = [7 x i8] c"--1--\0A\00"
@.str.5 = [14 x i8] c"decoded : %s\0A\00"
@.str.6 = [22 x i8] c"strlen(decoded) : %d\0A\00"
@.str.7 = [25 x i8] c"src and decoded are %s.\0A\00"
@.str.8 = [6 x i8] c"equal\00"
@.str.9 = [10 x i8] c"not equal\00"
define i32 @test_encoder_decoder(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = call i32 (...) @gen_tabs()
store i8* getelementptr inbounds ([947 x i8], [947 x i8]* @.str, i64 0, i64 0), i8** %5
%11 = load i8*, i8** %5
%12 = call i8* @strlen(i8* %11)
%13 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = load i8*, i8** %5
%17 = call i8* @strlen(i8* %16)
%18 = call i32 @encode_data(i8* %14, i8* %15, i8* %17)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %8
%24 = call i32 @decode_data(i8* %21, i8* %22, i32 %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%34 = call i8* @strlen(i8* %33)
%35 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %5
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%38 = call i64 @strcmp(i8* %36, i8* %37)
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0)
%42 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [947 x i8] c"Hello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0AHello This is a test.\0A\00"
@.str.1 = [18 x i8] c"strlen(src) : %d\0A\00"
@.str.2 = [10 x i8] c"len : %d\0A\00"
@.str.3 = [11 x i8] c"len2 : %d\0A\00"
@.str.4 = [7 x i8] c"--1--\0A\00"
@.str.5 = [14 x i8] c"decoded : %s\0A\00"
@.str.6 = [22 x i8] c"strlen(decoded) : %d\0A\00"
@.str.7 = [25 x i8] c"src and decoded are %s.\0A\00"
@.str.8 = [6 x i8] c"equal\00"
@.str.9 = [10 x i8] c"not equal\00"
define i32 @test_encoder_decoder(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = tail call i32 (...) @gen_tabs()
%6 = tail call i8* @strlen(i8* getelementptr inbounds ([947 x i8], [947 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = tail call i8* @strlen(i8* getelementptr inbounds ([947 x i8], [947 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @encode_data(i8* %8, i8* getelementptr inbounds ([947 x i8], [947 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 @decode_data(i8* %9, i8* %8, i32 %11)
%14 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%19 = call i8* @strlen(i8* %9)
%20 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %19)
%21 = call i64 @strcmp(i8* getelementptr inbounds ([947 x i8], [947 x i8]* @.str, i64 0, i64 0), i8* %9)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0)
%24 = call i32 (i8*, ...) @debug(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %23)
ret i32 0
}