#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 ReadPublicParameters(mpz_t n, mpz_t u, int l, char **error) {
  FILE *fd;
  int i;
  fd = fopen("public_params", "r");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  if (mpz_inp_str(n, fd, 10) == 0) {
    *error = "file read failed";
    return;
  }
  if (mpz_inp_str(u, fd, 10) == 0) {
    *error = "file read failed";
    return;
  }
  fclose(fd);
  *error = "success";
}


x86 assembly (clang, -O0):
<ReadPublicParameters>:
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    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117a <ReadPublicParameters+0x4a>
mov    -0x18(%rbp),%rax
lea    0xe9e(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ed <ReadPublicParameters+0xbd>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11a8 <ReadPublicParameters+0x78>
mov    -0x18(%rbp),%rax
lea    0xe81(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ed <ReadPublicParameters+0xbd>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11d6 <ReadPublicParameters+0xa6>
mov    -0x18(%rbp),%rax
lea    0xe53(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ed <ReadPublicParameters+0xbd>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
lea    0xe48(%rip),%rcx
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadPublicParameters>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %esi,%r15d
mov    %edi,%ebp
lea    0xeba(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     119b <ReadPublicParameters+0x6b>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
lea    0xeb1(%rip),%rbp
test   %rax,%rax
je     11a2 <ReadPublicParameters+0x72>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
test   %rax,%rax
je     11a2 <ReadPublicParameters+0x72>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe99(%rip),%rbp
jmp    11a2 <ReadPublicParameters+0x72>
lea    0xe6e(%rip),%rbp
mov    %rbp,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"public_params\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 = [8 x i8] c"success\00"
define void @ReadPublicParameters(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 ([14 x i8], [14 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** %9
%12 = load i32*, i32** %9
%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 %34
16: ; preds = %4
%17 = load i32, i32* %5
%18 = load i32*, i32** %9
%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 %34
23: ; preds = %16
%24 = load i32, i32* %6
%25 = load i32*, i32** %9
%26 = call i64 @mpz_inp_str(i32 %24, i32* %25, i32 10)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %29
br label %34
30: ; preds = %23
%31 = load i32*, i32** %9
%32 = call i32 @fclose(i32* %31)
%33 = load i8**, i8*** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %33
br label %34
34: ; preds = %30, %28, %21, %14
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"public_params\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 = [8 x i8] c"success\00"
define void @ReadPublicParameters(i32 %0, i32 %1, i32 %2, i8** nocapture writeonly %3) {
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 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 %15, label %7
7: ; preds = %4
%8 = tail call i64 @mpz_inp_str(i32 %0, i32* %5, i32 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i64 @mpz_inp_str(i32 %1, i32* %5, i32 10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @fclose(i32* %5)
br label %15
15: ; preds = %10, %7, %4, %13
%16 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %13 ], [ 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.3, i64 0, i64 0), %10 ]
store i8* %16, i8** %3
ret void
}