#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__ RAND_MAX;
int /*<<< orphan*/ exit(int);
double fabs(double);
int /*<<< orphan*/ free(void *);
scalar_t__ generate_empty_matrix(double ***, int);
scalar_t__ malloc(int);
double mysecond();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int main(int argc, char **argv) {
  double *temp;
  unsigned int i, j, iter_start, iter_end;
  unsigned int iterations = 0;
  double error, norm, max = 0.0;
  double **A = 0;
  double *X;
  double *X_old, xi;
  double start, end;
  if (generate_empty_matrix(&A, 128) < 0) {
    printf("generate_empty_matrix() failed...\n");
    exit(-1);
  }
  printf("generate_empty_matrix() done...\n");
  X = (double *)malloc(128 * sizeof(double));
  X_old = (double *)malloc(128 * sizeof(double));
  if (X == NULL || X_old == NULL) {
    printf("X or X_old is NULL...\n");
    exit(-1);
  }
  for (i = 0; i < 128; i++) {
    X[i] = ((double)rand()) / ((double)RAND_MAX) * 10.0;
    X_old[i] = 0.0;
  }
  printf("start calculation...\n");
  iter_start = 0;
  iter_end = 128;
  start = mysecond();
  while (1) {
    iterations++;
    temp = X_old;
    X_old = X;
    X = temp;
    for (i = iter_start; i < iter_end; i++) {
      for (j = 0, xi = 0.0; j < i; j++)
        xi += A[i][j] * X_old[j];
      for (j = i + 1; j < 128; j++)
        xi += A[i][j] * X_old[j];
      X[i] = (A[i][128] - xi) / A[i][i];
    }
    if (iterations % 5000 == 0) {
      norm = 0.0;
      for (i = iter_start; i < iter_end; i++)
        norm += (X_old[i] - X[i]) * (X_old[i] - X[i]);
      norm /= (double)128;
      if (norm < 0.0000001)
        break;
    }
  }
  end = mysecond();
  if (128 < 16) {
    printf("Print the solution...\n");
    for (i = 0; i < 128; i++) {
      for (j = 0; j < 128; j++)
        printf("%8.2f\t", A[i][j]);
      printf("*\t%8.2f\t=\t%8.2f\n", X[i], A[i][128]);
    }
  }
  printf("Check the result...\n");
  for (i = 0; i < 128; i++) {
    error = fabs(X[i] - 1.0f);
    if (max < error)
      max = error;
    if (error > 0.01f) {
      printf("Result is on position %d wrong (%f != 1.0)\n", i, X[i]);
      exit(1);
    }
  }
  printf("maximal error is %f\n", max);
  printf("\nmatrix size: %d x %d\n", 128, 128);
  printf("number of iterations: %d\n", iterations);
  printf("calculation time: %lf s\n", end - start);
  free((void *)X_old);
  free((void *)X);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x80,%esi
call   1060 <generate_empty_matrix@plt>
cmp    $0x0,%rax
jge    11d0 <main+0x60>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1210 <main+0xa0>
cmpq   $0x0,-0x60(%rbp)
jne    1228 <main+0xb8>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x80,-0x1c(%rbp)
jae    128d <main+0x11d>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2d99(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdc0(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%ecx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    122f <main+0xbf>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x80,-0x28(%rbp)
mov    $0x0,%al
call   1040 <mysecond@plt>
movsd  %xmm0,-0x70(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    13dc <main+0x26c>
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1342 <main+0x1d2>
mov    -0x50(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12f7 <main+0x187>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x80,-0x20(%rbp)
jae    1397 <main+0x227>
mov    -0x50(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    134b <main+0x1db>
mov    -0x50(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movsd  0x400(%rax),%xmm0
subsd  -0x68(%rbp),%xmm0
mov    -0x50(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x1c(%rbp),%ecx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12dc <main+0x16c>
mov    -0x2c(%rbp),%eax
mov    $0x1388,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    148e <main+0x31e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    145b <main+0x2eb>
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
subsd  (%rax,%rcx,8),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13ff <main+0x28f>
movsd  -0x40(%rbp),%xmm0
movsd  0xba0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xb87(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1489 <main+0x319>
jmp    1493 <main+0x323>
jmp    148e <main+0x31e>
jmp    12b5 <main+0x145>
mov    $0x0,%al
call   1040 <mysecond@plt>
movsd  %xmm0,-0x78(%rbp)
lea    0xc0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x80,-0x1c(%rbp)
jae    1558 <main+0x3e8>
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xb3b(%rip),%xmm1
subsd  %xmm1,%xmm0
movaps 0xb50(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1507 <main+0x397>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xb04(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1545 <main+0x3d5>
mov    -0x1c(%rbp),%esi
mov    -0x58(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xb92(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    154a <main+0x3da>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14b4 <main+0x344>
movsd  -0x48(%rbp),%xmm0
lea    0xb8e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xb95(%rip),%rdi
mov    $0x80,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x78(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
lea    0xb96(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0x80,%esi
call   1070 <generate_empty_matrix@plt>
test   %rax,%rax
js     1564 <main+0x3e4>
lea    0xf1b(%rip),%rdi
call   1050 <puts@plt>
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    $0x400,%edi
call   1080 <malloc@plt>
test   %r12,%r12
je     156d <main+0x3ed>
mov    %rax,%r15
test   %rax,%rax
je     156d <main+0x3ed>
mov    0x2e00(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r14),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xded(%rip),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
movq   $0x0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    11f0 <main+0x70>
lea    0xeb6(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <mysecond@plt>
movsd  %xmm0,0x10(%rsp)
mov    (%rsp),%r8
movsd  0xdb2(%rip),%xmm0
movsd  0xdb2(%rip),%xmm1
mov    %r8,%r9
jmp    1293 <main+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14d
imul   $0x3afb7e91,%r14d,%eax
ror    $0x3,%eax
cmp    $0xd1b71,%eax
jbe    13c0 <main+0x240>
mov    (%rsp),%r9
mov    %r15,%r12
mov    %rbx,%r15
mov    %r12,%rbx
xor    %r10d,%r10d
xor    %edx,%edx
jmp    12ca <main+0x14a>
nopl   (%rax)
mov    (%r8,%rdx,8),%rcx
movsd  0x400(%rcx),%xmm3
subsd  %xmm2,%xmm3
divsd  (%rcx,%rdx,8),%xmm3
movsd  %xmm3,(%r15,%rdx,8)
add    $0x1,%r10
mov    %rax,%rdx
cmp    $0x80,%rax
je     1270 <main+0xf0>
test   %rdx,%rdx
je     12f0 <main+0x170>
mov    (%r9,%rdx,8),%rax
lea    -0x1(%rdx),%rcx
mov    %edx,%edi
and    $0x3,%edi
cmp    $0x3,%rcx
jae    1300 <main+0x180>
xorpd  %xmm2,%xmm2
xor    %ecx,%ecx
jmp    1357 <main+0x1d7>
nopw   0x0(%rax,%rax,1)
xorpd  %xmm2,%xmm2
mov    $0x1,%eax
jmp    1395 <main+0x215>
xchg   %ax,%ax
mov    %rdx,%rsi
and    $0xfffffffffffffffc,%rsi
xorpd  %xmm2,%xmm2
xor    %ecx,%ecx
nopl   (%rax)
movsd  (%rax,%rcx,8),%xmm3
movsd  0x8(%rax,%rcx,8),%xmm4
mulsd  (%rbx,%rcx,8),%xmm3
mulsd  0x8(%rbx,%rcx,8),%xmm4
addsd  %xmm2,%xmm3
movsd  0x10(%rax,%rcx,8),%xmm5
mulsd  0x10(%rbx,%rcx,8),%xmm5
addsd  %xmm3,%xmm4
movsd  0x18(%rax,%rcx,8),%xmm2
mulsd  0x18(%rbx,%rcx,8),%xmm2
addsd  %xmm4,%xmm5
addsd  %xmm5,%xmm2
add    $0x4,%rcx
cmp    %rcx,%rsi
jne    1310 <main+0x190>
test   %rdi,%rdi
je     1387 <main+0x207>
lea    (%rbx,%rcx,8),%rsi
lea    (%rax,%rcx,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movsd  (%rax,%rcx,8),%xmm3
mulsd  (%rsi,%rcx,8),%xmm3
addsd  %xmm3,%xmm2
add    $0x1,%rcx
cmp    %rcx,%rdi
jne    1370 <main+0x1f0>
lea    0x1(%rdx),%rax
cmp    $0x7e,%rdx
ja     12a0 <main+0x120>
mov    (%r9,%rdx,8),%rcx
mov    %r10,%rsi
nopl   0x0(%rax)
movsd  0x8(%rcx,%rsi,8),%xmm3
mulsd  0x8(%rbx,%rsi,8),%xmm3
addsd  %xmm3,%xmm2
add    $0x1,%rsi
cmp    $0x7f,%rsi
jne    13a0 <main+0x220>
jmp    12a0 <main+0x120>
nop
xorpd  %xmm2,%xmm2
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm3
movsd  0x8(%rbx,%rax,8),%xmm4
subsd  (%r15,%rax,8),%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm2,%xmm3
subsd  0x8(%r15,%rax,8),%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm3,%xmm4
movsd  0x10(%rbx,%rax,8),%xmm3
subsd  0x10(%r15,%rax,8),%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm4,%xmm3
movsd  0x18(%rbx,%rax,8),%xmm2
subsd  0x18(%r15,%rax,8),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
add    $0x4,%rax
cmp    $0x80,%rax
jne    13d0 <main+0x250>
mulsd  %xmm0,%xmm2
ucomisd %xmm2,%xmm1
jbe    1289 <main+0x109>
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <mysecond@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xcad(%rip),%rdi
call   1050 <puts@plt>
xorpd  %xmm5,%xmm5
movsd  0xbb4(%rip),%xmm2
movapd 0xbc4(%rip),%xmm3
movsd  0xbac(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r15,%r12,8),%xmm0
movapd %xmm0,%xmm6
addsd  %xmm2,%xmm6
andpd  %xmm3,%xmm6
ucomisd %xmm4,%xmm6
ja     1549 <main+0x3c9>
movsd  0x8(%r15,%r12,8),%xmm0
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
andpd  %xmm3,%xmm1
ucomisd %xmm4,%xmm1
ja     1545 <main+0x3c5>
maxsd  %xmm5,%xmm6
maxsd  %xmm6,%xmm1
add    $0x2,%r12
movapd %xmm1,%xmm5
cmp    $0x80,%r12
jne    1480 <main+0x300>
lea    0xb93(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xb96(%rip),%rdi
mov    $0x80,%esi
mov    $0x80,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb95(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xb92(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
add    $0x1,%r12
lea    0xaf0(%rip),%rdi
mov    %r12d,%esi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xbbf(%rip),%rdi
jmp    1574 <main+0x3f4>
lea    0xba0(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"generate_empty_matrix() failed...\0A\00"
@.str.1 = [33 x i8] c"generate_empty_matrix() done...\0A\00"
@.str.2 = [23 x i8] c"X or X_old is NULL...\0A\00"
@RAND_MAX = global i64 0
@.str.3 = [22 x i8] c"start calculation...\0A\00"
@.str.4 = [21 x i8] c"Check the result...\0A\00"
@.str.5 = [44 x i8] c"Result is on position %d wrong (%f != 1.0)\0A\00"
@.str.6 = [21 x i8] c"maximal error is %f\0A\00"
@.str.7 = [23 x i8] c"\0Amatrix size: %d x %d\0A\00"
@.str.8 = [26 x i8] c"number of iterations: %d\0A\00"
@.str.9 = [25 x i8] c"calculation time: %lf s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double**
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store double 0.000000e+00, double* %14
store double** null, double*** %15
%21 = call i64 @generate_empty_matrix(double*** %15, i32 128)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%28 = call i64 @malloc(i32 1024)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %16
%30 = call i64 @malloc(i32 1024)
%31 = inttoptr i64 %30 to double*
store double* %31, double** %17
%32 = load double*, double** %16
%33 = icmp eq double* %32, null
br i1 %33, label %37, label %34
34: ; preds = %26
%35 = load double*, double** %17
%36 = icmp eq double* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34, %26
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %34
store i32 0, i32* %7
br label %41
41: ; preds = %59, %40
%42 = load i32, i32* %7
%43 = icmp ult i32 %42, 128
br i1 %43, label %44, label %62
44: ; preds = %41
%45 = call i64 (...) @rand()
%46 = sitofp i64 %45 to double
%47 = load i64, i64* @RAND_MAX
%48 = sitofp i64 %47 to double
%49 = fdiv double %46, %48
%50 = fmul double %49, 1.000000e+01
%51 = load double*, double** %16
%52 = load i32, i32* %7
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
%55 = load double*, double** %17
%56 = load i32, i32* %7
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
store double 0.000000e+00, double* %58
br label %59
59: ; preds = %44
%60 = load i32, i32* %7
%61 = add i32 %60, 1
store i32 %61, i32* %7
br label %41
62: ; preds = %41
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
store i32 128, i32* %10
%64 = call double (...) @mysecond()
store double %64, double* %19
br label %65
65: ; preds = %62, %199
%66 = load i32, i32* %11
%67 = add i32 %66, 1
store i32 %67, i32* %11
%68 = load double*, double** %17
store double* %68, double** %6
%69 = load double*, double** %16
store double* %69, double** %17
%70 = load double*, double** %6
store double* %70, double** %16
%71 = load i32, i32* %9
store i32 %71, i32* %7
br label %72
72: ; preds = %151, %65
%73 = load i32, i32* %7
%74 = load i32, i32* %10
%75 = icmp ult i32 %73, %74
br i1 %75, label %76, label %154
76: ; preds = %72
store i32 0, i32* %8
store double 0.000000e+00, double* %18
br label %77
77: ; preds = %98, %76
%78 = load i32, i32* %8
%79 = load i32, i32* %7
%80 = icmp ult i32 %78, %79
br i1 %80, label %81, label %101
81: ; preds = %77
%82 = load double**, double*** %15
%83 = load i32, i32* %7
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds double*, double** %82, i64 %84
%86 = load double*, double** %85
%87 = load i32, i32* %8
%88 = zext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
%90 = load double, double* %89
%91 = load double*, double** %17
%92 = load i32, i32* %8
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = load double, double* %18
%97 = call double @llvm.fmuladd.f64(double %90, double %95, double %96)
store double %97, double* %18
br label %98
98: ; preds = %81
%99 = load i32, i32* %8
%100 = add i32 %99, 1
store i32 %100, i32* %8
br label %77
101: ; preds = %77
%102 = load i32, i32* %7
%103 = add i32 %102, 1
store i32 %103, i32* %8
br label %104
104: ; preds = %124, %101
%105 = load i32, i32* %8
%106 = icmp ult i32 %105, 128
br i1 %106, label %107, label %127
107: ; preds = %104
%108 = load double**, double*** %15
%109 = load i32, i32* %7
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds double*, double** %108, i64 %110
%112 = load double*, double** %111
%113 = load i32, i32* %8
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
%116 = load double, double* %115
%117 = load double*, double** %17
%118 = load i32, i32* %8
%119 = zext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = load double, double* %18
%123 = call double @llvm.fmuladd.f64(double %116, double %121, double %122)
store double %123, double* %18
br label %124
124: ; preds = %107
%125 = load i32, i32* %8
%126 = add i32 %125, 1
store i32 %126, i32* %8
br label %104
127: ; preds = %104
%128 = load double**, double*** %15
%129 = load i32, i32* %7
%130 = zext i32 %129 to i64
%131 = getelementptr inbounds double*, double** %128, i64 %130
%132 = load double*, double** %131
%133 = getelementptr inbounds double, double* %132, i64 128
%134 = load double, double* %133
%135 = load double, double* %18
%136 = fsub double %134, %135
%137 = load double**, double*** %15
%138 = load i32, i32* %7
%139 = zext i32 %138 to i64
%140 = getelementptr inbounds double*, double** %137, i64 %139
%141 = load double*, double** %140
%142 = load i32, i32* %7
%143 = zext i32 %142 to i64
%144 = getelementptr inbounds double, double* %141, i64 %143
%145 = load double, double* %144
%146 = fdiv double %136, %145
%147 = load double*, double** %16
%148 = load i32, i32* %7
%149 = zext i32 %148 to i64
%150 = getelementptr inbounds double, double* %147, i64 %149
store double %146, double* %150
br label %151
151: ; preds = %127
%152 = load i32, i32* %7
%153 = add i32 %152, 1
store i32 %153, i32* %7
br label %72
154: ; preds = %72
%155 = load i32, i32* %11
%156 = urem i32 %155, 5000
%157 = icmp eq i32 %156, 0
br i1 %157, label %158, label %199
158: ; preds = %154
store double 0.000000e+00, double* %13
%159 = load i32, i32* %9
store i32 %159, i32* %7
br label %160
160: ; preds = %189, %158
%161 = load i32, i32* %7
%162 = load i32, i32* %10
%163 = icmp ult i32 %161, %162
br i1 %163, label %164, label %192
164: ; preds = %160
%165 = load double*, double** %17
%166 = load i32, i32* %7
%167 = zext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
%169 = load double, double* %168
%170 = load double*, double** %16
%171 = load i32, i32* %7
%172 = zext i32 %171 to i64
%173 = getelementptr inbounds double, double* %170, i64 %172
%174 = load double, double* %173
%175 = fsub double %169, %174
%176 = load double*, double** %17
%177 = load i32, i32* %7
%178 = zext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load double*, double** %16
%182 = load i32, i32* %7
%183 = zext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
%186 = fsub double %180, %185
%187 = load double, double* %13
%188 = call double @llvm.fmuladd.f64(double %175, double %186, double %187)
store double %188, double* %13
br label %189
189: ; preds = %164
%190 = load i32, i32* %7
%191 = add i32 %190, 1
store i32 %191, i32* %7
br label %160
192: ; preds = %160
%193 = load double, double* %13
%194 = fdiv double %193, 1.280000e+02
store double %194, double* %13
%195 = load double, double* %13
%196 = fcmp olt double %195, 0x3E7AD7F29ABCAF48
br i1 %196, label %197, label %198
197: ; preds = %192
br label %200
198: ; preds = %192
br label %199
199: ; preds = %198, %154
br label %65
200: ; preds = %197
%201 = call double (...) @mysecond()
store double %201, double* %20
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %203
203: ; preds = %232, %200
%204 = load i32, i32* %7
%205 = icmp ult i32 %204, 128
br i1 %205, label %206, label %235
206: ; preds = %203
%207 = load double*, double** %16
%208 = load i32, i32* %7
%209 = zext i32 %208 to i64
%210 = getelementptr inbounds double, double* %207, i64 %209
%211 = load double, double* %210
%212 = fsub double %211, 1.000000e+00
%213 = call double @llvm.fabs.f64(double %212)
store double %213, double* %12
%214 = load double, double* %14
%215 = load double, double* %12
%216 = fcmp olt double %214, %215
br i1 %216, label %217, label %219
217: ; preds = %206
%218 = load double, double* %12
store double %218, double* %14
br label %219
219: ; preds = %217, %206
%220 = load double, double* %12
%221 = fcmp ogt double %220, 0x3F847AE140000000
br i1 %221, label %222, label %231
222: ; preds = %219
%223 = load i32, i32* %7
%224 = load double*, double** %16
%225 = load i32, i32* %7
%226 = zext i32 %225 to i64
%227 = getelementptr inbounds double, double* %224, i64 %226
%228 = load double, double* %227
%229 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %223, double %228)
%230 = call i32 @exit(i32 1)
unreachable
231: ; preds = %219
br label %232
232: ; preds = %231
%233 = load i32, i32* %7
%234 = add i32 %233, 1
store i32 %234, i32* %7
br label %203
235: ; preds = %203
%236 = load double, double* %14
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %236)
%238 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 128, i32 128)
%239 = load i32, i32* %11
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %239)
%241 = load double, double* %20
%242 = load double, double* %19
%243 = fsub double %241, %242
%244 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), double %243)
%245 = load double*, double** %17
%246 = bitcast double* %245 to i8*
%247 = call i32 @free(i8* %246)
%248 = load double*, double** %16
%249 = bitcast double* %248 to i8*
%250 = call i32 @free(i8* %249)
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str.5 = [44 x i8] c"Result is on position %d wrong (%f != 1.0)\0A\00"
@.str.6 = [21 x i8] c"maximal error is %f\0A\00"
@.str.7 = [23 x i8] c"\0Amatrix size: %d x %d\0A\00"
@.str.8 = [26 x i8] c"number of iterations: %d\0A\00"
@.str.9 = [25 x i8] c"calculation time: %lf s\0A\00"
@str = [32 x i8] c"generate_empty_matrix() done...\00"
@str.10 = [21 x i8] c"start calculation...\00"
@str.11 = [20 x i8] c"Check the result...\00"
@str.12 = [22 x i8] c"X or X_old is NULL...\00"
@str.13 = [34 x i8] c"generate_empty_matrix() failed...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double**
%4 = bitcast double*** %3 to i8*
store double** null, double*** %3
%5 = call i64 @generate_empty_matrix(double*** %3, i32 128)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = call i64 @malloc(i32 1024)
%13 = inttoptr i64 %12 to double*
%14 = call i64 @malloc(i32 1024)
%15 = inttoptr i64 %14 to double*
%16 = icmp eq i64 %12, 0
%17 = icmp eq i64 %14, 0
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %10, %22
%23 = phi i64 [ %32, %22 ], [ 0, %10 ]
%24 = call i64 (...) @rand()
%25 = sitofp i64 %24 to double
%26 = load i64, i64* @RAND_MAX
%27 = sitofp i64 %26 to double
%28 = fdiv double %25, %27
%29 = fmul double %28, 1.000000e+01
%30 = getelementptr inbounds double, double* %13, i64 %23
store double %29, double* %30
%31 = getelementptr inbounds double, double* %15, i64 %23
store double 0.000000e+00, double* %31
%32 = add nuw nsw i64 %23, 1
%33 = icmp eq i64 %32, 128
br i1 %33, label %34, label %22
34: ; preds = %22
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0))
%36 = call double (...) @mysecond()
%37 = load double**, double*** %3
br label %38
38: ; preds = %174, %34
%39 = phi double** [ %37, %34 ], [ %175, %174 ]
%40 = phi i32 [ 0, %34 ], [ %136, %174 ]
%41 = phi double* [ %13, %34 ], [ %42, %174 ]
%42 = phi double* [ %15, %34 ], [ %41, %174 ]
br label %43
43: ; preds = %38, %121
%44 = phi i64 [ 0, %38 ], [ %122, %121 ]
%45 = phi i64 [ 1, %38 ], [ %133, %121 ]
%46 = icmp eq i64 %44, 0
br i1 %46, label %106, label %47
47: ; preds = %43
%48 = getelementptr inbounds double*, double** %39, i64 %44
%49 = load double*, double** %48
%50 = add i64 %44, -1
%51 = and i64 %44, 3
%52 = icmp ult i64 %50, 3
br i1 %52, label %85, label %53
53: ; preds = %47
%54 = and i64 %44, -4
br label %55
55: ; preds = %55, %53
%56 = phi i64 [ 0, %53 ], [ %82, %55 ]
%57 = phi double [ 0.000000e+00, %53 ], [ %81, %55 ]
%58 = phi i64 [ 0, %53 ], [ %83, %55 ]
%59 = getelementptr inbounds double, double* %49, i64 %56
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %41, i64 %56
%62 = load double, double* %61
%63 = call double @llvm.fmuladd.f64(double %60, double %62, double %57)
%64 = or i64 %56, 1
%65 = getelementptr inbounds double, double* %49, i64 %64
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %41, i64 %64
%68 = load double, double* %67
%69 = call double @llvm.fmuladd.f64(double %66, double %68, double %63)
%70 = or i64 %56, 2
%71 = getelementptr inbounds double, double* %49, i64 %70
%72 = load double, double* %71
%73 = getelementptr inbounds double, double* %41, i64 %70
%74 = load double, double* %73
%75 = call double @llvm.fmuladd.f64(double %72, double %74, double %69)
%76 = or i64 %56, 3
%77 = getelementptr inbounds double, double* %49, i64 %76
%78 = load double, double* %77
%79 = getelementptr inbounds double, double* %41, i64 %76
%80 = load double, double* %79
%81 = call double @llvm.fmuladd.f64(double %78, double %80, double %75)
%82 = add nuw nsw i64 %56, 4
%83 = add i64 %58, 4
%84 = icmp eq i64 %83, %54
br i1 %84, label %85, label %55
85: ; preds = %55, %47
%86 = phi double [ undef, %47 ], [ %81, %55 ]
%87 = phi i64 [ 0, %47 ], [ %82, %55 ]
%88 = phi double [ 0.000000e+00, %47 ], [ %81, %55 ]
%89 = icmp eq i64 %51, 0
br i1 %89, label %102, label %90
90: ; preds = %85, %90
%91 = phi i64 [ %99, %90 ], [ %87, %85 ]
%92 = phi double [ %98, %90 ], [ %88, %85 ]
%93 = phi i64 [ %100, %90 ], [ 0, %85 ]
%94 = getelementptr inbounds double, double* %49, i64 %91
%95 = load double, double* %94
%96 = getelementptr inbounds double, double* %41, i64 %91
%97 = load double, double* %96
%98 = call double @llvm.fmuladd.f64(double %95, double %97, double %92)
%99 = add nuw nsw i64 %91, 1
%100 = add i64 %93, 1
%101 = icmp eq i64 %100, %51
br i1 %101, label %102, label %90
102: ; preds = %90, %85
%103 = phi double [ %86, %85 ], [ %98, %90 ]
%104 = add nuw nsw i64 %44, 1
%105 = icmp ult i64 %44, 127
br i1 %105, label %106, label %121
106: ; preds = %43, %102
%107 = phi i64 [ %104, %102 ], [ 1, %43 ]
%108 = phi double [ %103, %102 ], [ 0.000000e+00, %43 ]
%109 = getelementptr inbounds double*, double** %39, i64 %44
%110 = load double*, double** %109
br label %111
111: ; preds = %106, %111
%112 = phi i64 [ %45, %106 ], [ %119, %111 ]
%113 = phi double [ %108, %106 ], [ %118, %111 ]
%114 = getelementptr inbounds double, double* %110, i64 %112
%115 = load double, double* %114
%116 = getelementptr inbounds double, double* %41, i64 %112
%117 = load double, double* %116
%118 = call double @llvm.fmuladd.f64(double %115, double %117, double %113)
%119 = add nuw nsw i64 %112, 1
%120 = icmp eq i64 %119, 128
br i1 %120, label %121, label %111
121: ; preds = %111, %102
%122 = phi i64 [ %104, %102 ], [ %107, %111 ]
%123 = phi double [ %103, %102 ], [ %118, %111 ]
%124 = getelementptr inbounds double*, double** %37, i64 %44
%125 = load double*, double** %124
%126 = getelementptr inbounds double, double* %125, i64 128
%127 = load double, double* %126
%128 = fsub double %127, %123
%129 = getelementptr inbounds double, double* %125, i64 %44
%130 = load double, double* %129
%131 = fdiv double %128, %130
%132 = getelementptr inbounds double, double* %42, i64 %44
store double %131, double* %132
%133 = add nuw nsw i64 %45, 1
%134 = icmp eq i64 %122, 128
br i1 %134, label %135, label %43
135: ; preds = %121
%136 = add i32 %40, 1
%137 = urem i32 %136, 5000
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %174
139: ; preds = %135, %139
%140 = phi i64 [ %169, %139 ], [ 0, %135 ]
%141 = phi double [ %168, %139 ], [ 0.000000e+00, %135 ]
%142 = getelementptr inbounds double, double* %41, i64 %140
%143 = load double, double* %142
%144 = getelementptr inbounds double, double* %42, i64 %140
%145 = load double, double* %144
%146 = fsub double %143, %145
%147 = call double @llvm.fmuladd.f64(double %146, double %146, double %141)
%148 = or i64 %140, 1
%149 = getelementptr inbounds double, double* %41, i64 %148
%150 = load double, double* %149
%151 = getelementptr inbounds double, double* %42, i64 %148
%152 = load double, double* %151
%153 = fsub double %150, %152
%154 = call double @llvm.fmuladd.f64(double %153, double %153, double %147)
%155 = or i64 %140, 2
%156 = getelementptr inbounds double, double* %41, i64 %155
%157 = load double, double* %156
%158 = getelementptr inbounds double, double* %42, i64 %155
%159 = load double, double* %158
%160 = fsub double %157, %159
%161 = call double @llvm.fmuladd.f64(double %160, double %160, double %154)
%162 = or i64 %140, 3
%163 = getelementptr inbounds double, double* %41, i64 %162
%164 = load double, double* %163
%165 = getelementptr inbounds double, double* %42, i64 %162
%166 = load double, double* %165
%167 = fsub double %164, %166
%168 = call double @llvm.fmuladd.f64(double %167, double %167, double %161)
%169 = add nuw nsw i64 %140, 4
%170 = icmp eq i64 %169, 128
br i1 %170, label %171, label %139
171: ; preds = %139
%172 = fmul double %168, 7.812500e-03
%173 = fcmp olt double %172, 0x3E7AD7F29ABCAF48
br i1 %173, label %176, label %174
174: ; preds = %171, %135
%175 = load double**, double*** %3
br label %38
176: ; preds = %171
%177 = call double (...) @mysecond()
%178 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
br label %179
179: ; preds = %202, %176
%180 = phi i64 [ 0, %176 ], [ %205, %202 ]
%181 = phi double [ 0.000000e+00, %176 ], [ %204, %202 ]
%182 = getelementptr inbounds double, double* %42, i64 %180
%183 = load double, double* %182
%184 = fadd double %183, -1.000000e+00
%185 = call double @llvm.fabs.f64(double %184)
%186 = fcmp ogt double %185, 0x3F847AE140000000
br i1 %186, label %187, label %193
187: ; preds = %193, %179
%188 = phi i64 [ %180, %179 ], [ %196, %193 ]
%189 = phi double [ %183, %179 ], [ %198, %193 ]
%190 = trunc i64 %188 to i32
%191 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %190, double %189)
%192 = call i32 @exit(i32 1)
unreachable
193: ; preds = %179
%194 = fcmp olt double %181, %185
%195 = select i1 %194, double %185, double %181
%196 = or i64 %180, 1
%197 = getelementptr inbounds double, double* %42, i64 %196
%198 = load double, double* %197
%199 = fadd double %198, -1.000000e+00
%200 = call double @llvm.fabs.f64(double %199)
%201 = fcmp ogt double %200, 0x3F847AE140000000
br i1 %201, label %187, label %202
202: ; preds = %193
%203 = fcmp olt double %195, %200
%204 = select i1 %203, double %200, double %195
%205 = add nuw nsw i64 %180, 2
%206 = icmp eq i64 %205, 128
br i1 %206, label %207, label %179
207: ; preds = %202
%208 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %204)
%209 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 128, i32 128)
%210 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %136)
%211 = fsub double %177, %36
%212 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), double %211)
%213 = bitcast double* %41 to i8*
%214 = call i32 @free(i8* %213)
%215 = bitcast double* %42 to i8*
%216 = call i32 @free(i8* %215)
ret i32 0
}