#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 */
typedef int /*<<< orphan*/ searchStr;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ strstr(char *, char *);
bool SameNecklace(char *src, char *shifted) {
  if (!src || !shifted || strlen(shifted) != strlen(src)) {
    return false;
  }
  if (strcmp(shifted, "") == 0) {
    return true;
  }
  char searchStr[256 * 2];
  memset(searchStr, '\0', sizeof(searchStr));
  strcpy(searchStr, shifted);
  strcat(searchStr, shifted);
  return strstr(searchStr, src) ? true : false;
}


x86 assembly (clang, -O0):
<SameNecklace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b5 <SameNecklace+0x55>
cmpq   $0x0,-0x18(%rbp)
je     11b5 <SameNecklace+0x55>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x228(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x228(%rbp),%rax
cmp    %rcx,%rax
je     11c1 <SameNecklace+0x61>
movl   $0x0,-0x4(%rbp)
jmp    123e <SameNecklace+0xde>
mov    -0x18(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e7 <SameNecklace+0x87>
movl   $0x1,-0x4(%rbp)
jmp    123e <SameNecklace+0xde>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SameNecklace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     11ee <SameNecklace+0x8e>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11ee <SameNecklace+0x8e>
mov    %rdi,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %rax,%r15
jne    11ee <SameNecklace+0x8e>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11e9 <SameNecklace+0x89>
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1080 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
jmp    11ee <SameNecklace+0x8e>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @SameNecklace(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [512 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i8*, i8** %5
%14 = call i64 @strlen(i8* %13)
%15 = load i8*, i8** %4
%16 = call i64 @strlen(i8* %15)
%17 = icmp ne i64 %14, %16
br i1 %17, label %18, label %19
18: ; preds = %12, %9, %2
store i32 0, i32* %3
br label %39
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %39
24: ; preds = %19
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i8 signext 0, i32 512)
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%28 = load i8*, i8** %5
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%31 = load i8*, i8** %5
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%34 = load i8*, i8** %4
%35 = call i64 @strstr(i8* %33, i8* %34)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i64
%38 = select i1 %36, i32 1, i32 0
store i32 %38, i32* %3
br label %39
39: ; preds = %24, %23, %18
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @SameNecklace(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = tail call i64 @strlen(i8* %1)
%9 = tail call i64 @strlen(i8* %0)
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i8 signext 0, i32 512)
%17 = call i32 @strcpy(i8* %15, i8* %1)
%18 = call i32 @strcat(i8* %15, i8* %1)
%19 = call i64 @strstr(i8* %15, i8* %0)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %11, %2, %7, %14
%23 = phi i32 [ %21, %14 ], [ 0, %7 ], [ 0, %2 ], [ 1, %11 ]
ret i32 %23
}