#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 */
struct sll {
  int dummy;
};

/* Variables and functions */
struct sll *sll_create();
int /*<<< orphan*/ sll_free(struct sll *);
char sll_pop(struct sll *);
int /*<<< orphan*/ sll_push(struct sll *, char);
scalar_t__ strlen(char *);
int isPalindrome(char *string) {
  int i;
  struct sll *list = sll_create();
  for (i = 0; i < (int)strlen(string); i++) {
    sll_push(list, string[i]);
  }
  for (i = 0; i < (int)strlen(string); i++) {
    if (sll_pop(list) != string[i]) {
      sll_free(list);
      return 0;
    }
  }
  sll_free(list);
  return 1;
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <sll_create@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11ae <isPalindrome+0x5e>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <sll_push@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <isPalindrome+0x1e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    121a <isPalindrome+0xca>
mov    -0x20(%rbp),%rdi
call   1070 <sll_pop@plt>
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1207 <isPalindrome+0xb7>
mov    -0x20(%rbp),%rdi
call   1060 <sll_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    122a <isPalindrome+0xda>
jmp    120c <isPalindrome+0xbc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b5 <isPalindrome+0x65>
mov    -0x20(%rbp),%rdi
call   1060 <sll_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <sll_create@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    119f <isPalindrome+0x4f>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%rbx,%rbp,1),%esi
mov    %r14,%rdi
call   1050 <sll_push@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1180 <isPalindrome+0x30>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    11e5 <isPalindrome+0x95>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1070 <sll_pop@plt>
cmp    (%rbx,%rbp,1),%al
jne    11e2 <isPalindrome+0x92>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11c0 <isPalindrome+0x70>
jmp    11e5 <isPalindrome+0x95>
xor    %r15d,%r15d
mov    %r14,%rdi
call   1060 <sll_free@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sll = type { i32 }
define i32 @isPalindrome(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.sll*
store i8* %0, i8** %3
%6 = call %struct.sll* (...) @sll_create()
store %struct.sll* %6, %struct.sll** %5
store i32 0, i32* %4
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %4
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
%12 = icmp slt i32 %8, %11
br i1 %12, label %13, label %24
13: ; preds = %7
%14 = load %struct.sll*, %struct.sll** %5
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @sll_push(%struct.sll* %14, i8 signext %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %7
24: ; preds = %7
store i32 0, i32* %4
br label %25
25: ; preds = %46, %24
%26 = load i32, i32* %4
%27 = load i8*, i8** %3
%28 = call i64 @strlen(i8* %27)
%29 = trunc i64 %28 to i32
%30 = icmp slt i32 %26, %29
br i1 %30, label %31, label %49
31: ; preds = %25
%32 = load %struct.sll*, %struct.sll** %5
%33 = call signext i8 @sll_pop(%struct.sll* %32)
%34 = sext i8 %33 to i32
%35 = load i8*, i8** %3
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %34, %40
br i1 %41, label %42, label %45
42: ; preds = %31
%43 = load %struct.sll*, %struct.sll** %5
%44 = call i32 @sll_free(%struct.sll* %43)
store i32 0, i32* %2
br label %52
45: ; preds = %31
br label %46
46: ; preds = %45
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %25
49: ; preds = %25
%50 = load %struct.sll*, %struct.sll** %5
%51 = call i32 @sll_free(%struct.sll* %50)
store i32 1, i32* %2
br label %52
52: ; preds = %49, %42
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
%struct.sll = type { i32 }
define i32 @isPalindrome(i8* nocapture %0) {
%2 = tail call %struct.sll* (...) @sll_create()
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %10, %1
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = trunc i64 %7 to i32
%9 = icmp sgt i32 %8, 0
br i1 %9, label %25, label %32
10: ; preds = %1, %10
%11 = phi i64 [ %15, %10 ], [ 0, %1 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @sll_push(%struct.sll* %2, i8 signext %13)
%15 = add nuw nsw i64 %11, 1
%16 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%17 = shl i64 %16, 32
%18 = ashr exact i64 %17, 32
%19 = icmp slt i64 %15, %18
br i1 %19, label %10, label %6
20: ; preds = %25
%21 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%22 = shl i64 %21, 32
%23 = ashr exact i64 %22, 32
%24 = icmp slt i64 %31, %23
br i1 %24, label %25, label %32
25: ; preds = %6, %20
%26 = phi i64 [ %31, %20 ], [ 0, %6 ]
%27 = tail call signext i8 @sll_pop(%struct.sll* %2)
%28 = getelementptr inbounds i8, i8* %0, i64 %26
%29 = load i8, i8* %28
%30 = icmp eq i8 %27, %29
%31 = add nuw nsw i64 %26, 1
br i1 %30, label %20, label %32
32: ; preds = %20, %25, %6
%33 = phi i32 [ 1, %6 ], [ 0, %25 ], [ 1, %20 ]
%34 = tail call i32 @sll_free(%struct.sll* %2)
ret i32 %33
}