#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 *);
scalar_t__ mpz_inp_str(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
void ReadPrivateParameters(mpz_t p, mpz_t q, mpz_t r, char **error) {
  int i;
  FILE *fd;
  fd = fopen("private_per_user_param", "r");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  if (mpz_inp_str(r, 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    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
lea    0xeb4(%rip),%rdi
lea    0xec4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117a <ReadPrivateParameters+0x4a>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
mov    %rcx,(%rax)
jmp    1267 <ReadPrivateParameters+0x137>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11a8 <ReadPrivateParameters+0x78>
mov    -0x18(%rbp),%rax
lea    0xe8a(%rip),%rcx
mov    %rcx,(%rax)
jmp    1267 <ReadPrivateParameters+0x137>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe83(%rip),%rdi
lea    0xe58(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e6 <ReadPrivateParameters+0xb6>
mov    -0x18(%rbp),%rax
lea    0xe3b(%rip),%rcx
mov    %rcx,(%rax)
jmp    1267 <ReadPrivateParameters+0x137>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    1214 <ReadPrivateParameters+0xe4>
mov    -0x18(%rbp),%rax
lea    0xe1e(%rip),%rcx
mov    %rcx,(%rax)
jmp    1267 <ReadPrivateParameters+0x137>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    1242 <ReadPrivateParameters+0x112>
mov    -0x18(%rbp),%rax
lea    0xdf0(%rip),%rcx
mov    %rcx,(%rax)
jmp    1267 <ReadPrivateParameters+0x137>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
lea    0xdf4(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xde6(%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    %rcx,%r12
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
lea    0xeb3(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1050 <fopen@plt>
lea    0xeb9(%rip),%r13
test   %rax,%rax
je     11eb <ReadPrivateParameters+0xbb>
mov    %rax,%rbp
mov    %ebx,%edi
mov    %rax,%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
lea    0xea8(%rip),%rbx
test   %rax,%rax
je     11e8 <ReadPrivateParameters+0xb8>
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xea5(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11eb <ReadPrivateParameters+0xbb>
mov    %rax,%rbp
mov    %r15d,%edi
mov    %rax,%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
test   %rax,%rax
je     11e8 <ReadPrivateParameters+0xb8>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
mov    %rbx,%r13
test   %rax,%rax
je     11eb <ReadPrivateParameters+0xbb>
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xe64(%rip),%r13
jmp    11eb <ReadPrivateParameters+0xbb>
mov    %rbx,%r13
mov    %r13,(%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, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%11 = 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* %11, i32** %10
%12 = load i32*, i32** %10
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %15
br label %50
16: ; preds = %4
%17 = load i32, i32* %7
%18 = load i32*, i32** %10
%19 = call i64 @mpz_inp_str(i32 %17, i32* %18, i32 10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %22
br label %50
23: ; preds = %16
%24 = load i32*, i32** %10
%25 = call i32 @fclose(i32* %24)
%26 = 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* %26, i32** %10
%27 = load i32*, i32** %10
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %30
br label %50
31: ; preds = %23
%32 = load i32, i32* %5
%33 = load i32*, i32** %10
%34 = call i64 @mpz_inp_str(i32 %32, i32* %33, i32 10)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %37
br label %50
38: ; preds = %31
%39 = load i32, i32* %6
%40 = load i32*, i32** %10
%41 = call i64 @mpz_inp_str(i32 %39, i32* %40, i32 10)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %44
br label %50
45: ; preds = %38
%46 = load i32*, i32** %10
%47 = call i32 @fclose(i32* %46)
%48 = load i8**, i8*** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %48
%49 = load i8**, i8*** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %49
br label %50
50: ; preds = %45, %43, %36, %29, %21, %14
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 %2, i8** nocapture writeonly %3) {
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %22, label %7
7: ; preds = %4
%8 = tail call i64 @mpz_inp_str(i32 %2, i32* %5, i32 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = tail call i32 @fclose(i32* %5)
%12 = 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))
%13 = icmp eq i32* %12, null
br i1 %13, label %22, label %14
14: ; preds = %10
%15 = tail call i64 @mpz_inp_str(i32 %0, i32* %12, i32 10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = tail call i64 @mpz_inp_str(i32 %1, i32* %12, i32 10)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @fclose(i32* %12)
br label %22
22: ; preds = %17, %14, %10, %7, %4, %20
%23 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %20 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %14 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %17 ]
store i8* %23, i8** %3
ret void
}