#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_out_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
void WritePrivateParametersToFile(mpz_t rj, char **error) {
  int i;
  FILE *fd = fopen("private_per_user_param", "w");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  if (mpz_out_str(fd, 10, rj) == 0) {
    *error = "file write failed";
    return;
  }
  fclose(fd);
  *error = "success";
}


x86 assembly (clang, -O0):
<WritePrivateParametersToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeba(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1174 <WritePrivateParametersToFile+0x44>
mov    -0x10(%rbp),%rax
lea    0xead(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b9 <WritePrivateParametersToFile+0x89>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    $0xa,%esi
call   1040 <mpz_out_str@plt>
cmp    $0x0,%rax
jne    11a2 <WritePrivateParametersToFile+0x72>
mov    -0x10(%rbp),%rax
lea    0xe90(%rip),%rcx
mov    %rcx,(%rax)
jmp    11b9 <WritePrivateParametersToFile+0x89>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
lea    0xe86(%rip),%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WritePrivateParametersToFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xec0(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1179 <WritePrivateParametersToFile+0x49>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
mov    %ebp,%edx
call   1040 <mpz_out_str@plt>
test   %rax,%rax
je     1182 <WritePrivateParametersToFile+0x52>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xec5(%rip),%rax
jmp    1189 <WritePrivateParametersToFile+0x59>
lea    0xe99(%rip),%rax
jmp    1189 <WritePrivateParametersToFile+0x59>
lea    0xea1(%rip),%rax
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"private_per_user_param\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [17 x i8] c"file open failed\00"
@.str.3 = [18 x i8] c"file write failed\00"
@.str.4 = [8 x i8] c"success\00"
define void @WritePrivateParametersToFile(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = 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* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i8**, i8*** %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %11
br label %23
12: ; preds = %2
%13 = load i32*, i32** %6
%14 = load i32, i32* %3
%15 = call i64 @mpz_out_str(i32* %13, i32 10, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = load i8**, i8*** %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %18
br label %23
19: ; preds = %12
%20 = load i32*, i32** %6
%21 = call i32 @fclose(i32* %20)
%22 = load i8**, i8*** %4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %22
br label %23
23: ; preds = %19, %17, %10
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"private_per_user_param\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [17 x i8] c"file open failed\00"
@.str.3 = [18 x i8] c"file write failed\00"
@.str.4 = [8 x i8] c"success\00"
define void @WritePrivateParametersToFile(i32 %0, i8** nocapture writeonly %1) {
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i64 @mpz_out_str(i32* %3, i32 10, i32 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @fclose(i32* %3)
br label %10
10: ; preds = %5, %2, %8
%11 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %5 ]
store i8* %11, i8** %1
ret void
}