#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*/ printf(char *);
int /*<<< orphan*/ run_test(char *, int, int);
int main(int argc, char const *argv[]) {
  int lkey = 'B';
  int nkey = 'B';
  char subTest[] = "Hello World!";
  char transTest_0[] = "Hell";
  char transTest_1[] = "HHHello";
  char truncationTest[1030];
  printf("Sub alg test on Hello World!\n");
  run_test(subTest, lkey, nkey);
  printf("Test trans alg with only one quad\n");
  run_test(transTest_0, lkey, nkey);
  printf("Trans alg test: 3 char last quad \n");
  run_test(transTest_1, lkey, nkey);
  printf("Creating huge string to test truncation\n");
  int i;
  for (i = 0; i < 1030; i++)
    truncationTest[i] = 'x';
  truncationTest[1030] = '\0';
  run_test(truncationTest, lkey, nkey);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x42,-0x14(%rbp)
movl   $0x42,-0x18(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x25(%rbp)
mov    0xeb0(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xeab(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xea3(%rip),%eax
mov    %eax,-0x2a(%rbp)
mov    0xe9e(%rip),%al
mov    %al,-0x26(%rbp)
mov    0xe95(%rip),%rax
mov    %rax,-0x32(%rbp)
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
lea    -0x25(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <run_test@plt>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
lea    -0x2a(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <run_test@plt>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    -0x32(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <run_test@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x444(%rbp)
cmpl   $0x406,-0x444(%rbp)
jge    121b <main+0xfb>
movslq -0x444(%rbp),%rax
movb   $0x78,-0x440(%rbp,%rax,1)
78
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    11e8 <main+0xc8>
movb   $0x0,-0x3a(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <run_test@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x430,%rsp
movabs $0x21646c726f5720,%rax
mov    %rax,0x15(%rsp)
movabs $0x6f57206f6c6c6548,%rax
20 57 6f
mov    %rax,0x10(%rsp)
movb   $0x0,0x4(%rsp)
movl   $0x6c6c6548,(%rsp)
movabs $0x6f6c6c65484848,%rax
mov    %rax,0x8(%rsp)
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
mov    $0x42,%esi
mov    $0x42,%edx
call   1050 <run_test@plt>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x42,%esi
mov    $0x42,%edx
call   1050 <run_test@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
mov    $0x42,%esi
mov    $0x42,%edx
call   1050 <run_test@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rbx
mov    $0x406,%edx
mov    %rbx,%rdi
mov    $0x78,%esi
call   1040 <memset@plt>
movb   $0x0,0x426(%rsp)
mov    %rbx,%rdi
mov    $0x42,%esi
mov    $0x42,%edx
call   1050 <run_test@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.subTest = [13 x i8] c"Hello World!\00"
@__const.main.transTest_0 = [5 x i8] c"Hell\00"
@__const.main.transTest_1 = [8 x i8] c"HHHello\00"
@.str = [30 x i8] c"Sub alg test on Hello World!\0A\00"
@.str.1 = [35 x i8] c"Test trans alg with only one quad\0A\00"
@.str.2 = [35 x i8] c"Trans alg test: 3 char last quad \0A\00"
@.str.3 = [41 x i8] c"Creating huge string to test truncation\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [13 x i8]
%9 = alloca [5 x i8]
%10 = alloca [8 x i8]
%11 = alloca [1030 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 66, i32* %6
store i32 66, i32* %7
%13 = bitcast [13 x i8]* %8 to i8*
%14 = bitcast [5 x i8]* %9 to i8*
%15 = bitcast [8 x i8]* %10 to i8*
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 @run_test(i8* %17, i32 %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 @run_test(i8* %22, i32 %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @run_test(i8* %27, i32 %28, i32 %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %12
br label %32
32: ; preds = %39, %2
%33 = load i32, i32* %12
%34 = icmp slt i32 %33, 1030
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1030 x i8], [1030 x i8]* %11, i64 0, i64 %37
store i8 120, i8* %38
br label %39
39: ; preds = %35
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %32
42: ; preds = %32
%43 = getelementptr inbounds [1030 x i8], [1030 x i8]* %11, i64 0, i64 1030
store i8 0, i8* %43
%44 = getelementptr inbounds [1030 x i8], [1030 x i8]* %11, i64 0, i64 0
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 @run_test(i8* %44, i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@__const.main.subTest = [13 x i8] c"Hello World!\00"
@__const.main.transTest_0 = [5 x i8] c"Hell\00"
@str = [29 x i8] c"Sub alg test on Hello World!\00"
@str.4 = [34 x i8] c"Test trans alg with only one quad\00"
@str.5 = [34 x i8] c"Trans alg test: 3 char last quad \00"
@str.6 = [40 x i8] c"Creating huge string to test truncation\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i8]
%4 = alloca [5 x i8]
%5 = alloca i64
%6 = alloca [1030 x i8]
%7 = getelementptr inbounds [1030 x i8], [1030 x i8]* %6, i64 0, i64 0
%8 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%10 = bitcast i64* %5 to i8*
store i64 31362935226386504, i64* %5
%11 = getelementptr inbounds [1030 x i8], [1030 x i8]* %6, i64 0, i64 0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%13 = call i32 @run_test(i8* %8, i32 66, i32 66)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.4, i64 0, i64 0))
%15 = call i32 @run_test(i8* %9, i32 66, i32 66)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%17 = call i32 @run_test(i8* %10, i32 66, i32 66)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
%19 = getelementptr inbounds [1030 x i8], [1030 x i8]* %6, i64 0, i64 1030
store i8 0, i8* %19
%20 = call i32 @run_test(i8* %11, i32 66, i32 66)
ret i32 0
}