#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 */
long long atoll(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
long long sqrt(long long);
int /*<<< orphan*/ strcat(char *, char *);
long long int arrayToInt(int *A, int len) {
  long long int length = len, m, i, r;
  char a_as_num[length][40];
  char string[30] = "\0";
  for (i = length - 1; i >= 0; i--) {
    sprintf(a_as_num[i], "%lld", A[i]);
    strcat(string, a_as_num[i]);
  }
  r = atoll(string);
  printf("\nValue of number is :%lld\n", r);
  m = sqrt(r);
  if (r == 1) {
    printf("Wrong input");
    exit(1);
  }
  if (r == 2 || r == 3) {
    return r;
  } else {
    for (i = 2; i <= m; i++) {
      if (i >= 100000) {
        break;
      }
      if (r % i == 0) {
        printf("\nWRONG INPUT\n");
        exit(1);
      }
    }
    return r;
  }
}


x86 assembly (clang, -O0):
<arrayToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    (%rax,%rax,4),%rcx
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jl     1226 <arrayToInt+0xb6>
mov    -0x80(%rbp),%rdi
imul   $0x28,-0x30(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe05(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x80(%rbp),%rsi
lea    -0x70(%rbp),%rdi
imul   $0x28,-0x30(%rbp),%rax
add    %rax,%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11d2 <arrayToInt+0x62>
lea    -0x70(%rbp),%rdi
call   1050 <atoll@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <sqrt@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x1,-0x38(%rbp)
jne    1275 <arrayToInt+0x105>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmpq   $0x2,-0x38(%rbp)
je     128b <arrayToInt+0x11b>
cmpq   $0x3,-0x38(%rbp)
jne    129f <arrayToInt+0x12f>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x74(%rbp)
jmp    1319 <arrayToInt+0x1a9>
movq   $0x2,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     130a <arrayToInt+0x19a>
cmpq   $0x186a0,-0x30(%rbp)
jl     12c8 <arrayToInt+0x158>
jmp    130a <arrayToInt+0x19a>
mov    -0x38(%rbp),%rax
cqto
idivq  -0x30(%rbp)
cmp    $0x0,%rdx
jne    12f4 <arrayToInt+0x184>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12f9 <arrayToInt+0x189>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a7 <arrayToInt+0x137>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x74(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arrayToInt>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movslq %esi,%r13
mov    %rsp,%rax
lea    0x0(,%r13,4),%rcx
add    %r13,%rcx
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
sub    %rdx,%rax
mov    %rax,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,-0x42(%rbp)
movaps %xmm0,-0x50(%rbp)
test   %r13d,%r13d
jle    11f9 <arrayToInt+0x89>
mov    %rdi,%r14
add    $0x1,%r13
lea    (%rax,%rcx,8),%rbx
add    $0xffffffffffffffd8,%rbx
lea    0xe36(%rip),%r15
lea    -0x50(%rbp),%r12
xchg   %ax,%ax
mov    -0x8(%r14,%r13,4),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
add    $0xffffffffffffffff,%r13
add    $0xffffffffffffffd8,%rbx
cmp    $0x1,%r13
jg     11d0 <arrayToInt+0x60>
lea    -0x50(%rbp),%rdi
call   1050 <atoll@plt>
mov    %rax,%rbx
lea    0xdf9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <sqrt@plt>
cmp    $0x1,%rbx
je     12c5 <arrayToInt+0x155>
mov    %rbx,%rcx
and    $0xfffffffffffffffe,%rcx
cmp    $0x2,%rcx
je     129d <arrayToInt+0x12d>
cmp    $0x2,%rax
jl     129d <arrayToInt+0x12d>
add    $0xfffffffffffffffe,%rax
cmp    $0x1869d,%rax
mov    $0x1869d,%ecx
cmovb  %rax,%rcx
not    %rcx
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1280 <arrayToInt+0x110>
mov    %rbx,%rax
cqto
idiv   %rsi
test   %rdx,%rdx
jne    128b <arrayToInt+0x11b>
jmp    12af <arrayToInt+0x13f>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
je     12af <arrayToInt+0x13f>
lea    (%rcx,%rsi,1),%rax
add    $0x1,%rax
add    $0x1,%rsi
cmp    $0x2,%rax
jne    1260 <arrayToInt+0xf0>
mov    %rbx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd76(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xd54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [27 x i8] c"\0AValue of number is :%lld\0A\00"
@.str.2 = [12 x i8] c"Wrong input\00"
@.str.3 = [14 x i8] c"\0AWRONG INPUT\0A\00"
define i64 @arrayToInt(i32* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca [30 x i8]
%13 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %10
%18 = alloca [40 x i8], i64 %16
store i64 %16, i64* %11
%19 = bitcast [30 x i8]* %12 to i8*
%20 = load i64, i64* %6
%21 = sub nsw i64 %20, 1
store i64 %21, i64* %8
br label %22
22: ; preds = %39, %2
%23 = load i64, i64* %8
%24 = icmp sge i64 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %22
%26 = load i64, i64* %8
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %18, i64 %26
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %27, i64 0, i64 0
%29 = load i32*, i32** %4
%30 = load i64, i64* %8
%31 = getelementptr inbounds i32, i32* %29, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%35 = load i64, i64* %8
%36 = getelementptr inbounds [40 x i8], [40 x i8]* %18, i64 %35
%37 = getelementptr inbounds [40 x i8], [40 x i8]* %36, i64 0, i64 0
%38 = call i32 @strcat(i8* %34, i8* %37)
br label %39
39: ; preds = %25
%40 = load i64, i64* %8
%41 = add nsw i64 %40, -1
store i64 %41, i64* %8
br label %22
42: ; preds = %22
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%44 = call i64 @atoll(i8* %43)
store i64 %44, i64* %9
%45 = load i64, i64* %9
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %45)
%47 = load i64, i64* %9
%48 = call i64 @sqrt(i64 %47)
store i64 %48, i64* %7
%49 = load i64, i64* %9
%50 = icmp eq i64 %49, 1
br i1 %50, label %51, label %54
51: ; preds = %42
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %42
%55 = load i64, i64* %9
%56 = icmp eq i64 %55, 2
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i64, i64* %9
%59 = icmp eq i64 %58, 3
br i1 %59, label %60, label %62
60: ; preds = %57, %54
%61 = load i64, i64* %9
store i64 %61, i64* %3
store i32 1, i32* %13
br label %85
62: ; preds = %57
store i64 2, i64* %8
br label %63
63: ; preds = %80, %62
%64 = load i64, i64* %8
%65 = load i64, i64* %7
%66 = icmp sle i64 %64, %65
br i1 %66, label %67, label %83
67: ; preds = %63
%68 = load i64, i64* %8
%69 = icmp sge i64 %68, 100000
br i1 %69, label %70, label %71
70: ; preds = %67
br label %83
71: ; preds = %67
%72 = load i64, i64* %9
%73 = load i64, i64* %8
%74 = srem i64 %72, %73
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %71
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %71
br label %80
80: ; preds = %79
%81 = load i64, i64* %8
%82 = add nsw i64 %81, 1
store i64 %82, i64* %8
br label %63
83: ; preds = %70, %63
%84 = load i64, i64* %9
store i64 %84, i64* %3
store i32 1, i32* %13
br label %85
85: ; preds = %83, %60
%86 = load i8*, i8** %10
%87 = load i64, i64* %3
ret i64 %87
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [27 x i8] c"\0AValue of number is :%lld\0A\00"
@.str.2 = [12 x i8] c"Wrong input\00"
@str = [13 x i8] c"\0AWRONG INPUT\00"
define i64 @arrayToInt(i32* nocapture %0, i32 %1) {
%3 = alloca [30 x i8]
%4 = sext i32 %1 to i64
%5 = alloca [40 x i8], i64 %4
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %17
8: ; preds = %2, %8
%9 = phi i64 [ %10, %8 ], [ %4, %2 ]
%10 = add nsw i64 %9, -1
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 %10, i64 0
%12 = getelementptr inbounds i32, i32* %0, i64 %10
%13 = load i32, i32* %12
%14 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @strcat(i8* %6, i8* %11)
%16 = icmp sgt i64 %9, 1
br i1 %16, label %8, label %17
17: ; preds = %8, %2
%18 = call i64 @atoll(i8* %6)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %18)
%20 = call i64 @sqrt(i64 %18)
%21 = icmp eq i64 %18, 1
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = and i64 %18, -2
%27 = icmp eq i64 %26, 2
%28 = icmp slt i64 %20, 2
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %44, label %30
30: ; preds = %25
%31 = add nsw i64 %20, -2
%32 = call i64 @llvm.umin.i64(i64 %31, i64 99997)
%33 = add nuw nsw i64 %32, 2
br label %37
34: ; preds = %37
%35 = add nuw nsw i64 %38, 1
%36 = icmp eq i64 %38, %33
br i1 %36, label %44, label %37
37: ; preds = %30, %34
%38 = phi i64 [ %35, %34 ], [ 2, %30 ]
%39 = srem i64 %18, %38
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %34
41: ; preds = %37
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34, %25
ret i64 %18
}