#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 */
int check_convergence(double **, double *, double *);
int /*<<< orphan*/ print_matrix(double **);
int /*<<< orphan*/ print_vector(double *, int);
int /*<<< orphan*/ printf(char *, ...);
void fail() {
  double A[3][3] = {{5.0, 6.0, 2.0}, {6.0, 4.0, 4.0}, {1.0, 1.0, 6.0}};
  double L[3][3] = {{5.0, 0.0, 0.0}, {6.0, 4.0, 0.0}, {1.0, 1.0, 6.0}};
  double L1[3][3] = {{1.0 / 5.0, 0.0, 0.0},
                     {-3.0 / 10.0, 1.0 / 4.0, 0.0},
                     {1.0 / 60.0, -1.0 / 24.0, 1.0 / 6.0}};
  double U[3][3] = {{0.0, 6.0, 2.0}, {0.0, 0.0, 4.0}, {0.0, 0.0, 0.0}};
  double b[3] = {2.0, 7.0, 6.0};
  double x[3] = {0.0};
  double temp1[3] = {0};
  double temp2[3] = {0};
  double temp3[3] = {0};
  double b_check[3] = {0};
  int check = 0;
  int count = 0;
  int i, j;
  printf("\n----------Question3_Fail_Cases : ----------\n\n");
  printf("Ax=b case provided for the first question\n");
  printf("is already failed for Jacobi Method, therefore\n");
  printf("we will only provide fail case for Gauss-Seidel Method :\n");
  printf("Fail case for Gauss-Seidel Method : \n\n");
  while ((check == 0) && (count < 250)) {
    for (i = 0; i < 3; i++) {
      temp1[i] = 0.0;
      temp2[i] = 0.0;
      temp3[i] = 0.0;
    }
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        temp1[i] = temp1[i] + U[i][j] * x[j];
      }
      temp2[i] = b[i] - temp1[i];
    }
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
        temp3[i] = temp3[i] + L1[i][j] * temp2[j];
      }
      x[i] = temp3[i];
    }
    count = count + 1;
    check = check_convergence(A, x, b);
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      b_check[i] = b_check[i] + A[i][j] * x[j];
    }
  }
  if (count == 250) {
    printf(
        "Gauss-Seidel is failed! (Maximum number of iterations is reached)\n");
    printf("\nMatrix A : \n");
    print_matrix(A);
  } else {
    printf("Gauss-Seidel Method is converged in %d iterations.\n", count);
    printf("Solution,  x: \n");
    print_vector(x, 3);
  }
  printf("\n----------EndOfFailCase----------\n\n");
}


x86 assembly (clang, -O0):
<fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    -0x50(%rbp),%rdi
lea    0xeea(%rip),%rsi
mov    $0x48,%edx
call   1060 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe45(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe73(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe2e(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xe3e(%rip),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  0xe0e(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xdde(%rip),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  0xdc6(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1050 <memset@plt>
movsd  0xd9b(%rip),%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
movsd  0xd83(%rip),%xmm0
movsd  %xmm0,-0x130(%rbp)
ff
movsd  0xd6b(%rip),%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
mov    0xe0c(%rip),%rax
mov    %rax,-0x160(%rbp)
mov    0xe06(%rip),%rax
mov    %rax,-0x158(%rbp)
mov    0xe00(%rip),%rax
mov    %rax,-0x150(%rbp)
lea    -0x180(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x1e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
movl   $0x0,-0x204(%rbp)
movl   $0x0,-0x208(%rbp)
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x204(%rbp)
mov    %al,-0x211(%rbp)
jne    13a8 <fail+0x248>
cmpl   $0xfa,-0x208(%rbp)
setl   %al
mov    %al,-0x211(%rbp)
mov    -0x211(%rbp),%al
test   $0x1,%al
jne    13bb <fail+0x25b>
jmp    15fe <fail+0x49e>
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3,-0x20c(%rbp)
jge    141f <fail+0x2bf>
movslq -0x20c(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1a0(%rbp,%rax,8)
ff ff
movslq -0x20c(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1c0(%rbp,%rax,8)
ff ff
movslq -0x20c(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x1e0(%rbp,%rax,8)
ff ff
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    13c5 <fail+0x265>
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3,-0x20c(%rbp)
jge    14fe <fail+0x39e>
movl   $0x0,-0x210(%rbp)
cmpl   $0x3,-0x210(%rbp)
jge    14ba <fail+0x35a>
movslq -0x20c(%rbp),%rax
movsd  -0x1a0(%rbp,%rax,8),%xmm1
ff ff
movslq -0x20c(%rbp),%rcx
lea    -0x140(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x210(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x210(%rbp),%rax
movsd  -0x180(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x20c(%rbp),%rax
movsd  %xmm0,-0x1a0(%rbp,%rax,8)
ff ff
mov    -0x210(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x210(%rbp)
jmp    1440 <fail+0x2e0>
movslq -0x20c(%rbp),%rax
movsd  -0x160(%rbp,%rax,8),%xmm0
ff ff
movslq -0x20c(%rbp),%rax
subsd  -0x1a0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x20c(%rbp),%rax
movsd  %xmm0,-0x1c0(%rbp,%rax,8)
ff ff
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    1429 <fail+0x2c9>
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3,-0x20c(%rbp)
jge    15cd <fail+0x46d>
movl   $0x0,-0x210(%rbp)
cmpl   $0x3,-0x210(%rbp)
jge    1599 <fail+0x439>
movslq -0x20c(%rbp),%rax
movsd  -0x1e0(%rbp,%rax,8),%xmm1
ff ff
movslq -0x20c(%rbp),%rcx
lea    -0xf0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x210(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x210(%rbp),%rax
movsd  -0x1c0(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x20c(%rbp),%rax
movsd  %xmm0,-0x1e0(%rbp,%rax,8)
ff ff
mov    -0x210(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x210(%rbp)
jmp    151f <fail+0x3bf>
movslq -0x20c(%rbp),%rax
movsd  -0x1e0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x20c(%rbp),%rax
movsd  %xmm0,-0x180(%rbp,%rax,8)
ff ff
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    1508 <fail+0x3a8>
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x180(%rbp),%rsi
lea    -0x160(%rbp),%rdx
call   1030 <check_convergence@plt>
mov    %eax,-0x204(%rbp)
jmp    1380 <fail+0x220>
movl   $0x0,-0x20c(%rbp)
cmpl   $0x3,-0x20c(%rbp)
jge    16af <fail+0x54f>
movl   $0x0,-0x210(%rbp)
cmpl   $0x3,-0x210(%rbp)
jge    1696 <fail+0x536>
movslq -0x20c(%rbp),%rax
movsd  -0x200(%rbp,%rax,8),%xmm1
ff ff
movslq -0x20c(%rbp),%rcx
lea    -0x50(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x210(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x210(%rbp),%rax
movsd  -0x180(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x20c(%rbp),%rax
movsd  %xmm0,-0x200(%rbp,%rax,8)
ff ff
mov    -0x210(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x210(%rbp)
jmp    161f <fail+0x4bf>
jmp    169b <fail+0x53b>
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
jmp    1608 <fail+0x4a8>
cmpl   $0xfa,-0x208(%rbp)
jne    16e9 <fail+0x589>
lea    0xaed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1080 <print_matrix@plt>
jmp    171c <fail+0x5bc>
mov    -0x208(%rbp),%esi
lea    0xb0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x180(%rbp),%rdi
mov    $0x3,%esi
call   1070 <print_vector@plt>
lea    0xb25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fail>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0xf3b(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xf1c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
mov    0xf19(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa0(%rip),%rdi
call   1030 <puts@plt>
lea    0xfcd(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
movsd  0xe02(%rip),%xmm1
movsd  0xe02(%rip),%xmm0
movsd  0xe02(%rip),%xmm2
xorpd  %xmm3,%xmm3
movhpd 0xe06(%rip),%xmm3
movapd %xmm3,0x40(%rsp)
lea    0x50(%rsp),%r14
mov    %rsp,%r15
lea    0x20(%rsp),%r12
xorpd  %xmm3,%xmm3
xorpd  %xmm4,%xmm4
xorpd  %xmm5,%xmm5
nopl   0x0(%rax)
xorpd  %xmm8,%xmm8
mulsd  %xmm8,%xmm5
addsd  %xmm8,%xmm5
movapd %xmm4,%xmm6
mulsd  0xdb5(%rip),%xmm6
addsd  %xmm5,%xmm6
movapd %xmm3,%xmm7
addsd  %xmm3,%xmm7
addsd  %xmm6,%xmm7
subsd  %xmm7,%xmm1
mulsd  %xmm8,%xmm4
addsd  %xmm5,%xmm4
movapd %xmm3,%xmm5
mulsd  0xd94(%rip),%xmm5
addsd  %xmm4,%xmm5
subsd  %xmm5,%xmm0
mulsd  %xmm8,%xmm3
addsd  %xmm4,%xmm3
subsd  %xmm3,%xmm2
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
mulpd  0xd97(%rip),%xmm3
addpd  0xd9f(%rip),%xmm3
movapd %xmm0,%xmm4
unpcklpd %xmm0,%xmm4
mulpd  0x40(%rsp),%xmm4
addpd  %xmm3,%xmm4
movapd %xmm2,%xmm3
mulsd  %xmm8,%xmm3
unpcklpd %xmm3,%xmm3
addpd  %xmm4,%xmm3
movapd %xmm3,(%rsp)
mulsd  0xd47(%rip),%xmm1
addsd  %xmm8,%xmm1
mulsd  0xd42(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xd3e(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <check_convergence@plt>
test   %eax,%eax
jne    1349 <fail+0x1f9>
cmp    $0xf8,%ebx
ja     1349 <fail+0x1f9>
movsd  (%rsp),%xmm5
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm3
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm2
add    $0x1,%ebx
jmp    1240 <fail+0xf0>
cmp    $0xf9,%ebx
jne    1375 <fail+0x225>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0x50(%rsp),%rdi
call   1070 <print_matrix@plt>
jmp    13a1 <fail+0x251>
add    $0x1,%ebx
lea    0xd49(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x3,%esi
call   1060 <print_vector@plt>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.fail.A = [3 x [3 x double]] [[3 x double] [double 5.000000e+00, double 6.000000e+00, double 2.000000e+00], [3 x double] [double 6.000000e+00, double 4.000000e+00, double 4.000000e+00], [3 x double] [double 1.000000e+00, double 1.000000e+00, double 6.000000e+00]]
@__const.fail.b = [3 x double] [double 2.000000e+00, double 7.000000e+00, double 6.000000e+00]
@.str = [47 x i8] c"\0A----------Question3_Fail_Cases : ----------\0A\0A\00"
@.str.1 = [43 x i8] c"Ax=b case provided for the first question\0A\00"
@.str.2 = [48 x i8] c"is already failed for Jacobi Method, therefore\0A\00"
@.str.3 = [58 x i8] c"we will only provide fail case for Gauss-Seidel Method :\0A\00"
@.str.4 = [39 x i8] c"Fail case for Gauss-Seidel Method : \0A\0A\00"
@.str.5 = [67 x i8] c"Gauss-Seidel is failed! (Maximum number of iterations is reached)\0A\00"
@.str.6 = [14 x i8] c"\0AMatrix A : \0A\00"
@.str.7 = [52 x i8] c"Gauss-Seidel Method is converged in %d iterations.\0A\00"
@.str.8 = [16 x i8] c"Solution, x: \0A\00"
@.str.9 = [37 x i8] c"\0A----------EndOfFailCase----------\0A\0A\00"
define void @fail() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [3 x [3 x double]]
%3 = alloca [3 x [3 x double]]
%4 = alloca [3 x [3 x double]]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = alloca [3 x double]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = bitcast [3 x [3 x double]]* %1 to i8*
%16 = bitcast [3 x [3 x double]]* %2 to i8*
%17 = bitcast i8* %16 to [3 x [3 x double]]*
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i32 0, i32 0
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i32 0, i32 0
store double 5.000000e+00, double* %19
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i32 0, i32 1
%21 = getelementptr inbounds [3 x double], [3 x double]* %20, i32 0, i32 0
store double 6.000000e+00, double* %21
%22 = getelementptr inbounds [3 x double], [3 x double]* %20, i32 0, i32 1
store double 4.000000e+00, double* %22
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %17, i32 0, i32 2
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i32 0, i32 0
store double 1.000000e+00, double* %24
%25 = getelementptr inbounds [3 x double], [3 x double]* %23, i32 0, i32 1
store double 1.000000e+00, double* %25
%26 = getelementptr inbounds [3 x double], [3 x double]* %23, i32 0, i32 2
store double 6.000000e+00, double* %26
%27 = bitcast [3 x [3 x double]]* %3 to i8*
%28 = bitcast i8* %27 to [3 x [3 x double]]*
%29 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %28, i32 0, i32 0
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i32 0, i32 0
store double 2.000000e-01, double* %30
%31 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %28, i32 0, i32 1
%32 = getelementptr inbounds [3 x double], [3 x double]* %31, i32 0, i32 0
store double -3.000000e-01, double* %32
%33 = getelementptr inbounds [3 x double], [3 x double]* %31, i32 0, i32 1
store double 2.500000e-01, double* %33
%34 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %28, i32 0, i32 2
%35 = getelementptr inbounds [3 x double], [3 x double]* %34, i32 0, i32 0
store double 0x3F91111111111111, double* %35
%36 = getelementptr inbounds [3 x double], [3 x double]* %34, i32 0, i32 1
store double 0xBFA5555555555555, double* %36
%37 = getelementptr inbounds [3 x double], [3 x double]* %34, i32 0, i32 2
store double 0x3FC5555555555555, double* %37
%38 = bitcast [3 x [3 x double]]* %4 to i8*
%39 = bitcast i8* %38 to [3 x [3 x double]]*
%40 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %39, i32 0, i32 0
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i32 0, i32 1
store double 6.000000e+00, double* %41
%42 = getelementptr inbounds [3 x double], [3 x double]* %40, i32 0, i32 2
store double 2.000000e+00, double* %42
%43 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %39, i32 0, i32 1
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i32 0, i32 2
store double 4.000000e+00, double* %44
%45 = bitcast [3 x double]* %5 to i8*
%46 = bitcast [3 x double]* %6 to i8*
%47 = bitcast [3 x double]* %7 to i8*
%48 = bitcast [3 x double]* %8 to i8*
%49 = bitcast [3 x double]* %9 to i8*
%50 = bitcast [3 x double]* %10 to i8*
store i32 0, i32* %11
store i32 0, i32* %12
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %170, %0
%57 = load i32, i32* %11
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %12
%61 = icmp slt i32 %60, 250
br label %62
62: ; preds = %59, %56
%63 = phi i1 [ false, %56 ], [ %61, %59 ]
br i1 %63, label %64, label %178
64: ; preds = %62
store i32 0, i32* %13
br label %65
65: ; preds = %78, %64
%66 = load i32, i32* %13
%67 = icmp slt i32 %66, 3
br i1 %67, label %68, label %81
68: ; preds = %65
%69 = load i32, i32* %13
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %70
store double 0.000000e+00, double* %71
%72 = load i32, i32* %13
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %73
store double 0.000000e+00, double* %74
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %76
store double 0.000000e+00, double* %77
br label %78
78: ; preds = %68
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 1
store i32 %80, i32* %13
br label %65
81: ; preds = %65
store i32 0, i32* %13
br label %82
82: ; preds = %125, %81
%83 = load i32, i32* %13
%84 = icmp slt i32 %83, 3
br i1 %84, label %85, label %128
85: ; preds = %82
store i32 0, i32* %14
br label %86
86: ; preds = %109, %85
%87 = load i32, i32* %14
%88 = icmp slt i32 %87, 3
br i1 %88, label %89, label %112
89: ; preds = %86
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %91
%93 = load double, double* %92
%94 = load i32, i32* %13
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 %95
%97 = load i32, i32* %14
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [3 x double], [3 x double]* %96, i64 0, i64 %98
%100 = load double, double* %99
%101 = load i32, i32* %14
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %102
%104 = load double, double* %103
%105 = call double @llvm.fmuladd.f64(double %100, double %104, double %93)
%106 = load i32, i32* %13
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %107
store double %105, double* %108
br label %109
109: ; preds = %89
%110 = load i32, i32* %14
%111 = add nsw i32 %110, 1
store i32 %111, i32* %14
br label %86
112: ; preds = %86
%113 = load i32, i32* %13
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %114
%116 = load double, double* %115
%117 = load i32, i32* %13
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %118
%120 = load double, double* %119
%121 = fsub double %116, %120
%122 = load i32, i32* %13
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %123
store double %121, double* %124
br label %125
125: ; preds = %112
%126 = load i32, i32* %13
%127 = add nsw i32 %126, 1
store i32 %127, i32* %13
br label %82
128: ; preds = %82
store i32 0, i32* %13
br label %129
129: ; preds = %167, %128
%130 = load i32, i32* %13
%131 = icmp slt i32 %130, 3
br i1 %131, label %132, label %170
132: ; preds = %129
store i32 0, i32* %14
br label %133
133: ; preds = %156, %132
%134 = load i32, i32* %14
%135 = icmp slt i32 %134, 3
br i1 %135, label %136, label %159
136: ; preds = %133
%137 = load i32, i32* %13
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %138
%140 = load double, double* %139
%141 = load i32, i32* %13
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 %142
%144 = load i32, i32* %14
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [3 x double], [3 x double]* %143, i64 0, i64 %145
%147 = load double, double* %146
%148 = load i32, i32* %14
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %149
%151 = load double, double* %150
%152 = call double @llvm.fmuladd.f64(double %147, double %151, double %140)
%153 = load i32, i32* %13
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %154
store double %152, double* %155
br label %156
156: ; preds = %136
%157 = load i32, i32* %14
%158 = add nsw i32 %157, 1
store i32 %158, i32* %14
br label %133
159: ; preds = %133
%160 = load i32, i32* %13
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 %161
%163 = load double, double* %162
%164 = load i32, i32* %13
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %165
store double %163, double* %166
br label %167
167: ; preds = %159
%168 = load i32, i32* %13
%169 = add nsw i32 %168, 1
store i32 %169, i32* %13
br label %129
170: ; preds = %129
%171 = load i32, i32* %12
%172 = add nsw i32 %171, 1
store i32 %172, i32* %12
%173 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%174 = bitcast [3 x double]* %173 to double**
%175 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%176 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%177 = call i32 @check_convergence(double** %174, double* %175, double* %176)
store i32 %177, i32* %11
br label %56
178: ; preds = %62
store i32 0, i32* %13
br label %179
179: ; preds = %210, %178
%180 = load i32, i32* %13
%181 = icmp slt i32 %180, 3
br i1 %181, label %182, label %213
182: ; preds = %179
store i32 0, i32* %14
br label %183
183: ; preds = %206, %182
%184 = load i32, i32* %14
%185 = icmp slt i32 %184, 3
br i1 %185, label %186, label %209
186: ; preds = %183
%187 = load i32, i32* %13
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %188
%190 = load double, double* %189
%191 = load i32, i32* %13
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 %192
%194 = load i32, i32* %14
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [3 x double], [3 x double]* %193, i64 0, i64 %195
%197 = load double, double* %196
%198 = load i32, i32* %14
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 %199
%201 = load double, double* %200
%202 = call double @llvm.fmuladd.f64(double %197, double %201, double %190)
%203 = load i32, i32* %13
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %204
store double %202, double* %205
br label %206
206: ; preds = %186
%207 = load i32, i32* %14
%208 = add nsw i32 %207, 1
store i32 %208, i32* %14
br label %183
209: ; preds = %183
br label %210
210: ; preds = %209
%211 = load i32, i32* %13
%212 = add nsw i32 %211, 1
store i32 %212, i32* %13
br label %179
213: ; preds = %179
%214 = load i32, i32* %12
%215 = icmp eq i32 %214, 250
br i1 %215, label %216, label %222
216: ; preds = %213
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0))
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%219 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 0
%220 = bitcast [3 x double]* %219 to double**
%221 = call i32 @print_matrix(double** %220)
br label %228
222: ; preds = %213
%223 = load i32, i32* %12
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %223)
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%226 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%227 = call i32 @print_vector(double* %226, i32 3)
br label %228
228: ; preds = %222, %216
%229 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.fail.A = [3 x [3 x double]] [[3 x double] [double 5.000000e+00, double 6.000000e+00, double 2.000000e+00], [3 x double] [double 6.000000e+00, double 4.000000e+00, double 4.000000e+00], [3 x double] [double 1.000000e+00, double 1.000000e+00, double 6.000000e+00]]
@__const.fail.b = [3 x double] [double 2.000000e+00, double 7.000000e+00, double 6.000000e+00]
@.str.7 = [52 x i8] c"Gauss-Seidel Method is converged in %d iterations.\0A\00"
@str = [46 x i8] c"\0A----------Question3_Fail_Cases : ----------\0A\00"
@str.10 = [42 x i8] c"Ax=b case provided for the first question\00"
@str.11 = [47 x i8] c"is already failed for Jacobi Method, therefore\00"
@str.12 = [57 x i8] c"we will only provide fail case for Gauss-Seidel Method :\00"
@str.13 = [38 x i8] c"Fail case for Gauss-Seidel Method : \0A\00"
@str.14 = [15 x i8] c"Solution, x: \00"
@str.15 = [36 x i8] c"\0A----------EndOfFailCase----------\0A\00"
@str.16 = [66 x i8] c"Gauss-Seidel is failed! (Maximum number of iterations is reached)\00"
@str.17 = [13 x i8] c"\0AMatrix A : \00"
define void @fail() {
%1 = alloca [3 x [3 x double]]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = bitcast [3 x [3 x double]]* %1 to i8*
%5 = bitcast [3 x double]* %2 to i8*
%6 = bitcast [3 x double]* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.11, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.12, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
%12 = bitcast [3 x [3 x double]]* %1 to double**
%13 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%14 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%16 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%17 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%18 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%19 = bitcast [3 x double]* %3 to <2 x double>*
br label %20
20: ; preds = %54, %0
%21 = phi double [ 6.000000e+00, %0 ], [ %60, %54 ]
%22 = phi double [ 7.000000e+00, %0 ], [ %59, %54 ]
%23 = phi double [ 2.000000e+00, %0 ], [ %58, %54 ]
%24 = phi double [ 0.000000e+00, %0 ], [ %57, %54 ]
%25 = phi double [ 0.000000e+00, %0 ], [ %56, %54 ]
%26 = phi double [ 0.000000e+00, %0 ], [ %55, %54 ]
%27 = phi i32 [ 0, %0 ], [ %49, %54 ]
%28 = call double @llvm.fmuladd.f64(double %26, double 0.000000e+00, double 0.000000e+00)
%29 = call double @llvm.fmuladd.f64(double %25, double 6.000000e+00, double %28)
%30 = call double @llvm.fmuladd.f64(double %24, double 2.000000e+00, double %29)
%31 = fsub double %23, %30
%32 = call double @llvm.fmuladd.f64(double %25, double 0.000000e+00, double %28)
%33 = call double @llvm.fmuladd.f64(double %24, double 4.000000e+00, double %32)
%34 = fsub double %22, %33
%35 = call double @llvm.fmuladd.f64(double %24, double 0.000000e+00, double %32)
%36 = fsub double %21, %35
%37 = insertelement <2 x double> poison, double %31, i64 0
%38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %38, <2 x double> <double 2.000000e-01, double -3.000000e-01>, <2 x double> zeroinitializer)
%40 = insertelement <2 x double> poison, double %34, i64 0
%41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
%42 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %41, <2 x double> <double 0.000000e+00, double 2.500000e-01>, <2 x double> %39)
%43 = insertelement <2 x double> poison, double %36, i64 0
%44 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> zeroinitializer
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> zeroinitializer, <2 x double> %42)
store <2 x double> %45, <2 x double>* %19
%46 = call double @llvm.fmuladd.f64(double %31, double 0x3F91111111111111, double 0.000000e+00)
%47 = call double @llvm.fmuladd.f64(double %34, double 0xBFA5555555555555, double %46)
%48 = call double @llvm.fmuladd.f64(double %36, double 0x3FC5555555555555, double %47)
store double %48, double* %16
%49 = add nuw nsw i32 %27, 1
%50 = call i32 @check_convergence(double** %12, double* %13, double* %14)
%51 = icmp eq i32 %50, 0
%52 = icmp ult i32 %27, 249
%53 = select i1 %51, i1 %52, i1 false
br i1 %53, label %54, label %61
54: ; preds = %20
%55 = load double, double* %13
%56 = load double, double* %15
%57 = load double, double* %16
%58 = load double, double* %14
%59 = load double, double* %18
%60 = load double, double* %17
br label %20
61: ; preds = %20
%62 = icmp eq i32 %49, 250
br i1 %62, label %63, label %67
63: ; preds = %61
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.16, i64 0, i64 0))
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.17, i64 0, i64 0))
%66 = call i32 @print_matrix(double** %12)
br label %71
67: ; preds = %61
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
%70 = call i32 @print_vector(double* %13, i32 3)
br label %71
71: ; preds = %67, %63
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0))
ret void
}