#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 */
scalar_t__ left_trunc(char *, int);
int /*<<< orphan*/ memset(char *, char, int);
scalar_t__ right_trunc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
bool is_trunc_prime(char *s, int len) {
  char left_buf[64];
  char right_buf[64];
  memset(left_buf, '\0', 64);
  memset(right_buf, '\0', 64);
  strcpy(left_buf, &s[1]);
  strcpy(right_buf, s);
  right_buf[len - 1] = '\0';
  return left_trunc(left_buf, len - 1) && right_trunc(right_buf, len - 1);
}


x86 assembly (clang, -O0):
<is_trunc_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1040 <left_trunc@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x91(%rbp)
je     11e9 <is_trunc_prime+0xa9>
lea    -0x90(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1060 <right_trunc@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_trunc_prime>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0x40(%rsp),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    0x1(%rbx),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movslq %r15d,%rbx
movb   $0x0,-0x1(%rsp,%rbx,1)
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <left_trunc@plt>
test   %rax,%rax
je     11c2 <is_trunc_prime+0x82>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1060 <right_trunc@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_trunc_prime(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i8 signext 0, i32 64)
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 64)
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = call i32 @strcpy(i8* %11, i8* %13)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = call i64 @left_trunc(i8* %22, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %2
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = call i64 @right_trunc(i8* %28, i32 %30)
%32 = icmp ne i64 %31, 0
br label %33
33: ; preds = %27, %2
%34 = phi i1 [ false, %2 ], [ %32, %27 ]
%35 = zext i1 %34 to i32
ret i32 %35
}

LLVM IR (-O2):
define i32 @is_trunc_prime(i8* %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i8 signext 0, i32 64)
%8 = call i32 @memset(i8* %6, i8 signext 0, i32 64)
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = call i32 @strcpy(i8* %5, i8* %9)
%11 = call i32 @strcpy(i8* %6, i8* %0)
%12 = add nsw i32 %1, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i64 @left_trunc(i8* %5, i32 %12)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = call i64 @right_trunc(i8* %6, i32 %12)
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %17, %2
%22 = phi i32 [ 0, %2 ], [ %20, %17 ]
ret i32 %22
}