#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*/ is_prime(int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
bool left_trunc(char *s, int len) {
  char *ps = s;
  for (int i = 0; i < len; i++) {
    int n;
    sscanf(ps, "%i", &n);
    if (!is_prime(n)) {
      return false;
    }
    ps++;
  }
  return true;
}


x86 assembly (clang, -O0):
<left_trunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1195 <left_trunc+0x75>
mov    -0x20(%rbp),%rdi
lea    0xeab(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x28(%rbp),%edi
call   1030 <is_prime@plt>
cmp    $0x0,%eax
jne    117b <left_trunc+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    119c <left_trunc+0x7c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <left_trunc+0x1e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<left_trunc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a1 <left_trunc+0x81>
mov    %esi,%r14d
mov    %rdi,%r13
lea    0xec4(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0x4(%rsp),%edi
call   1030 <is_prime@plt>
test   %eax,%eax
je     11a8 <left_trunc+0x88>
mov    %r14d,%ebp
mov    $0x1,%ecx
lea    0xe9e(%rip),%r15
lea    0x4(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %ebx,%ebp
je     1197 <left_trunc+0x77>
lea    (%rbx,%r13,1),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <sscanf@plt>
mov    0x4(%rsp),%edi
call   1030 <is_prime@plt>
lea    0x1(%rbx),%rcx
test   %eax,%eax
jne    1170 <left_trunc+0x50>
xor    %eax,%eax
cmp    %r14d,%ebx
setge  %al
jmp    11aa <left_trunc+0x8a>
mov    $0x1,%eax
jmp    11aa <left_trunc+0x8a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define i32 @left_trunc(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i8*, i8** %4
store i8* %9, i8** %6
store i32 0, i32* %7
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%17 = load i32, i32* %8
%18 = call i32 @is_prime(i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 0, i32* %3
br label %28
21: ; preds = %14
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %6
br label %24
24: ; preds = %21
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %10
27: ; preds = %10
store i32 1, i32* %3
br label %28
28: ; preds = %27, %20
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define i32 @left_trunc(i8* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 @is_prime(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %25, label %16
11: ; preds = %16
%12 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = call i32 @is_prime(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %6, %11
%17 = phi i8* [ %19, %11 ], [ %0, %6 ]
%18 = phi i32 [ %20, %11 ], [ 0, %6 ]
%19 = getelementptr inbounds i8, i8* %17, i64 1
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %1
br i1 %21, label %22, label %11
22: ; preds = %11, %16
%23 = icmp sge i32 %20, %1
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %22, %6, %2
%26 = phi i32 [ 1, %2 ], [ 0, %6 ], [ %24, %22 ]
ret i32 %26
}