#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 scalar_t__ clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ free_matrix(double **, int);
double **generate_random_matrix(int);
double *generate_random_vector(int);
double *malloc(int);
int /*<<< orphan*/ print_vector(double *, int);
int /*<<< orphan*/ printf(char *, ...);
int read_dimension();
double **read_matrix(char *, int);
double *read_vector(char *, int);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ write_vector(char *, double *, int);
int main() {
  int n = 0;
  char filename[256];
  double **matrixA;
  clock_t time;
  double *vectorX;
  double *vectorY;
  int i = 0;
  int j = 0;
  n = read_dimension();
  printf("Dimensio n=%d\n", n);
  printf("Arxiu matriu A? (buit per matriu random) ");
  fgets(filename, 255, stdin);
  if (filename[0] != '\n') {
    if (filename[strlen(filename) - 1] == '\n') {
      filename[strlen(filename) - 1] = '\0';
    }
    printf("\nMatriu de l'arxiu %s\n", filename);
    matrixA = read_matrix(filename, n);
  } else {
    printf("\nMatriu random\n");
    matrixA = generate_random_matrix(n);
  }
  printf("Arxiu vector x? (buit per vector random) ");
  fgets(filename, 255, stdin);
  if (filename[0] != '\n') {
    if (filename[strlen(filename) - 1] == '\n') {
      filename[strlen(filename) - 1] = '\0';
    }
    printf("\nVector de l'arxiu %s\n", filename);
    vectorX = read_vector(filename, n);
  } else {
    printf("\n Vector random\n");
    vectorX = generate_random_vector(n);
  }
  vectorY = malloc(sizeof(double) * n);
  printf("Començant calcul L(Ux) = y...\n");
  time = clock();
  for (i = 0; i < n; i++) {
    vectorY[i] = 0;
    for (j = i; j < n; j++) {
      vectorY[i] += matrixA[i][j] * vectorX[j];
    }
  }
  for (i = 0; i < n; i++) {
    vectorX[i] = vectorY[i];
    for (j = 0; j < i; j++) {
      vectorX[i] += matrixA[i][j] * vectorY[j];
    }
  }
  print_vector(vectorX, n);
  time = clock() - time;
  printf("Calcul finalitzat.\n");
  printf("S'escriura el vector y a l'arxiu output3.txt\n");
  write_vector("output3.txt", vectorX, n);
  printf("n = %d, t = %.6f, t/n = %.6f\n", n, ((float)time) / CLOCKS_PER_SEC,
         (((float)time) / CLOCKS_PER_SEC) / n);
  free_matrix(matrixA, n);
  free(vectorX);
  free(vectorY);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x134(%rbp)
movl   $0x0,-0x138(%rbp)
mov    $0x0,%al
call   1100 <read_dimension@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   10a0 <fgets@plt>
movsbl -0x110(%rbp),%eax
cmp    $0xa,%eax
je     12cb <main+0xeb>
lea    -0x110(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    129b <main+0xbb>
lea    -0x110(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rsi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10f0 <read_matrix@plt>
mov    %rax,-0x118(%rbp)
jmp    12e8 <main+0x108>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <generate_random_matrix@plt>
mov    %rax,-0x118(%rbp)
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   10a0 <fgets@plt>
movsbl -0x110(%rbp),%eax
cmp    $0xa,%eax
je     138b <main+0x1ab>
lea    -0x110(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    135b <main+0x17b>
lea    -0x110(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rsi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10b0 <read_vector@plt>
mov    %rax,-0x128(%rbp)
jmp    13a8 <main+0x1c8>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%edi
call   1090 <generate_random_vector@plt>
mov    %rax,-0x128(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x130(%rbp)
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x120(%rbp)
movl   $0x0,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14a2 <main+0x2c2>
mov    -0x130(%rbp),%rax
movslq -0x134(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x134(%rbp),%eax
mov    %eax,-0x138(%rbp)
mov    -0x138(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1489 <main+0x2a9>
mov    -0x118(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x138(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x128(%rbp),%rax
movslq -0x138(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x130(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    1415 <main+0x235>
jmp    148e <main+0x2ae>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    13e4 <main+0x204>
movl   $0x0,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    157b <main+0x39b>
mov    -0x130(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x128(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x138(%rbp)
mov    -0x138(%rbp),%eax
cmp    -0x134(%rbp),%eax
jge    1562 <main+0x382>
mov    -0x118(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x138(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x130(%rbp),%rax
movslq -0x138(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x128(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    14eb <main+0x30b>
jmp    1567 <main+0x387>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    14ac <main+0x2cc>
mov    -0x128(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10d0 <print_vector@plt>
mov    $0x0,%al
call   1050 <clock@plt>
sub    -0x120(%rbp),%rax
mov    %rax,-0x120(%rbp)
lea    0xb2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x128(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xb48(%rip),%rdi
call   10e0 <write_vector@plt>
mov    -0x8(%rbp),%esi
cvtsi2ssq -0x120(%rbp),%xmm0
ff ff
mov    0x29fc(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2ssq -0x120(%rbp),%xmm1
ff ff
mov    0x29e4(%rip),%rax
divss  (%rax),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xb0c(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    -0x118(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <free_matrix@plt>
mov    -0x128(%rbp),%rdi
call   1030 <free@plt>
mov    -0x130(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
xor    %eax,%eax
call   1110 <read_dimension@plt>
mov    %eax,%r14d
lea    0xdee(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2db8(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10b0 <fgets@plt>
cmpb   $0xa,(%rsp)
jne    125f <main+0x6f>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1090 <generate_random_matrix@plt>
jmp    129e <main+0xae>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    127f <main+0x8f>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xdb3(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1100 <read_matrix@plt>
mov    %rax,%r15
lea    0xda8(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10b0 <fgets@plt>
cmpb   $0xa,(%rsp)
jne    12de <main+0xee>
lea    0xdef(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   10a0 <generate_random_vector@plt>
jmp    131d <main+0x12d>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    12fe <main+0x10e>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xd75(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   10c0 <read_vector@plt>
mov    %rax,%r12
lea    0x0(,%r14,8),%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <clock@plt>
mov    %rax,%r13
test   %r14d,%r14d
jle    14c1 <main+0x2d1>
mov    %r14d,%r9d
cmp    $0x1,%r14d
jne    135f <main+0x16f>
xor    %edx,%edx
jmp    13ee <main+0x1fe>
mov    %r9d,%r8d
and    $0xfffffffe,%r8d
xor    %edx,%edx
mov    %r9,%rsi
mov    %r12,%rdi
xchg   %ax,%ax
lea    0x0(,%rdx,8),%rbp
mov    (%r15,%rdx,8),%rcx
add    %rbp,%rcx
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rcx,%rax,8),%xmm1
mulsd  (%rdi,%rax,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rax
cmp    %rax,%rsi
jne    1390 <main+0x1a0>
movsd  %xmm0,(%rbx,%rdx,8)
mov    %rdx,%rcx
or     $0x1,%rcx
add    (%r15,%rcx,8),%rbp
xorpd  %xmm0,%xmm0
mov    $0x1,%eax
movsd  0x0(%rbp,%rax,8),%xmm1
mulsd  (%rdi,%rax,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rax
cmp    %rax,%rsi
jne    13c0 <main+0x1d0>
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x2,%rdx
add    $0x10,%rdi
add    $0xfffffffffffffffe,%rsi
cmp    %r8,%rdx
jne    1370 <main+0x180>
test   $0x1,%r9b
je     141d <main+0x22d>
mov    (%r15,%rdx,8),%rcx
xorpd  %xmm0,%xmm0
mov    %rdx,%rax
nop
movsd  (%rcx,%rax,8),%xmm1
mulsd  (%r12,%rax,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rax
cmp    %rax,%r9
jne    1400 <main+0x210>
movsd  %xmm0,(%rbx,%rdx,8)
test   %r14d,%r14d
jle    14c1 <main+0x2d1>
xor    %ecx,%ecx
jmp    143d <main+0x24d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %r9,%rcx
je     14c1 <main+0x2d1>
movsd  (%rbx,%rcx,8),%xmm0
movsd  %xmm0,(%r12,%rcx,8)
test   %rcx,%rcx
je     1430 <main+0x240>
mov    (%r15,%rcx,8),%rdx
cmp    $0x1,%rcx
jne    1460 <main+0x270>
xor    %esi,%esi
jmp    14a3 <main+0x2b3>
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
nopl   0x0(%rax)
movsd  (%rdx,%rsi,8),%xmm1
mulsd  (%rbx,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rcx,8)
movsd  0x8(%rdx,%rsi,8),%xmm0
mulsd  0x8(%rbx,%rsi,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r12,%rcx,8)
add    $0x2,%rsi
cmp    %rsi,%rdi
jne    1470 <main+0x280>
test   $0x1,%cl
je     1430 <main+0x240>
movsd  (%rdx,%rsi,8),%xmm1
mulsd  (%rbx,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12,%rcx,8)
jmp    1430 <main+0x240>
mov    %r12,%rdi
mov    %r14d,%esi
call   10e0 <print_vector@plt>
xor    %eax,%eax
call   1060 <clock@plt>
mov    %rax,%rbp
sub    %r13,%rbp
lea    0xc0d(%rip),%rdi
call   1040 <puts@plt>
lea    0xc14(%rip),%rdi
call   1040 <puts@plt>
lea    0xc29(%rip),%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   10f0 <write_vector@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %rbp,%xmm1
mov    0x2ace(%rip),%rax
divss  (%rax),%xmm1
cvtsi2ss %r14d,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xb60(%rip),%rdi
mov    %r14d,%esi
mov    $0x2,%al
call   1080 <printf@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1050 <free_matrix@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Dimensio n=%d\0A\00"
@.str.1 = [42 x i8] c"Arxiu matriu A? (buit per matriu random) \00"
@stdin = global i32 0
@.str.2 = [23 x i8] c"\0AMatriu de l'arxiu %s\0A\00"
@.str.3 = [16 x i8] c"\0AMatriu random\0A\00"
@.str.4 = [42 x i8] c"Arxiu vector x? (buit per vector random) \00"
@.str.5 = [23 x i8] c"\0AVector de l'arxiu %s\0A\00"
@.str.6 = [17 x i8] c"\0A Vector random\0A\00"
@.str.7 = [32 x i8] c"Comen\C3\A7ant calcul L(Ux) = y...\0A\00"
@.str.8 = [20 x i8] c"Calcul finalitzat.\0A\00"
@.str.9 = [46 x i8] c"S'escriura el vector y a l'arxiu output3.txt\0A\00"
@.str.10 = [12 x i8] c"output3.txt\00"
@.str.11 = [30 x i8] c"n = %d, t = %.6f, t/n = %.6f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca double**
%5 = alloca i64
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %8
store i32 0, i32* %9
%10 = call i32 (...) @read_dimension()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %14, i32 255, i32 %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %42
21: ; preds = %0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %36
30: ; preds = %21
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %30, %21
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%40 = load i32, i32* %2
%41 = call double** @read_matrix(i8* %39, i32 %40)
store double** %41, double*** %4
br label %46
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %2
%45 = call double** @generate_random_matrix(i32 %44)
store double** %45, double*** %4
br label %46
46: ; preds = %42, %36
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%49 = load i32, i32* @stdin
%50 = call i32 @fgets(i8* %48, i32 255, i32 %49)
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 10
br i1 %54, label %55, label %76
55: ; preds = %46
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = sub nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 10
br i1 %63, label %64, label %70
64: ; preds = %55
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%66 = call i32 @strlen(i8* %65)
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %68
store i8 0, i8* %69
br label %70
70: ; preds = %64, %55
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %71)
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%74 = load i32, i32* %2
%75 = call double* @read_vector(i8* %73, i32 %74)
store double* %75, double** %6
br label %80
76: ; preds = %46
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32, i32* %2
%79 = call double* @generate_random_vector(i32 %78)
store double* %79, double** %6
br label %80
80: ; preds = %76, %70
%81 = load i32, i32* %2
%82 = sext i32 %81 to i64
%83 = mul i64 8, %82
%84 = trunc i64 %83 to i32
%85 = call double* @malloc(i32 %84)
store double* %85, double** %7
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%87 = call i64 (...) @clock()
store i64 %87, i64* %5
store i32 0, i32* %8
br label %88
88: ; preds = %127, %80
%89 = load i32, i32* %8
%90 = load i32, i32* %2
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %130
92: ; preds = %88
%93 = load double*, double** %7
%94 = load i32, i32* %8
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
store double 0.000000e+00, double* %96
%97 = load i32, i32* %8
store i32 %97, i32* %9
br label %98
98: ; preds = %123, %92
%99 = load i32, i32* %9
%100 = load i32, i32* %2
%101 = icmp slt i32 %99, %100
br i1 %101, label %102, label %126
102: ; preds = %98
%103 = load double**, double*** %4
%104 = load i32, i32* %8
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double*, double** %103, i64 %105
%107 = load double*, double** %106
%108 = load i32, i32* %9
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %107, i64 %109
%111 = load double, double* %110
%112 = load double*, double** %6
%113 = load i32, i32* %9
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
%116 = load double, double* %115
%117 = load double*, double** %7
%118 = load i32, i32* %8
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = call double @llvm.fmuladd.f64(double %111, double %116, double %121)
store double %122, double* %120
br label %123
123: ; preds = %102
%124 = load i32, i32* %9
%125 = add nsw i32 %124, 1
store i32 %125, i32* %9
br label %98
126: ; preds = %98
br label %127
127: ; preds = %126
%128 = load i32, i32* %8
%129 = add nsw i32 %128, 1
store i32 %129, i32* %8
br label %88
130: ; preds = %88
store i32 0, i32* %8
br label %131
131: ; preds = %174, %130
%132 = load i32, i32* %8
%133 = load i32, i32* %2
%134 = icmp slt i32 %132, %133
br i1 %134, label %135, label %177
135: ; preds = %131
%136 = load double*, double** %7
%137 = load i32, i32* %8
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds double, double* %136, i64 %138
%140 = load double, double* %139
%141 = load double*, double** %6
%142 = load i32, i32* %8
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds double, double* %141, i64 %143
store double %140, double* %144
store i32 0, i32* %9
br label %145
145: ; preds = %170, %135
%146 = load i32, i32* %9
%147 = load i32, i32* %8
%148 = icmp slt i32 %146, %147
br i1 %148, label %149, label %173
149: ; preds = %145
%150 = load double**, double*** %4
%151 = load i32, i32* %8
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double*, double** %150, i64 %152
%154 = load double*, double** %153
%155 = load i32, i32* %9
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds double, double* %154, i64 %156
%158 = load double, double* %157
%159 = load double*, double** %7
%160 = load i32, i32* %9
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %159, i64 %161
%163 = load double, double* %162
%164 = load double*, double** %6
%165 = load i32, i32* %8
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double, double* %164, i64 %166
%168 = load double, double* %167
%169 = call double @llvm.fmuladd.f64(double %158, double %163, double %168)
store double %169, double* %167
br label %170
170: ; preds = %149
%171 = load i32, i32* %9
%172 = add nsw i32 %171, 1
store i32 %172, i32* %9
br label %145
173: ; preds = %145
br label %174
174: ; preds = %173
%175 = load i32, i32* %8
%176 = add nsw i32 %175, 1
store i32 %176, i32* %8
br label %131
177: ; preds = %131
%178 = load double*, double** %6
%179 = load i32, i32* %2
%180 = call i32 @print_vector(double* %178, i32 %179)
%181 = call i64 (...) @clock()
%182 = load i64, i64* %5
%183 = sub nsw i64 %181, %182
store i64 %183, i64* %5
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
%186 = load double*, double** %6
%187 = load i32, i32* %2
%188 = call i32 @write_vector(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), double* %186, i32 %187)
%189 = load i32, i32* %2
%190 = load i64, i64* %5
%191 = sitofp i64 %190 to float
%192 = load float, float* @CLOCKS_PER_SEC
%193 = fdiv float %191, %192
%194 = fpext float %193 to double
%195 = load i64, i64* %5
%196 = sitofp i64 %195 to float
%197 = load float, float* @CLOCKS_PER_SEC
%198 = fdiv float %196, %197
%199 = load i32, i32* %2
%200 = sitofp i32 %199 to float
%201 = fdiv float %198, %200
%202 = fpext float %201 to double
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %189, double %194, double %202)
%204 = load double**, double*** %4
%205 = load i32, i32* %2
%206 = call i32 @free_matrix(double** %204, i32 %205)
%207 = load double*, double** %6
%208 = call i32 @free(double* %207)
%209 = load double*, double** %7
%210 = call i32 @free(double* %209)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Dimensio n=%d\0A\00"
@.str.1 = [42 x i8] c"Arxiu matriu A? (buit per matriu random) \00"
@stdin = global i32 0
@.str.2 = [23 x i8] c"\0AMatriu de l'arxiu %s\0A\00"
@.str.4 = [42 x i8] c"Arxiu vector x? (buit per vector random) \00"
@.str.5 = [23 x i8] c"\0AVector de l'arxiu %s\0A\00"
@.str.10 = [12 x i8] c"output3.txt\00"
@.str.11 = [30 x i8] c"n = %d, t = %.6f, t/n = %.6f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@str = [15 x i8] c"\0AMatriu random\00"
@str.12 = [16 x i8] c"\0A Vector random\00"
@str.13 = [31 x i8] c"Comen\C3\A7ant calcul L(Ux) = y...\00"
@str.14 = [19 x i8] c"Calcul finalitzat.\00"
@str.15 = [45 x i8] c"S'escriura el vector y a l'arxiu output3.txt\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @read_dimension()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 255, i32 %6)
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 10
br i1 %9, label %25, label %10
10: ; preds = %0
%11 = call i32 @strlen(i8* %2)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = call i32 @strlen(i8* %2)
%19 = add nsw i32 %18, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %17, %10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%24 = call double** @read_matrix(i8* %2, i32 %3)
br label %28
25: ; preds = %0
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%27 = call double** @generate_random_matrix(i32 %3)
br label %28
28: ; preds = %25, %22
%29 = phi double** [ %24, %22 ], [ %27, %25 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @stdin
%32 = call i32 @fgets(i8* %2, i32 255, i32 %31)
%33 = load i8, i8* %2
%34 = icmp eq i8 %33, 10
br i1 %34, label %50, label %35
35: ; preds = %28
%36 = call i32 @strlen(i8* %2)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 10
br i1 %41, label %42, label %47
42: ; preds = %35
%43 = call i32 @strlen(i8* %2)
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %45
store i8 0, i8* %46
br label %47
47: ; preds = %42, %35
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%49 = call double* @read_vector(i8* %2, i32 %3)
br label %53
50: ; preds = %28
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%52 = call double* @generate_random_vector(i32 %3)
br label %53
53: ; preds = %50, %47
%54 = phi double* [ %49, %47 ], [ %52, %50 ]
%55 = shl i32 %3, 3
%56 = call double* @malloc(i32 %55)
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
%58 = call i64 (...) @clock()
%59 = icmp sgt i32 %3, 0
br i1 %59, label %60, label %166
60: ; preds = %53
%61 = zext i32 %3 to i64
%62 = and i64 %61, 1
%63 = icmp eq i32 %3, 1
br i1 %63, label %66, label %64
64: ; preds = %60
%65 = and i64 %61, 4294967294
br label %87
66: ; preds = %118, %60
%67 = phi i64 [ 0, %60 ], [ %119, %118 ]
%68 = icmp eq i64 %62, 0
br i1 %68, label %84, label %69
69: ; preds = %66
%70 = getelementptr inbounds double, double* %56, i64 %67
%71 = getelementptr inbounds double*, double** %29, i64 %67
%72 = load double*, double** %71
br label %73
73: ; preds = %73, %69
%74 = phi i64 [ %67, %69 ], [ %81, %73 ]
%75 = phi double [ 0.000000e+00, %69 ], [ %80, %73 ]
%76 = getelementptr inbounds double, double* %72, i64 %74
%77 = load double, double* %76
%78 = getelementptr inbounds double, double* %54, i64 %74
%79 = load double, double* %78
%80 = call double @llvm.fmuladd.f64(double %77, double %79, double %75)
%81 = add nuw nsw i64 %74, 1
%82 = icmp eq i64 %81, %61
br i1 %82, label %83, label %73
83: ; preds = %73
store double %80, double* %70
br label %84
84: ; preds = %66, %83
br i1 %59, label %85, label %166
85: ; preds = %84
%86 = zext i32 %3 to i64
br label %122
87: ; preds = %118, %64
%88 = phi i64 [ 0, %64 ], [ %119, %118 ]
%89 = phi i64 [ 0, %64 ], [ %120, %118 ]
%90 = getelementptr inbounds double, double* %56, i64 %88
%91 = getelementptr inbounds double*, double** %29, i64 %88
%92 = load double*, double** %91
br label %93
93: ; preds = %87, %93
%94 = phi i64 [ %88, %87 ], [ %101, %93 ]
%95 = phi double [ 0.000000e+00, %87 ], [ %100, %93 ]
%96 = getelementptr inbounds double, double* %92, i64 %94
%97 = load double, double* %96
%98 = getelementptr inbounds double, double* %54, i64 %94
%99 = load double, double* %98
%100 = call double @llvm.fmuladd.f64(double %97, double %99, double %95)
%101 = add nuw nsw i64 %94, 1
%102 = icmp eq i64 %101, %61
br i1 %102, label %103, label %93
103: ; preds = %93
store double %100, double* %90
%104 = or i64 %88, 1
%105 = getelementptr inbounds double, double* %56, i64 %104
%106 = getelementptr inbounds double*, double** %29, i64 %104
%107 = load double*, double** %106
br label %108
108: ; preds = %108, %103
%109 = phi i64 [ %104, %103 ], [ %116, %108 ]
%110 = phi double [ 0.000000e+00, %103 ], [ %115, %108 ]
%111 = getelementptr inbounds double, double* %107, i64 %109
%112 = load double, double* %111
%113 = getelementptr inbounds double, double* %54, i64 %109
%114 = load double, double* %113
%115 = call double @llvm.fmuladd.f64(double %112, double %114, double %110)
%116 = add nuw nsw i64 %109, 1
%117 = icmp eq i64 %116, %61
br i1 %117, label %118, label %108
118: ; preds = %108
store double %115, double* %105
%119 = add nuw nsw i64 %88, 2
%120 = add i64 %89, 2
%121 = icmp eq i64 %120, %65
br i1 %121, label %66, label %87
122: ; preds = %85, %163
%123 = phi i64 [ 0, %85 ], [ %164, %163 ]
%124 = getelementptr inbounds double, double* %56, i64 %123
%125 = load double, double* %124
%126 = getelementptr inbounds double, double* %54, i64 %123
store double %125, double* %126
%127 = icmp eq i64 %123, 0
br i1 %127, label %163, label %128
128: ; preds = %122
%129 = getelementptr inbounds double*, double** %29, i64 %123
%130 = load double*, double** %129
%131 = and i64 %123, 1
%132 = icmp eq i64 %123, 1
br i1 %132, label %153, label %133
133: ; preds = %128
%134 = and i64 %123, 9223372036854775806
br label %135
135: ; preds = %135, %133
%136 = phi double [ %125, %133 ], [ %149, %135 ]
%137 = phi i64 [ 0, %133 ], [ %150, %135 ]
%138 = phi i64 [ 0, %133 ], [ %151, %135 ]
%139 = getelementptr inbounds double, double* %130, i64 %137
%140 = load double, double* %139
%141 = getelementptr inbounds double, double* %56, i64 %137
%142 = load double, double* %141
%143 = call double @llvm.fmuladd.f64(double %140, double %142, double %136)
store double %143, double* %126
%144 = or i64 %137, 1
%145 = getelementptr inbounds double, double* %130, i64 %144
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %56, i64 %144
%148 = load double, double* %147
%149 = call double @llvm.fmuladd.f64(double %146, double %148, double %143)
store double %149, double* %126
%150 = add nuw nsw i64 %137, 2
%151 = add i64 %138, 2
%152 = icmp eq i64 %151, %134
br i1 %152, label %153, label %135
153: ; preds = %135, %128
%154 = phi double [ %125, %128 ], [ %149, %135 ]
%155 = phi i64 [ 0, %128 ], [ %150, %135 ]
%156 = icmp eq i64 %131, 0
br i1 %156, label %163, label %157
157: ; preds = %153
%158 = getelementptr inbounds double, double* %130, i64 %155
%159 = load double, double* %158
%160 = getelementptr inbounds double, double* %56, i64 %155
%161 = load double, double* %160
%162 = call double @llvm.fmuladd.f64(double %159, double %161, double %154)
store double %162, double* %126
br label %163
163: ; preds = %157, %153, %122
%164 = add nuw nsw i64 %123, 1
%165 = icmp eq i64 %164, %86
br i1 %165, label %166, label %122
166: ; preds = %163, %53, %84
%167 = call i32 @print_vector(double* %54, i32 %3)
%168 = call i64 (...) @clock()
%169 = sub nsw i64 %168, %58
%170 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.14, i64 0, i64 0))
%171 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
%172 = call i32 @write_vector(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), double* %54, i32 %3)
%173 = sitofp i64 %169 to float
%174 = load float, float* @CLOCKS_PER_SEC
%175 = fdiv float %173, %174
%176 = fpext float %175 to double
%177 = sitofp i32 %3 to float
%178 = fdiv float %175, %177
%179 = fpext float %178 to double
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %3, double %176, double %179)
%181 = call i32 @free_matrix(double** %29, i32 %3)
%182 = call i32 @free(double* %54)
%183 = call i32 @free(double* %56)
ret i32 0
}