#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 strlen(char *);
int canshuffle(char *s1) {
  if (strlen(s1) < 4) {
    return 0;
  }
  char ch = s1[1];
  for (int i = 1; i < strlen(s1) - 1; i++) {
    if (ch != s1[i]) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<canshuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jge    113a <canshuffle+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <canshuffle+0x98>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x11(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a1 <canshuffle+0x91>
movsbl -0x11(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     118e <canshuffle+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <canshuffle+0x98>
jmp    1193 <canshuffle+0x83>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114b <canshuffle+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<canshuffle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %r15d,%r15d
cmp    $0x4,%eax
jl     1164 <canshuffle+0x54>
mov    0x1(%rbx),%r14b
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     1164 <canshuffle+0x54>
mov    $0x1,%ebp
nopl   (%rax)
cmp    (%rbx,%rbp,1),%r14b
jne    115e <canshuffle+0x4e>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbp
jl     1140 <canshuffle+0x30>
jmp    1164 <canshuffle+0x54>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @canshuffle(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %36
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
store i8 %13, i8* %4
store i32 1, i32* %5
br label %14
14: ; preds = %32, %10
%15 = load i32, i32* %5
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %35
20: ; preds = %14
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %22, %28
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 1, i32* %2
br label %36
31: ; preds = %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %14
35: ; preds = %14
store i32 0, i32* %2
br label %36
36: ; preds = %35, %30, %9
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @canshuffle(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 4
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 2
br i1 %8, label %14, label %20
9: ; preds = %14
%10 = tail call i32 @strlen(i8* %0)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %19, %12
br i1 %13, label %14, label %20
14: ; preds = %4, %9
%15 = phi i64 [ %19, %9 ], [ 1, %4 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %6, %17
%19 = add nuw nsw i64 %15, 1
br i1 %18, label %9, label %20
20: ; preds = %14, %9, %4, %1
%21 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 1, %14 ], [ 0, %9 ]
ret i32 %21
}