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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
scalar_t__ mpz_inp_str(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
void ReadPrivateParameters(mpz_t p, mpz_t q, mpz_t *r, int l, char **error) {
  int i;
  FILE *fd;
  fd = fopen("private_per_user_param", "r");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  for (i = 0; i < l; i++) {
    mpz_init(r[i]);
    if (mpz_inp_str(r[i], fd, 10) == 0) {
      *error = "file read failed";
      return;
    }
  }
  fclose(fd);
  fd = fopen("private_params", "r");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  if (mpz_inp_str(p, fd, 10) == 0) {
    *error = "file read failed";
    return;
  }
  if (mpz_inp_str(q, fd, 10) == 0) {
    *error = "file read failed";
    return;
  }
  fclose(fd);
  *error = "success";
  *error = "success";
}


x86 assembly (clang, -O0):
<ReadPrivateParameters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
lea    0xea0(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    118e <ReadPrivateParameters+0x4e>
mov    -0x20(%rbp),%rax
lea    0xe93(%rip),%rcx
mov    %rcx,(%rax)
jmp    12b9 <ReadPrivateParameters+0x179>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fa <ReadPrivateParameters+0xba>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <mpz_init@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11e7 <ReadPrivateParameters+0xa7>
mov    -0x20(%rbp),%rax
lea    0xe4b(%rip),%rcx
mov    %rcx,(%rax)
jmp    12b9 <ReadPrivateParameters+0x179>
jmp    11ec <ReadPrivateParameters+0xac>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1195 <ReadPrivateParameters+0x55>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe31(%rip),%rdi
lea    0xe06(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1238 <ReadPrivateParameters+0xf8>
mov    -0x20(%rbp),%rax
lea    0xde9(%rip),%rcx
mov    %rcx,(%rax)
jmp    12b9 <ReadPrivateParameters+0x179>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    1266 <ReadPrivateParameters+0x126>
mov    -0x20(%rbp),%rax
lea    0xdcc(%rip),%rcx
mov    %rcx,(%rax)
jmp    12b9 <ReadPrivateParameters+0x179>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    1294 <ReadPrivateParameters+0x154>
mov    -0x20(%rbp),%rax
lea    0xd9e(%rip),%rcx
mov    %rcx,(%rax)
jmp    12b9 <ReadPrivateParameters+0x179>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
lea    0xda2(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
lea    0xd94(%rip),%rcx
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadPrivateParameters>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r12
mov    %ecx,%r13d
mov    %rdx,%rbp
mov    %esi,%r15d
mov    %edi,0x4(%rsp)
lea    0xe9e(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
lea    0xea4(%rip),%r14
test   %rax,%rax
je     1227 <ReadPrivateParameters+0xe7>
mov    %rax,%rbx
mov    %r15d,(%rsp)
test   %r13d,%r13d
jle    11ba <ReadPrivateParameters+0x7a>
mov    %r13d,%r13d
xor    %r15d,%r15d
mov    0x0(%rbp,%r15,4),%edi
call   1040 <mpz_init@plt>
mov    0x0(%rbp,%r15,4),%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
test   %rax,%rax
je     1220 <ReadPrivateParameters+0xe0>
add    $0x1,%r15
cmp    %r15,%r13
jne    1190 <ReadPrivateParameters+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe72(%rip),%rdi
lea    0xe47(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1227 <ReadPrivateParameters+0xe7>
mov    %rax,%rbx
mov    0x4(%rsp),%edi
mov    %rax,%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
lea    0xe35(%rip),%r14
test   %rax,%rax
je     1227 <ReadPrivateParameters+0xe7>
mov    (%rsp),%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <mpz_inp_str@plt>
test   %rax,%rax
je     1227 <ReadPrivateParameters+0xe7>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe2c(%rip),%r14
jmp    1227 <ReadPrivateParameters+0xe7>
lea    0xe03(%rip),%r14
mov    %r14,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"private_per_user_param\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"file open failed\00"
@.str.3 = [17 x i8] c"file read failed\00"
@.str.4 = [15 x i8] c"private_params\00"
@.str.5 = [8 x i8] c"success\00"
define void @ReadPrivateParameters(i32 %0, i32 %1, i32* %2, i32 %3, i8** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i8** %4, i8*** %10
%13 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %12
%14 = load i32*, i32** %12
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = load i8**, i8*** %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %17
br label %71
18: ; preds = %5
store i32 0, i32* %11
br label %19
19: ; preds = %41, %18
%20 = load i32, i32* %11
%21 = load i32, i32* %9
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = load i32*, i32** %8
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 @mpz_init(i32 %28)
%30 = load i32*, i32** %8
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32*, i32** %12
%36 = call i64 @mpz_inp_str(i32 %34, i32* %35, i32 10)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %23
%39 = load i8**, i8*** %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %39
br label %71
40: ; preds = %23
br label %41
41: ; preds = %40
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %19
44: ; preds = %19
%45 = load i32*, i32** %12
%46 = call i32 @fclose(i32* %45)
%47 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %47, i32** %12
%48 = load i32*, i32** %12
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = load i8**, i8*** %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %51
br label %71
52: ; preds = %44
%53 = load i32, i32* %6
%54 = load i32*, i32** %12
%55 = call i64 @mpz_inp_str(i32 %53, i32* %54, i32 10)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = load i8**, i8*** %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %58
br label %71
59: ; preds = %52
%60 = load i32, i32* %7
%61 = load i32*, i32** %12
%62 = call i64 @mpz_inp_str(i32 %60, i32* %61, i32 10)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = load i8**, i8*** %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %65
br label %71
66: ; preds = %59
%67 = load i32*, i32** %12
%68 = call i32 @fclose(i32* %67)
%69 = load i8**, i8*** %10
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %69
%70 = load i8**, i8*** %10
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %70
br label %71
71: ; preds = %66, %64, %57, %50, %38, %16
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"private_per_user_param\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"file open failed\00"
@.str.3 = [17 x i8] c"file read failed\00"
@.str.4 = [15 x i8] c"private_params\00"
@.str.5 = [8 x i8] c"success\00"
define void @ReadPrivateParameters(i32 %0, i32 %1, i32* nocapture %2, i32 %3, i8** nocapture writeonly %4) {
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %35, label %8
8: ; preds = %5
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %23
10: ; preds = %8
%11 = zext i32 %3 to i64
br label %14
12: ; preds = %14
%13 = icmp eq i64 %22, %11
br i1 %13, label %23, label %14
14: ; preds = %10, %12
%15 = phi i64 [ 0, %10 ], [ %22, %12 ]
%16 = getelementptr inbounds i32, i32* %2, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 @mpz_init(i32 %17)
%19 = load i32, i32* %16
%20 = tail call i64 @mpz_inp_str(i32 %19, i32* %6, i32 10)
%21 = icmp eq i64 %20, 0
%22 = add nuw nsw i64 %15, 1
br i1 %21, label %35, label %12
23: ; preds = %12, %8
%24 = tail call i32 @fclose(i32* %6)
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %35, label %27
27: ; preds = %23
%28 = tail call i64 @mpz_inp_str(i32 %0, i32* %25, i32 10)
%29 = icmp eq i64 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = tail call i64 @mpz_inp_str(i32 %1, i32* %25, i32 10)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 @fclose(i32* %25)
br label %35
35: ; preds = %14, %30, %27, %23, %5, %33
%36 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %33 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %23 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %27 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %14 ]
store i8* %36, i8** %4
ret void
}