#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*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ housholder(double *, int, int, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_matrix(double *, int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, double *);
int main(int argc, char *args[]) {
  int i;
  double *P = (double *)malloc(sizeof(double) * 10 * 10);
  double *D = (double *)malloc(sizeof(double) * 10 * 10);
  memset(D, 0, sizeof(double) * 10 * 10);
  memset(P, 0, sizeof(double) * 10 * 10);
  FILE *fp = NULL;
  if (!(fp = fopen("E:\\data.txt", "r"))) {
    printf("cant open file to read!\n");
    exit(1);
  }
  int index = 0;
  char buffer[10240];
  for (index = 0; index < 10; index++) {
    fgets(buffer, 10240, fp);
    printf("%s\n", buffer);
    for (i = 0; i < 10; i++) {
      sscanf(buffer + i * 10, "%lf", P + 10 * i + index);
    }
  }
  print_matrix(P, 10, 10, "P MATRIX");
  housholder(P, 10, 6, 6, 1);
  print_matrix(P, 10, 10, "P MATRIX");
  free(P);
  free(D);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
movq   $0x0,-0x30(%rbp)
lea    0xdfc(%rip),%rdi
lea    0xe01(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1236 <main+0x96>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    12e2 <main+0x142>
lea    -0x2840(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x2800,%esi
call   1070 <fgets@plt>
lea    -0x2840(%rbp),%rsi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    12cf <main+0x12f>
lea    -0x2840(%rbp),%rdi
imul   $0xa,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
mov    -0x20(%rbp),%rdx
imul   $0xa,-0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd6f(%rip),%rsi
call   1090 <sscanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    127f <main+0xdf>
jmp    12d4 <main+0x134>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1244 <main+0xa4>
mov    -0x20(%rbp),%rdi
mov    $0xa,%edx
lea    0xd3d(%rip),%rcx
mov    %edx,%esi
call   10b0 <print_matrix@plt>
mov    -0x20(%rbp),%rdi
mov    $0xa,%esi
mov    $0x6,%ecx
mov    $0x1,%r8d
mov    %ecx,%edx
call   1060 <housholder@plt>
mov    -0x20(%rbp),%rdi
mov    $0xa,%edx
lea    0xd0b(%rip),%rcx
mov    %edx,%esi
call   10b0 <print_matrix@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x2840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2818,%rsp
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x320,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
lea    0xe0e(%rip),%rdi
lea    0xe13(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     139c <main+0x1fc>
mov    %rax,%r15
lea    0x6a(%rsp),%r12
xor    %r14d,%r14d
lea    0x10(%rsp),%r13
lea    0xdf0(%rip),%rbp
xchg   %ax,%ax
mov    %r13,%rdi
mov    $0x2800,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    (%rbx,%r14,1),%rdx
mov    %r13,%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x50,%rdx
lea    0x1a(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0xa0,%rdx
lea    0x24(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0xf0,%rdx
lea    0x2e(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x140,%rdx
lea    0x38(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x190,%rdx
lea    0x42(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x1e0,%rdx
lea    0x4c(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x230,%rdx
lea    0x56(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x280,%rdx
lea    0x60(%rsp),%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
lea    (%rbx,%r14,1),%rdx
add    $0x2d0,%rdx
mov    %r12,%rdi
mov    %rbp,%rsi
call   1090 <sscanf@plt>
add    $0x8,%r14
cmp    $0x50,%r14
jne    1220 <main+0x80>
lea    0xce3(%rip),%rbp
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
mov    %rbp,%rcx
call   10b0 <print_matrix@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x6,%edx
mov    $0x6,%ecx
mov    $0x1,%r8d
call   1060 <housholder@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
mov    %rbp,%rcx
call   10b0 <print_matrix@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x2818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc78(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"E:\\data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"cant open file to read!\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [9 x i8] c"P MATRIX\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca [10240 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 @malloc(i32 800)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %7
%14 = call i64 @malloc(i32 800)
%15 = inttoptr i64 %14 to double*
store double* %15, double** %8
%16 = load double*, double** %8
%17 = call i32 @memset(double* %16, i32 0, i32 800)
%18 = load double*, double** %7
%19 = call i32 @memset(double* %18, i32 0, i32 800)
store i32* null, i32** %9
%20 = 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* %20, i32** %9
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
store i32 0, i32* %10
store i32 0, i32* %10
br label %26
26: ; preds = %57, %25
%27 = load i32, i32* %10
%28 = icmp slt i32 %27, 10
br i1 %28, label %29, label %60
29: ; preds = %26
%30 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%31 = load i32*, i32** %9
%32 = call i32 @fgets(i8* %30, i32 10240, i32* %31)
%33 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %33)
store i32 0, i32* %6
br label %35
35: ; preds = %53, %29
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 10
br i1 %37, label %38, label %56
38: ; preds = %35
%39 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%40 = load i32, i32* %6
%41 = mul nsw i32 %40, 10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = load double*, double** %7
%45 = load i32, i32* %6
%46 = mul nsw i32 10, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %44, i64 %47
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %51)
br label %53
53: ; preds = %38
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %35
56: ; preds = %35
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %26
60: ; preds = %26
%61 = load double*, double** %7
%62 = call i32 @print_matrix(double* %61, i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%63 = load double*, double** %7
%64 = call i32 @housholder(double* %63, i32 10, i32 6, i32 6, i32 1)
%65 = load double*, double** %7
%66 = call i32 @print_matrix(double* %65, i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%67 = load double*, double** %7
%68 = call i32 @free(double* %67)
%69 = load double*, double** %8
%70 = call i32 @free(double* %69)
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [12 x i8] c"E:\\data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [9 x i8] c"P MATRIX\00"
@str = [24 x i8] c"cant open file to read!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10240 x i8]
%4 = tail call i64 @malloc(i32 800)
%5 = inttoptr i64 %4 to double*
%6 = tail call i64 @malloc(i32 800)
%7 = inttoptr i64 %6 to double*
%8 = tail call i32 @memset(double* %7, i32 0, i32 800)
%9 = tail call i32 @memset(double* %5, i32 0, i32 800)
%10 = 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))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 10
%18 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 20
%19 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 30
%20 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 40
%21 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 50
%22 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 60
%23 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 70
%24 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 80
%25 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 90
br label %26
26: ; preds = %15, %26
%27 = phi i64 [ 0, %15 ], [ %50, %26 ]
%28 = call i32 @fgets(i8* %16, i32 10240, i32* %10)
%29 = call i32 @puts(i8* %16)
%30 = getelementptr inbounds double, double* %5, i64 %27
%31 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %30)
%32 = getelementptr inbounds double, double* %30, i64 10
%33 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %32)
%34 = getelementptr inbounds double, double* %30, i64 20
%35 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %34)
%36 = getelementptr inbounds double, double* %30, i64 30
%37 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %36)
%38 = getelementptr inbounds double, double* %30, i64 40
%39 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %38)
%40 = getelementptr inbounds double, double* %30, i64 50
%41 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %40)
%42 = getelementptr inbounds double, double* %30, i64 60
%43 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %42)
%44 = getelementptr inbounds double, double* %30, i64 70
%45 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %44)
%46 = getelementptr inbounds double, double* %30, i64 80
%47 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %46)
%48 = getelementptr inbounds double, double* %30, i64 90
%49 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %48)
%50 = add nuw nsw i64 %27, 1
%51 = icmp eq i64 %50, 10
br i1 %51, label %52, label %26
52: ; preds = %26
%53 = call i32 @print_matrix(double* %5, i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 @housholder(double* %5, i32 10, i32 6, i32 6, i32 1)
%55 = call i32 @print_matrix(double* %5, i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @free(double* %5)
%57 = call i32 @free(double* %7)
ret i32 0
}