#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *palindrome(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int main(int argc, char *argv[]) {
  char *line;
  int size;
  size = 100;
  line = (char *)calloc(size + 1, sizeof(char));
  while (fgets(line, size, stdin) != NULL) {
    line[strcspn(line, "\n")] = '\0';
    printf("Is the string <%s> a palindrome? %s\n", line, palindrome(line));
  }
  free(line);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <palindrome@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    1191 <main+0x31>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x65,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
mov    0x2e67(%rip),%r12
mov    (%r12),%edx
mov    %rax,%rdi
mov    $0x64,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11eb <main+0x8b>
lea    0xe85(%rip),%r14
lea    0xe5b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
call   1050 <palindrome@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <fgets@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [37 x i8] c"Is the string <%s> a palindrome? %s\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
store i32 100, i32* %7
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
%10 = call i64 @calloc(i32 %9, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
br label %12
12: ; preds = %18, %2
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = load i32, i32* @stdin
%16 = call i32* @fgets(i8* %13, i32 %14, i32 %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %27
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i64 @strcspn(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %6
%24 = load i8*, i8** %6
%25 = call i8* @palindrome(i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %25)
br label %12
27: ; preds = %12
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [37 x i8] c"Is the string <%s> a palindrome? %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @calloc(i32 101, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = load i32, i32* @stdin
%6 = tail call i32* @fgets(i8* %4, i32 100, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = tail call i64 @strcspn(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8, i8* %4, i64 %9
store i8 0, i8* %10
%11 = tail call i8* @palindrome(i8* %4)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %11)
%13 = load i32, i32* @stdin
%14 = tail call i32* @fgets(i8* %4, i32 100, i32 %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8, %2
%17 = tail call i32 @free(i8* %4)
ret i32 0
}