#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*/ function(char *, int, int, int, int *, int *);
scalar_t__ malloc(int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *longestPalindrome(char *s) {
  if (*s == '\0')
    return "";
  int current_index = 0;
  int current_max = 0;
  int s_len = strlen(s);
  for (int i = 0; i < s_len; ++i) {
    function(s, s_len, i, i, &current_max, &current_index);
    function(s, s_len, i, i + 1, &current_max, &current_index);
  }
  char *result = (char *)malloc(sizeof(char) * (current_max + 1));
  strncpy(result, s + current_index, current_max);
  result[current_max] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<longestPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116c <longestPalindrome+0x2c>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <longestPalindrome+0xe0>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11de <longestPalindrome+0x9e>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    -0x18(%rbp),%r8
lea    -0x14(%rbp),%r9
call   1060 <function@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
lea    -0x18(%rbp),%r8
lea    -0x14(%rbp),%r9
call   1060 <function@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118d <longestPalindrome+0x4d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<longestPalindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     11bc <longestPalindrome+0x7c>
mov    %rdi,%r12
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
call   1040 <strlen@plt>
test   %eax,%eax
jle    11c5 <longestPalindrome+0x85>
mov    %eax,%r13d
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0x4(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %ebx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1060 <function@plt>
lea    0x1(%rbx),%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1060 <function@plt>
mov    %ebp,%ebx
cmp    %ebp,%r13d
jne    1180 <longestPalindrome+0x40>
mov    (%rsp),%edi
add    $0x1,%edi
jmp    11ca <longestPalindrome+0x8a>
lea    0xe3d(%rip),%rbx
jmp    11f0 <longestPalindrome+0xb0>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movslq 0x4(%rsp),%rax
add    %rax,%r12
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
movslq (%rsp),%rax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @longestPalindrome(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %56
14: ; preds = %1
store i32 0, i32* %4
store i32 0, i32* %5
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %6
store i32 0, i32* %7
br label %17
17: ; preds = %33, %14
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32, i32* %7
%26 = call i32 @function(i8* %22, i32 %23, i32 %24, i32 %25, i32* %5, i32* %4)
%27 = load i8*, i8** %3
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
%32 = call i32 @function(i8* %27, i32 %28, i32 %29, i32 %31, i32* %5, i32* %4)
br label %33
33: ; preds = %21
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %17
36: ; preds = %17
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = mul i64 1, %39
%41 = trunc i64 %40 to i32
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = load i8*, i8** %3
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i32, i32* %5
%50 = call i32 @strncpy(i8* %44, i8* %48, i32 %49)
%51 = load i8*, i8** %8
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 0, i8* %54
%55 = load i8*, i8** %8
store i8* %55, i8** %2
br label %56
56: ; preds = %36, %13
%57 = load i8*, i8** %2
ret i8* %57
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @longestPalindrome(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %1
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %26, label %14
11: ; preds = %26
%12 = load i32, i32* %3
%13 = add i32 %12, 1
br label %14
14: ; preds = %11, %6
%15 = phi i32 [ %13, %11 ], [ 1, %6 ]
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i32, i32* %3
%22 = call i32 @strncpy(i8* %17, i8* %20, i32 %21)
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %17, i64 %24
store i8 0, i8* %25
br label %32
26: ; preds = %6, %26
%27 = phi i32 [ %29, %26 ], [ 0, %6 ]
%28 = call i32 @function(i8* %0, i32 %9, i32 %27, i32 %27, i32* %3, i32* %2)
%29 = add nuw nsw i32 %27, 1
%30 = call i32 @function(i8* %0, i32 %9, i32 %27, i32 %29, i32* %3, i32* %2)
%31 = icmp eq i32 %29, %9
br i1 %31, label %11, label %26
32: ; preds = %1, %14
%33 = phi i8* [ %17, %14 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %33
}