#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 *, ...);
int /*<<< orphan*/ printf(char *);
int Lab1_saveoutput(int **C, int *n, double Time) {
  FILE *op;
  int i, j;
  if ((op = fopen("data_output", "w")) == NULL) {
    printf("Error opening the output file.\n");
    return 1;
  }
  fprintf(op, "%d\n\n", *n);
  for (i = 0; i < *n; i++) {
    for (j = 0; j < *n; j++)
      fprintf(op, "%d\t", C[i][j]);
    fprintf(op, "\n");
  }
  fprintf(op, "%f\n", Time);
  fclose(op);
  return 0;
}


x86 assembly (clang, -O0):
<Lab1_saveoutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
lea    0xea4(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    118e <Lab1_saveoutput+0x4e>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124c <Lab1_saveoutput+0x10c>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1225 <Lab1_saveoutput+0xe5>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    1205 <Lab1_saveoutput+0xc5>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c3 <Lab1_saveoutput+0x83>
mov    -0x28(%rbp),%rdi
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ad <Lab1_saveoutput+0x6d>
mov    -0x28(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe02(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lab1_saveoutput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xe93(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1226 <Lab1_saveoutput+0xd6>
mov    %rax,%r13
mov    0x0(%rbp),%edx
lea    0xe7f(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%eax
test   %eax,%eax
jle    1204 <Lab1_saveoutput+0xb4>
lea    0xe6c(%rip),%r12
xor    %ebx,%ebx
jmp    11ca <Lab1_saveoutput+0x7a>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbx
movslq 0x0(%rbp),%rax
cmp    %rax,%rbx
jge    1204 <Lab1_saveoutput+0xb4>
test   %eax,%eax
jle    11b0 <Lab1_saveoutput+0x60>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rax
mov    (%rax,%r14,4),%edx
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%r14
movslq 0x0(%rbp),%rax
cmp    %rax,%r14
jl     11e0 <Lab1_saveoutput+0x90>
jmp    11b0 <Lab1_saveoutput+0x60>
lea    0xe0c(%rip),%rsi
mov    %r13,%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1237 <Lab1_saveoutput+0xe7>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"data_output\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"Error opening the output file.\0A\00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [4 x i8] c"%d\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [4 x i8] c"%f\0A\00"
define i32 @Lab1_saveoutput(i32** %0, i32* %1, double %2) {
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32*
%7 = alloca double
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32** %0, i32*** %5
store i32* %1, i32** %6
store double %2, double* %7
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %58
15: ; preds = %3
%16 = load i32*, i32** %8
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %18)
store i32 0, i32* %9
br label %20
20: ; preds = %49, %15
%21 = load i32, i32* %9
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %52
25: ; preds = %20
store i32 0, i32* %10
br label %26
26: ; preds = %43, %25
%27 = load i32, i32* %10
%28 = load i32*, i32** %6
%29 = load i32, i32* %28
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %46
31: ; preds = %26
%32 = load i32*, i32** %8
%33 = load i32**, i32*** %5
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32*, i32** %33, i64 %35
%37 = load i32*, i32** %36
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %31
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %26
46: ; preds = %26
%47 = load i32*, i32** %8
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %46
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %20
52: ; preds = %20
%53 = load i32*, i32** %8
%54 = load double, double* %7
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %54)
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
store i32 0, i32* %4
br label %58
58: ; preds = %52, %13
%59 = load i32, i32* %4
ret i32 %59
}

LLVM IR (-O2):
@.str = [12 x i8] c"data_output\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [5 x i8] c"%d\0A\0A\00"
@.str.4 = [4 x i8] c"%d\09\00"
@.str.6 = [4 x i8] c"%f\0A\00"
@str = [31 x i8] c"Error opening the output file.\00"
define i32 @Lab1_saveoutput(i32** nocapture %0, i32* nocapture %1, double %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 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 %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %38
8: ; preds = %3
%9 = load i32, i32* %1
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %8, %29
%14 = phi i32 [ %32, %29 ], [ %11, %8 ]
%15 = phi i64 [ %31, %29 ], [ 0, %8 ]
%16 = icmp sgt i32 %14, 0
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = getelementptr inbounds i32*, i32** %0, i64 %15
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %25, %19 ]
%21 = load i32*, i32** %18
%22 = getelementptr inbounds i32, i32* %21, i64 %20
%23 = load i32, i32* %22
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %20, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %19, label %29
29: ; preds = %19, %13
%30 = tail call i32 @fputc(i32 10, i32* %4)
%31 = add nuw nsw i64 %15, 1
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %13, label %35
35: ; preds = %29, %8
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double %2)
%37 = tail call i32 @fclose(i32* %4)
br label %38
38: ; preds = %35, %6
%39 = phi i32 [ 1, %6 ], [ 0, %35 ]
ret i32 %39
}