#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;
  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    $0x20,%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    $0x20,%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*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%10 = 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* %10, i32** %9
%11 = load i32*, i32** %9
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %14
br label %33
15: ; preds = %4
%16 = load i32, i32* %5
%17 = load i32*, i32** %9
%18 = call i64 @mpz_inp_str(i32 %16, i32* %17, i32 10)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %21
br label %33
22: ; preds = %15
%23 = load i32, i32* %6
%24 = load i32*, i32** %9
%25 = call i64 @mpz_inp_str(i32 %23, i32* %24, i32 10)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load i8**, i8*** %8
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %28
br label %33
29: ; preds = %22
%30 = load i32*, i32** %9
%31 = call i32 @fclose(i32* %30)
%32 = load i8**, i8*** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %32
br label %33
33: ; preds = %29, %27, %20, %13
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
}