#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int RabbinMillerTest(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  FILE *fp;
  int n, i, count;
  int *p;
  if (argc != 2) {
    printf("have not enter file name strike any key exit");
    getchar();
    return -1;
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    printf("\nCannot open file strike any key exit!");
    getchar();
    return -1;
  }
  fscanf(fp, "%d", &n);
  p = (int *)malloc(sizeof(int) * n);
  i = 0;
  count = 0;
  do {
    fscanf(fp, "%d", &p[i]);
    ++i;
  } while (i < n);
  for (i = 0; i < n; i++)
    if (RabbinMillerTest(p[i]) == 1) {
      count++;
    }
  printf("count =%d\n", count);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b1 <main+0x41>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c6 <main+0x156>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f4 <main+0x84>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c6 <main+0x156>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <fscanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe13(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1229 <main+0xb9>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a5 <main+0x135>
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1090 <RabbinMillerTest@plt>
cmp    $0x1,%eax
jne    1292 <main+0x122>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1297 <main+0x127>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1264 <main+0xf4>
mov    -0x24(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    123b <main+0xcb>
mov    0x8(%rsi),%rdi
lea    0xe9d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1244 <main+0xd4>
mov    %rax,%r12
lea    0xeae(%rip),%r15
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <fscanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
mov    %rax,%rbp
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1050 <fscanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%rbx
jl     11d0 <main+0x60>
xor    %r15d,%r15d
mov    $0x0,%ebp
test   %eax,%eax
jle    1221 <main+0xb1>
xor    %ebx,%ebx
xor    %ebp,%ebp
mov    (%r14,%rbx,4),%edi
call   1090 <RabbinMillerTest@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebp
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0x90>
lea    0xe31(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
jmp    125f <main+0xef>
lea    0xdbe(%rip),%rdi
jmp    124b <main+0xdb>
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"have not enter file name strike any key exit\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"\0ACannot open file strike any key exit!\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"count =%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @getchar()
store i32 -1, i32* %3
br label %72
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (...) @getchar()
store i32 -1, i32* %3
br label %72
25: ; preds = %16
%26 = load i32*, i32** %6
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = mul i64 4, %29
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to i32*
store i32* %33, i32** %10
store i32 0, i32* %8
store i32 0, i32* %9
br label %34
34: ; preds = %43, %25
%35 = load i32*, i32** %6
%36 = load i32*, i32** %10
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = call i32 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %39)
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %43
43: ; preds = %34
%44 = load i32, i32* %8
%45 = load i32, i32* %7
%46 = icmp slt i32 %44, %45
br i1 %46, label %34, label %47
47: ; preds = %43
store i32 0, i32* %8
br label %48
48: ; preds = %64, %47
%49 = load i32, i32* %8
%50 = load i32, i32* %7
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %67
52: ; preds = %48
%53 = load i32*, i32** %10
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @RabbinMillerTest(i32 %57)
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %63
60: ; preds = %52
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %63
63: ; preds = %60, %52
br label %64
64: ; preds = %63
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %48
67: ; preds = %48
%68 = load i32, i32* %9
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = load i32*, i32** %6
%71 = call i32 @fclose(i32* %70)
store i32 0, i32* %3
br label %72
72: ; preds = %67, %22, %13
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str = [45 x i8] c"have not enter file name strike any key exit\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [39 x i8] c"\0ACannot open file strike any key exit!\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"count =%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @getchar()
br label %50
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @getchar()
br label %50
17: ; preds = %9
%18 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = shl i32 %19, 2
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
br label %23
23: ; preds = %23, %17
%24 = phi i64 [ %27, %23 ], [ 0, %17 ]
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %25)
%27 = add nuw nsw i64 %24, 1
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %23, label %31
31: ; preds = %23
%32 = icmp sgt i32 %28, 0
br i1 %32, label %33, label %46
33: ; preds = %31, %33
%34 = phi i64 [ %42, %33 ], [ 0, %31 ]
%35 = phi i32 [ %41, %33 ], [ 0, %31 ]
%36 = getelementptr inbounds i32, i32* %22, i64 %34
%37 = load i32, i32* %36
%38 = call i32 @RabbinMillerTest(i32 %37)
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
%41 = add nuw nsw i32 %35, %40
%42 = add nuw nsw i64 %34, 1
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %33, label %46
46: ; preds = %33, %31
%47 = phi i32 [ 0, %31 ], [ %41, %33 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = call i32 @fclose(i32* %12)
br label %50
50: ; preds = %46, %14, %6
%51 = phi i32 [ -1, %6 ], [ -1, %14 ], [ 0, %46 ]
ret i32 %51
}