#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, 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    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xeb7(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <ReadPublicParameters+0x47>
mov    -0x10(%rbp),%rax
lea    0xea1(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ea <ReadPublicParameters+0xba>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11a5 <ReadPublicParameters+0x75>
mov    -0x10(%rbp),%rax
lea    0xe84(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ea <ReadPublicParameters+0xba>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <mpz_inp_str@plt>
cmp    $0x0,%rax
jne    11d3 <ReadPublicParameters+0xa3>
mov    -0x10(%rbp),%rax
lea    0xe56(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ea <ReadPublicParameters+0xba>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
lea    0xe4b(%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    %rdx,%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, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%9 = 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* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i8**, i8*** %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %13
br label %32
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i32*, i32** %7
%17 = call i64 @mpz_inp_str(i32 %15, i32* %16, i32 10)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i8**, i8*** %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %20
br label %32
21: ; preds = %14
%22 = load i32, i32* %5
%23 = load i32*, i32** %7
%24 = call i64 @mpz_inp_str(i32 %22, i32* %23, i32 10)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i8**, i8*** %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %27
br label %32
28: ; preds = %21
%29 = load i32*, i32** %7
%30 = call i32 @fclose(i32* %29)
%31 = load i8**, i8*** %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %31
br label %32
32: ; preds = %28, %26, %19, %12
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, i8** nocapture writeonly %2) {
%4 = 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))
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i64 @mpz_inp_str(i32 %0, i32* %4, i32 10)
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i64 @mpz_inp_str(i32 %1, i32* %4, i32 10)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @fclose(i32* %4)
br label %14
14: ; preds = %9, %6, %3, %12
%15 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %9 ]
store i8* %15, i8** %2
ret void
}