#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdout;
int main(void) {
  bool isRotation(char *s1, char *s2);
  char s1[40] = {}, s2[80] = {};
  fputs("Please enter s1 string: ", stdout);
  scanf("%40s", s1);
  fputs("Please enter s2 string: ", stdout);
  scanf("%40s", s2);
  printf("s1 is a rotation of s2: %s\n", isRotation(s1, s2) ? "Yes" : "No");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
lea    0xe6e(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x30(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1070 <scanf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    0xe67(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x80(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <isRotation@plt>
mov    %eax,%ecx
lea    0xe75(%rip),%rsi
lea    0xe6a(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%esi
lea    0xe76(%rip),%rdi
call   1050 <fputs@plt>
lea    0xe83(%rip),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    (%rbx),%esi
lea    0xe71(%rip),%rdi
call   1050 <fputs@plt>
lea    0x30(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <isRotation@plt>
test   %eax,%eax
lea    0xe81(%rip),%rax
lea    0xe76(%rip),%rsi
cmove  %rax,%rsi
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Please enter s1 string: \00"
@stdout = global i32 0
@.str.1 = [5 x i8] c"%40s\00"
@.str.2 = [25 x i8] c"Please enter s2 string: \00"
@.str.3 = [28 x i8] c"s1 is a rotation of s2: %s\0A\00"
@.str.4 = [4 x i8] c"Yes\00"
@.str.5 = [3 x i8] c"No\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [80 x i8]
store i32 0, i32* %1
%4 = bitcast [40 x i8]* %2 to i8*
%5 = bitcast [80 x i8]* %3 to i8*
%6 = load i32, i32* @stdout
%7 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stdout
%11 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%16 = call i32 @isRotation(i8* %14, i8* %15)
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Please enter s1 string: \00"
@stdout = global i32 0
@.str.1 = [5 x i8] c"%40s\00"
@.str.2 = [25 x i8] c"Please enter s2 string: \00"
@.str.3 = [28 x i8] c"s1 is a rotation of s2: %s\0A\00"
@.str.4 = [4 x i8] c"Yes\00"
@.str.5 = [3 x i8] c"No\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%8 = load i32, i32* @stdout
%9 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i32 @isRotation(i8* %3, i8* %4)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %13)
ret i32 0
}