#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*/ computeLPSArray(char *, int, int *);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
bool isRepeat(char *str) {
  int n = strlen(str);
  int lps[n];
  computeLPSArray(str, n, lps);
  int len = lps[n - 1];
  printf("len:[%d]\n", len);
  printf("retval:[%d]\n", (len > 0));
  printf("retval:[%d]\n", (n % (n - len)));
  printf("retval:[%d]\n", (n % (n - len) == 0));
  return (len > 0 && n % (n - len) == 0) ? 1 : 0;
}


x86 assembly (clang, -O0):
<isRepeat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <computeLPSArray@plt>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe1d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jle    1216 <isRepeat+0xe6>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isRepeat>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %eax,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1050 <computeLPSArray@plt>
movslq %r15d,%r14
mov    -0x4(%rbx,%r14,4),%r15d
lea    0xe86(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %r14d,%ecx
sub    %r15d,%ecx
mov    %r14d,%eax
cltd
idiv   %ecx
mov    %edx,%r14d
xor    %ebx,%ebx
test   %edx,%edx
sete   %bl
xor    %r12d,%r12d
xor    %esi,%esi
test   %r15d,%r15d
setg   %sil
lea    0xe5f(%rip),%r15
cmovg  %ebx,%r12d
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r12d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"len:[%d]\0A\00"
@.str.1 = [13 x i8] c"retval:[%d]\0A\00"
define i32 @isRepeat(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i32, i64 %10
store i64 %10, i64* %5
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = call i32 @computeLPSArray(i8* %13, i32 %14, i32* %12)
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %12, i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = load i32, i32* %3
%29 = load i32, i32* %6
%30 = sub nsw i32 %28, %29
%31 = srem i32 %27, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %3
%35 = load i32, i32* %6
%36 = sub nsw i32 %34, %35
%37 = srem i32 %33, %36
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %6
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %1
%44 = load i32, i32* %3
%45 = load i32, i32* %3
%46 = load i32, i32* %6
%47 = sub nsw i32 %45, %46
%48 = srem i32 %44, %47
%49 = icmp eq i32 %48, 0
br label %50
50: ; preds = %43, %1
%51 = phi i1 [ false, %1 ], [ %49, %43 ]
%52 = zext i1 %51 to i64
%53 = select i1 %51, i32 1, i32 0
%54 = load i8*, i8** %4
ret i32 %53
}

LLVM IR (-O2):
@.str = [10 x i8] c"len:[%d]\0A\00"
@.str.1 = [13 x i8] c"retval:[%d]\0A\00"
define i32 @isRepeat(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i32, i64 %3
%5 = call i32 @computeLPSArray(i8* %0, i32 %2, i32* %4)
%6 = add nsw i32 %2, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %4, i64 %7
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp sgt i32 %9, 0
%12 = zext i1 %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = sub nsw i32 %2, %9
%15 = srem i32 %2, %14
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %15, 0
%18 = zext i1 %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = select i1 %11, i32 %18, i32 0
ret i32 %20
}