#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 */
typedef int /*<<< orphan*/ palindrome;

/* Variables and functions */
char *malloc(int);
int manacher(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
char *longestPalindrom(char *s) {
  int i;
  if (s == NULL) {
    return NULL;
  }
  int len = strlen(s);
  if (len <= 1) {
    return s;
  }
  char *palindrome = malloc(2000);
  memset(palindrome, 0, sizeof(palindrome));
  int size = manacher(s, palindrome);
  palindrome[size] = '\0';
  return palindrome;
}


x86 assembly (clang, -O0):
<longestPalindrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <longestPalindrom+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <longestPalindrom+0x89>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jg     1187 <longestPalindrom+0x47>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c9 <longestPalindrom+0x89>
mov    $0x7d0,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <manacher@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longestPalindrom>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1189 <longestPalindrom+0x49>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     118b <longestPalindrom+0x4b>
mov    $0x7d0,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <manacher@plt>
cltq
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rbx
jmp    118b <longestPalindrom+0x4b>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @longestPalindrom(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %30
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp sle i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = load i8*, i8** %3
store i8* %17, i8** %2
br label %30
18: ; preds = %11
%19 = call i8* @malloc(i32 2000)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @memset(i8* %20, i32 0, i32 8)
%22 = load i8*, i8** %3
%23 = load i8*, i8** %6
%24 = call i32 @manacher(i8* %22, i8* %23)
store i32 %24, i32* %7
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 0, i8* %28
%29 = load i8*, i8** %6
store i8* %29, i8** %2
br label %30
30: ; preds = %18, %16, %10
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
define i8* @longestPalindrom(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 2
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call dereferenceable_or_null(2000) i8* @malloc(i32 2000)
%8 = tail call i32 @memset(i8* %7, i32 0, i32 8)
%9 = tail call i32 @manacher(i8* %0, i8* %7)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %6, %3, %1
%13 = phi i8* [ null, %1 ], [ %7, %6 ], [ %0, %3 ]
ret i8* %13
}