#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 *);
int /*<<< orphan*/ diagonalize(double *, int, int, double *, 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];
  int N;
  int K;
  double *data, *val, *vect;
  strcpy(input_file, argv[1]);
  N = (int)atoi(argv[2]);
  K = (int)atoi(argv[3]);
  strcpy(output_file1, argv[4]);
  strcpy(output_file2, argv[5]);
  data = (double *)malloc(N * N * sizeof(double));
  val = (double *)malloc(K * sizeof(double));
  vect = (double *)malloc(N * K * sizeof(double));
  read_data_double(input_file, N, N, data);
  diagonalize(data, N, K, val, vect);
  write_data_double(output_file1, K, 1, val);
  write_data_double(output_file2, N, K, vect);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x630,%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   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x614(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x618(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x610(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x614(%rbp),%eax
imul   -0x614(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x620(%rbp)
movslq -0x618(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x628(%rbp)
mov    -0x614(%rbp),%eax
imul   -0x618(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x630(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x614(%rbp),%esi
mov    -0x614(%rbp),%edx
mov    -0x620(%rbp),%rcx
call   1040 <read_data_double@plt>
mov    -0x620(%rbp),%rdi
mov    -0x614(%rbp),%esi
mov    -0x618(%rbp),%edx
mov    -0x628(%rbp),%rcx
mov    -0x630(%rbp),%r8
call   1060 <diagonalize@plt>
lea    -0x410(%rbp),%rdi
mov    -0x618(%rbp),%esi
mov    -0x628(%rbp),%rcx
mov    $0x1,%edx
call   1070 <write_data_double@plt>
lea    -0x610(%rbp),%rdi
mov    -0x614(%rbp),%esi
mov    -0x618(%rbp),%edx
mov    -0x630(%rbp),%rcx
call   1070 <write_data_double@plt>
xor    %eax,%eax
add    $0x630,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x608,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x200(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %rax,%rbp
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %rax,%r14
mov    0x20(%rbx),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x28(%rbx),%rsi
lea    0x400(%rsp),%r13
mov    %r13,%rdi
call   1030 <strcpy@plt>
mov    %ebp,%edi
imul   %ebp,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
imul   %ebp,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0x200(%rsp),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <read_data_double@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15,%rcx
mov    %r12,%r8
call   1060 <diagonalize@plt>
mov    %rsp,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <write_data_double@plt>
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r12,%rcx
call   1070 <write_data_double@plt>
xor    %eax,%eax
add    $0x608,%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 i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcpy(i8* %14, i8* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i64 @atoi(i8* %21)
%23 = trunc i64 %22 to i32
store i32 %23, i32* %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call i64 @atoi(i8* %26)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %10
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
%33 = call i32 @strcpy(i8* %29, i8* %32)
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 5
%37 = load i8*, i8** %36
%38 = call i32 @strcpy(i8* %34, i8* %37)
%39 = load i32, i32* %9
%40 = load i32, i32* %9
%41 = mul nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = mul i64 %42, 8
%44 = trunc i64 %43 to i32
%45 = call i64 @malloc(i32 %44)
%46 = inttoptr i64 %45 to double*
store double* %46, double** %11
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = mul i64 %48, 8
%50 = trunc i64 %49 to i32
%51 = call i64 @malloc(i32 %50)
%52 = inttoptr i64 %51 to double*
store double* %52, double** %12
%53 = load i32, i32* %9
%54 = load i32, i32* %10
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 8
%58 = trunc i64 %57 to i32
%59 = call i64 @malloc(i32 %58)
%60 = inttoptr i64 %59 to double*
store double* %60, double** %13
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%62 = load i32, i32* %9
%63 = load i32, i32* %9
%64 = load double*, double** %11
%65 = call i32 @read_data_double(i8* %61, i32 %62, i32 %63, double* %64)
%66 = load double*, double** %11
%67 = load i32, i32* %9
%68 = load i32, i32* %10
%69 = load double*, double** %12
%70 = load double*, double** %13
%71 = call i32 @diagonalize(double* %66, i32 %67, i32 %68, double* %69, double* %70)
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%73 = load i32, i32* %10
%74 = load double*, double** %12
%75 = call i32 @write_data_double(i8* %72, i32 %73, i32 1, double* %74)
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%77 = load i32, i32* %9
%78 = load i32, i32* %10
%79 = load double*, double** %13
%80 = call i32 @write_data_double(i8* %76, i32 %77, i32 %78, double* %79)
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 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @strcpy(i8* %6, i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i64 @atoi(i8* %13)
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = call i64 @atoi(i8* %17)
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %7, i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 5
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %8, i8* %24)
%26 = mul i64 %14, %14
%27 = trunc i64 %26 to i32
%28 = shl i32 %27, 3
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to double*
%31 = shl i32 %19, 3
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to double*
%34 = mul i64 %18, %14
%35 = trunc i64 %34 to i32
%36 = shl i32 %35, 3
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to double*
%39 = call i32 @read_data_double(i8* %6, i32 %15, i32 %15, double* %30)
%40 = call i32 @diagonalize(double* %30, i32 %15, i32 %19, double* %33, double* %38)
%41 = call i32 @write_data_double(i8* %7, i32 %19, i32 1, double* %33)
%42 = call i32 @write_data_double(i8* %8, i32 %15, i32 %19, double* %38)
ret i32 0
}