#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 EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ make_palindrome(char *, char **, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_make_palindrome();
int /*<<< orphan*/ test_split_by_n();
int /*<<< orphan*/ test_split_string_by_array();
int main(int argc, char **argv) {
  if (argc == 2) {
    char *output = NULL;
    int output_len;
    make_palindrome(argv[1], &output, &output_len);
    printf("%s\n", output);
    free(output);
    return EXIT_SUCCESS;
  }
  printf("\n==================================================================="
         "===\n\n");
  test_make_palindrome();
  printf("\n==================================================================="
         "===\n\n");
  test_split_string_by_array();
  printf("\n==================================================================="
         "===\n\n");
  test_split_by_n();
  printf("\n==================================================================="
         "===\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11c9 <main+0x69>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1080 <make_palindrome@plt>
mov    -0x18(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <main+0xbd>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <test_make_palindrome@plt>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <test_split_string_by_array@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <test_split_by_n@plt>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    11a7 <main+0x47>
movq   $0x0,0x8(%rsp)
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1080 <make_palindrome@plt>
mov    0x8(%rsp),%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ebx
jmp    11e5 <main+0x85>
lea    0xe52(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <test_make_palindrome@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1030 <test_split_string_by_array@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1060 <test_split_by_n@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [74 x i8] c"\0A======================================================================\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %20
10: ; preds = %2
store i8* null, i8** %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @make_palindrome(i8* %13, i8** %6, i32* %7)
%15 = load i8*, i8** %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %6
%18 = call i32 @free(i8* %17)
%19 = load i32, i32* @EXIT_SUCCESS
store i32 %19, i32* %3
br label %28
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @test_make_palindrome()
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (...) @test_split_string_by_array()
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 (...) @test_split_by_n()
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %20, %10
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str.4 = [73 x i8] c"\0A======================================================================\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @make_palindrome(i8* %10, i8** %3, i32* %4)
%12 = load i8*, i8** %3
%13 = call i32 @puts(i8* dereferenceable(1) %12)
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
%16 = load i32, i32* @EXIT_SUCCESS
br label %25
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.4, i64 0, i64 0))
%19 = tail call i32 (...) @test_make_palindrome()
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.4, i64 0, i64 0))
%21 = tail call i32 (...) @test_split_string_by_array()
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.4, i64 0, i64 0))
%23 = tail call i32 (...) @test_split_by_n()
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.4, i64 0, i64 0))
br label %25
25: ; preds = %17, %6
%26 = phi i32 [ %16, %6 ], [ 0, %17 ]
ret i32 %26
}