#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long);
int Save_File(char *Filename, long *Array, int Size) {
  FILE *fptr = fopen(Filename, "w");
  int numbers_written = 0;
  if (fptr == NULL)
    return (-1);
  fprintf(fptr, "%d\n", Size);
  int i;
  for (i = 0; i < Size; ++i) {
    fprintf(fptr, "%ld\n", Array[i]);
    ++numbers_written;
  }
  fclose(fptr);
  return numbers_written;
}


x86 assembly (clang, -O0):
<Save_File>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1175 <Save_File+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    11de <Save_File+0xae>
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rdx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11cf <Save_File+0x9f>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe53(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1190 <Save_File+0x60>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Save_File>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     119a <Save_File+0x6a>
mov    %rax,%r13
movslq %r14d,%r15
lea    0xea3(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1040 <fprintf@plt>
test   %r15d,%r15d
jle    11a2 <Save_File+0x72>
mov    %r14d,%ebp
xor    %ebx,%ebx
lea    0xe8b(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,8),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <Save_File+0x50>
jmp    11a5 <Save_File+0x75>
mov    $0xffffffff,%r14d
jmp    11ad <Save_File+0x7d>
xor    %r14d,%r14d
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @Save_File(i8* %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
store i32 0, i32* %9
%13 = load i32*, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 -1, i32* %4
br label %42
16: ; preds = %3
%17 = load i32*, i32** %8
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %19)
store i32 0, i32* %10
br label %21
21: ; preds = %35, %16
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i32*, i32** %8
%27 = load i64*, i64** %6
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i64, i64* %27, i64 %29
%31 = load i64, i64* %30
%32 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %31)
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %35
35: ; preds = %25
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %21
38: ; preds = %21
%39 = load i32*, i32** %8
%40 = call i32 @fclose(i32* %39)
%41 = load i32, i32* %9
store i32 %41, i32* %4
br label %42
42: ; preds = %38, %15
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @Save_File(i8* nocapture %0, i64* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = sext i32 %2 to i64
%8 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %17, %12 ]
%14 = getelementptr inbounds i64, i64* %1, i64 %13
%15 = load i64, i64* %14
%16 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %11
br i1 %18, label %19, label %12
19: ; preds = %12, %6
%20 = phi i32 [ 0, %6 ], [ %2, %12 ]
%21 = tail call i32 @fclose(i32* %4)
br label %22
22: ; preds = %3, %19
%23 = phi i32 [ %20, %19 ], [ -1, %3 ]
ret i32 %23
}