#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 Montgomery(int, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(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;
  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);
  printf("%d\n", n);
  n *= 3;
  p = (int *)malloc(sizeof(int) * n);
  i = 0;
  for (i = 0; i < n;) {
    fscanf(fp, "%d", &p[i++]);
    fgetc(fp);
    fscanf(fp, "%d", &p[i++]);
    fgetc(fp);
    fscanf(fp, "%d", &p[i++]);
    fgetc(fp);
  }
  for (i = 0; i < n; i += 3) {
    printf("%d\n", Montgomery(p[i], p[i + 1], p[i + 2]));
  }
  fclose(fp);
  return 1;
}


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     11c1 <main+0x41>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1366 <main+0x1e6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1204 <main+0x84>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1366 <main+0x1e6>
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
imul   $0x3,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12f5 <main+0x175>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdd6(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xda5(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd74(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
jmp    1251 <main+0xd1>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1356 <main+0x1d6>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
call   1030 <Montgomery@plt>
mov    %eax,%esi
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x20(%rbp)
jmp    12fc <main+0x17c>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-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    12a8 <main+0x128>
mov    0x8(%rsi),%rdi
lea    0xe8d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12b1 <main+0x131>
mov    %rax,%r12
lea    0xe9e(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    0xc(%rsp),%esi
lea    0xe89(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
lea    (%rax,%rax,2),%ecx
mov    %ecx,0xc(%rsp)
shl    $0x2,%eax
lea    (%rax,%rax,2),%edi
call   1090 <malloc@plt>
cmpl   $0x0,0xc(%rsp)
jle    1299 <main+0x119>
mov    %rax,%r14
lea    0xe52(%rip),%r15
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
lea    0x4(%rbx),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
lea    0x8(%rbx),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
mov    0xc(%rsp),%eax
add    $0xc,%rbx
add    $0x3,%ebp
cmp    %ebp,%eax
jg     1210 <main+0x90>
test   %eax,%eax
jle    1299 <main+0x119>
lea    0xdeb(%rip),%rbx
xor    %ebp,%ebp
mov    (%r14,%rbp,4),%edi
mov    0x4(%r14,%rbp,4),%esi
mov    0x8(%r14,%rbp,4),%edx
call   1030 <Montgomery@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x3,%rbp
cmp    %ebp,0xc(%rsp)
jg     1270 <main+0xf0>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    12cb <main+0x14b>
lea    0xd51(%rip),%rdi
jmp    12b8 <main+0x138>
lea    0xd77(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    $0xffffffff,%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 = [4 x i8] c"%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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (...) @getchar()
store i32 -1, i32* %3
br label %100
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (...) @getchar()
store i32 -1, i32* %3
br label %100
24: ; preds = %15
%25 = load i32*, i32** %6
%26 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %7
%30 = mul nsw i32 %29, 3
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = mul i64 4, %32
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i32*
store i32* %36, i32** %9
store i32 0, i32* %8
store i32 0, i32* %8
br label %37
37: ; preds = %41, %24
%38 = load i32, i32* %8
%39 = load i32, i32* %7
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %69
41: ; preds = %37
%42 = load i32*, i32** %6
%43 = load i32*, i32** %9
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i32, i32* %43, i64 %46
%48 = call i32 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %47)
%49 = load i32*, i32** %6
%50 = call i32 @fgetc(i32* %49)
%51 = load i32*, i32** %6
%52 = load i32*, i32** %9
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i32, i32* %52, i64 %55
%57 = call i32 @fscanf(i32* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %56)
%58 = load i32*, i32** %6
%59 = call i32 @fgetc(i32* %58)
%60 = load i32*, i32** %6
%61 = load i32*, i32** %9
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i32, i32* %61, i64 %64
%66 = call i32 @fscanf(i32* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %65)
%67 = load i32*, i32** %6
%68 = call i32 @fgetc(i32* %67)
br label %37
69: ; preds = %37
store i32 0, i32* %8
br label %70
70: ; preds = %94, %69
%71 = load i32, i32* %8
%72 = load i32, i32* %7
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %97
74: ; preds = %70
%75 = load i32*, i32** %9
%76 = load i32, i32* %8
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %75, i64 %77
%79 = load i32, i32* %78
%80 = load i32*, i32** %9
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %80, i64 %83
%85 = load i32, i32* %84
%86 = load i32*, i32** %9
%87 = load i32, i32* %8
%88 = add nsw i32 %87, 2
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %86, i64 %89
%91 = load i32, i32* %90
%92 = call i32 @Montgomery(i32 %79, i32 %85, i32 %91)
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %74
%95 = load i32, i32* %8
%96 = add nsw i32 %95, 3
store i32 %96, i32* %8
br label %70
97: ; preds = %70
%98 = load i32*, i32** %6
%99 = call i32 @fclose(i32* %98)
store i32 1, i32* %3
br label %100
100: ; preds = %97, %21, %12
%101 = load i32, i32* %3
ret i32 %101
}

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 = [4 x i8] c"%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 %65
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 %65
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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 3
store i32 %22, i32* %3
%23 = mul i32 %21, 12
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 0
br i1 %27, label %30, label %63
28: ; preds = %30
%29 = icmp sgt i32 %44, 0
br i1 %29, label %47, label %63
30: ; preds = %17, %30
%31 = phi i64 [ %40, %30 ], [ 0, %17 ]
%32 = add nuw nsw i64 %31, 1
%33 = getelementptr inbounds i32, i32* %25, i64 %31
%34 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %33)
%35 = call i32 @fgetc(i32* %12)
%36 = add nuw nsw i64 %31, 2
%37 = getelementptr inbounds i32, i32* %25, i64 %32
%38 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %37)
%39 = call i32 @fgetc(i32* %12)
%40 = add nuw i64 %31, 3
%41 = getelementptr inbounds i32, i32* %25, i64 %36
%42 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %41)
%43 = call i32 @fgetc(i32* %12)
%44 = load i32, i32* %3
%45 = trunc i64 %40 to i32
%46 = icmp sgt i32 %44, %45
br i1 %46, label %30, label %28
47: ; preds = %28, %47
%48 = phi i64 [ %59, %47 ], [ 0, %28 ]
%49 = getelementptr inbounds i32, i32* %25, i64 %48
%50 = load i32, i32* %49
%51 = add nuw nsw i64 %48, 1
%52 = getelementptr inbounds i32, i32* %25, i64 %51
%53 = load i32, i32* %52
%54 = add nuw nsw i64 %48, 2
%55 = getelementptr inbounds i32, i32* %25, i64 %54
%56 = load i32, i32* %55
%57 = call i32 @Montgomery(i32 %50, i32 %53, i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = add nuw i64 %48, 3
%60 = load i32, i32* %3
%61 = trunc i64 %59 to i32
%62 = icmp sgt i32 %60, %61
br i1 %62, label %47, label %63
63: ; preds = %47, %17, %28
%64 = call i32 @fclose(i32* %12)
br label %65
65: ; preds = %63, %14, %6
%66 = phi i32 [ -1, %6 ], [ -1, %14 ], [ 1, %63 ]
ret i32 %66
}