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


x86 assembly (clang, -O0):
<WritePrivateParametersToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea6(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1188 <WritePrivateParametersToFile+0x48>
mov    -0x18(%rbp),%rax
lea    0xe99(%rip),%rcx
mov    %rcx,(%rax)
jmp    1206 <WritePrivateParametersToFile+0xc6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ef <WritePrivateParametersToFile+0xaf>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    $0xa,%esi
call   1050 <mpz_out_str@plt>
cmp    $0x0,%rax
jne    11d1 <WritePrivateParametersToFile+0x91>
mov    -0x18(%rbp),%rax
lea    0xe61(%rip),%rcx
mov    %rcx,(%rax)
jmp    1206 <WritePrivateParametersToFile+0xc6>
mov    -0x28(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <WritePrivateParametersToFile+0x4f>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
lea    0xe3b(%rip),%rcx
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WritePrivateParametersToFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xea6(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11bd <WritePrivateParametersToFile+0x7d>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11ac <WritePrivateParametersToFile+0x6c>
mov    %ebp,%r13d
xor    %ebp,%ebp
lea    0xeac(%rip),%r12
xchg   %ax,%ax
mov    (%r15,%rbp,4),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <mpz_out_str@plt>
test   %rax,%rax
je     11c4 <WritePrivateParametersToFile+0x84>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1180 <WritePrivateParametersToFile+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe81(%rip),%r12
jmp    11c4 <WritePrivateParametersToFile+0x84>
lea    0xe55(%rip),%r12
mov    %r12,(%r14)
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"w\00"
@.str.2 = [17 x i8] c"file open failed\00"
@.str.3 = [18 x i8] c"file write failed\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [8 x i8] c"success\00"
define void @WritePrivateParametersToFile(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 ([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* %9, i32** %8
%10 = load i32*, i32** %8
%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 %40
14: ; preds = %3
store i32 0, i32* %7
br label %15
15: ; preds = %33, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %36
19: ; preds = %15
%20 = load i32*, i32** %8
%21 = load i32*, i32** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i64 @mpz_out_str(i32* %20, i32 10, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = load i8**, i8*** %6
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %29
br label %40
30: ; preds = %19
%31 = load i32*, i32** %8
%32 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %30
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %15
36: ; preds = %15
%37 = load i32*, i32** %8
%38 = call i32 @fclose(i32* %37)
%39 = load i8**, i8*** %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %39
br label %40
40: ; preds = %36, %28, %12
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.5 = [8 x i8] c"success\00"
define void @WritePrivateParametersToFile(i32* nocapture %0, i32 %1, i8** nocapture writeonly %2) {
%4 = 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))
%5 = icmp eq i32* %4, null
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %20
8: ; preds = %6
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %16
%11 = phi i64 [ 0, %8 ], [ %18, %16 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = tail call i64 @mpz_out_str(i32* %4, i32 10, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = tail call i32 @fputc(i32 10, i32* %4)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %10
20: ; preds = %16, %6
%21 = tail call i32 @fclose(i32* %4)
br label %22
22: ; preds = %10, %3, %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), %3 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %10 ]
store i8* %23, i8** %2
ret void
}