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

/* Variables and functions */
scalar_t__ atoi(char *);
double detrm(double *, int);
int /*<<< orphan*/ fast_inverse(double *, int, double *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ read_data_double(char *, int, int, double *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ write_data_double(char *, int, int, double *);
int main(int argc, char *argv[]) {
  char input_file[512];
  char output_file1[512];
  char output_file2[512];
  char output_file3[512];
  int N;
  double *data;
  double *inv;
  double *inv2;
  double det;
  strcpy(input_file, argv[1]);
  N = (int)atoi(argv[2]);
  strcpy(output_file1, argv[3]);
  strcpy(output_file2, argv[4]);
  strcpy(output_file3, argv[5]);
  data = (double *)malloc(N * N * sizeof(double));
  inv = (double *)malloc(N * N * sizeof(double));
  inv2 = (double *)malloc(N * N * sizeof(double));
  read_data_double(input_file, N, N, data);
  fast_inverse(data, N, inv);
  write_data_double(output_file1, N, N, inv);
  det = detrm(data, N);
  write_data_double(output_file2, 1, 1, &det);
  free(data);
  free(inv);
  free(inv2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x814(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x610(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x814(%rbp),%eax
imul   -0x814(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x820(%rbp)
mov    -0x814(%rbp),%eax
imul   -0x814(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x828(%rbp)
mov    -0x814(%rbp),%eax
imul   -0x814(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x830(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x814(%rbp),%esi
mov    -0x814(%rbp),%edx
mov    -0x820(%rbp),%rcx
call   1060 <read_data_double@plt>
mov    -0x820(%rbp),%rdi
mov    -0x814(%rbp),%esi
mov    -0x828(%rbp),%rdx
call   1050 <fast_inverse@plt>
lea    -0x410(%rbp),%rdi
mov    -0x814(%rbp),%esi
mov    -0x814(%rbp),%edx
mov    -0x828(%rbp),%rcx
call   1090 <write_data_double@plt>
mov    -0x820(%rbp),%rdi
mov    -0x814(%rbp),%esi
call   1080 <detrm@plt>
movsd  %xmm0,-0x838(%rbp)
ff
lea    -0x610(%rbp),%rdi
mov    $0x1,%edx
lea    -0x838(%rbp),%rcx
mov    %edx,%esi
call   1090 <write_data_double@plt>
mov    -0x820(%rbp),%rdi
call   1030 <free@plt>
mov    -0x828(%rbp),%rdi
call   1030 <free@plt>
mov    -0x830(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rsi,%rbp
mov    0x8(%rsi),%rsi
lea    0x210(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %rax,%rbx
mov    0x18(%rbp),%rsi
lea    0x610(%rsp),%r12
mov    %r12,%rdi
call   1040 <strcpy@plt>
mov    0x20(%rbp),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x28(%rbp),%rsi
lea    0x410(%rsp),%rdi
call   1040 <strcpy@plt>
mov    %ebx,%ebp
imul   %ebx,%ebp
shl    $0x3,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0x210(%rsp),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
mov    %r13,%rcx
call   1060 <read_data_double@plt>
mov    %r13,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1050 <fast_inverse@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
mov    %r15,%rcx
call   1090 <write_data_double@plt>
mov    %r13,%rdi
mov    %ebx,%esi
call   1080 <detrm@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1090 <write_data_double@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %15, i8* %18)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i64 @atoi(i8* %22)
%24 = trunc i64 %23 to i32
store i32 %24, i32* %10
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i32 @strcpy(i8* %25, i8* %28)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 4
%33 = load i8*, i8** %32
%34 = call i32 @strcpy(i8* %30, i8* %33)
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 5
%38 = load i8*, i8** %37
%39 = call i32 @strcpy(i8* %35, i8* %38)
%40 = load i32, i32* %10
%41 = load i32, i32* %10
%42 = mul nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 8
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to double*
store double* %47, double** %11
%48 = load i32, i32* %10
%49 = load i32, i32* %10
%50 = mul nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 8
%53 = trunc i64 %52 to i32
%54 = call i64 @malloc(i32 %53)
%55 = inttoptr i64 %54 to double*
store double* %55, double** %12
%56 = load i32, i32* %10
%57 = load i32, i32* %10
%58 = mul nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 8
%61 = trunc i64 %60 to i32
%62 = call i64 @malloc(i32 %61)
%63 = inttoptr i64 %62 to double*
store double* %63, double** %13
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%65 = load i32, i32* %10
%66 = load i32, i32* %10
%67 = load double*, double** %11
%68 = call i32 @read_data_double(i8* %64, i32 %65, i32 %66, double* %67)
%69 = load double*, double** %11
%70 = load i32, i32* %10
%71 = load double*, double** %12
%72 = call i32 @fast_inverse(double* %69, i32 %70, double* %71)
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%74 = load i32, i32* %10
%75 = load i32, i32* %10
%76 = load double*, double** %12
%77 = call i32 @write_data_double(i8* %73, i32 %74, i32 %75, double* %76)
%78 = load double*, double** %11
%79 = load i32, i32* %10
%80 = call double @detrm(double* %78, i32 %79)
store double %80, double* %14
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%82 = call i32 @write_data_double(i8* %81, i32 1, i32 1, double* %14)
%83 = load double*, double** %11
%84 = call i32 @free(double* %83)
%85 = load double*, double** %12
%86 = call i32 @free(double* %85)
%87 = load double*, double** %13
%88 = call i32 @free(double* %87)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca double
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = bitcast double* %7 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcpy(i8* %8, i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %9, i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 4
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %10, i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 5
%27 = load i8*, i8** %26
%28 = call i32 @strcpy(i8* %11, i8* %27)
%29 = mul i64 %18, %18
%30 = trunc i64 %29 to i32
%31 = shl i32 %30, 3
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to double*
%34 = call i64 @malloc(i32 %31)
%35 = inttoptr i64 %34 to double*
%36 = call i64 @malloc(i32 %31)
%37 = inttoptr i64 %36 to double*
%38 = call i32 @read_data_double(i8* %8, i32 %19, i32 %19, double* %33)
%39 = call i32 @fast_inverse(double* %33, i32 %19, double* %35)
%40 = call i32 @write_data_double(i8* %9, i32 %19, i32 %19, double* %35)
%41 = call double @detrm(double* %33, i32 %19)
store double %41, double* %7
%42 = call i32 @write_data_double(i8* %10, i32 1, i32 1, double* %7)
%43 = call i32 @free(double* %33)
%44 = call i32 @free(double* %35)
%45 = call i32 @free(double* %37)
ret i32 0
}