#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ longestpalindrome(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char *palin = (char *)malloc(sizeof(char) * 1000);
  if (NULL == palin)
    return 0;
  printf("Please input the string:\nInput:");
  fflush(stdin);
  fgets(palin, 1000, stdin);
  longestpalindrome(palin);
  free(palin);
  palin = NULL;
  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)
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    119c <main+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11ee <main+0x8e>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1080 <longestpalindrome@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11b1 <main+0x51>
mov    %rax,%rbx
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e5f(%rip),%r14
mov    (%r14),%edi
call   1070 <fflush@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1080 <longestpalindrome@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please input the string:\0AInput:\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @malloc(i32 1000)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* null, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %23
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i32 @fflush(i32 %14)
%16 = load i8*, i8** %6
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %16, i32 1000, i32 %17)
%19 = load i8*, i8** %6
%20 = call i32 @longestpalindrome(i8* %19)
%21 = load i8*, i8** %6
%22 = call i32 @free(i8* %21)
store i8* null, i8** %6
store i32 0, i32* %3
br label %23
23: ; preds = %12, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [32 x i8] c"Please input the string:\0AInput:\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 1000)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = tail call i32 @fflush(i32 %8)
%10 = load i32, i32* @stdin
%11 = tail call i32 @fgets(i8* %4, i32 1000, i32 %10)
%12 = tail call i32 @longestpalindrome(i8* %4)
%13 = tail call i32 @free(i8* %4)
br label %14
14: ; preds = %2, %6
ret i32 0
}