#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 /*<<< orphan*/ GaussSeidalMethod(int, double *, double *, double **);
int /*<<< orphan*/ JacobisMethod(int, double *, double *, double **);
int /*<<< orphan*/ print(int, double *);
int main() {
  int n = 3;
  double x[n];
  double b[n], a[n][n];
  a[0][0] = 8;
  a[0][1] = 2;
  a[0][2] = -2;
  b[0] = 8;
  a[1][0] = 1;
  a[1][1] = -8;
  a[1][2] = 3;
  b[1] = -4;
  a[2][0] = 2;
  a[2][1] = 1;
  a[2][2] = 9;
  b[2] = 12;
  int i;
  for (i = 0; i < n; i++) {
    x[i] = 0;
  }
  JacobisMethod(n, x, b, a);
  print(n, x);
  for (i = 0; i < n; i++) {
    x[i] = 0;
  }
  GaussSeidalMethod(n, x, b, a);
  print(n, x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
lea    0xf(,%rcx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x50(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%ecx
mov    %ecx,%esi
mov    %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rsi,%rcx
imul   %rcx,%rcx
lea    0xf(,%rcx,8),%rdi
and    $0xfffffffffffffff0,%rdi
mov    %rsp,%rcx
sub    %rdi,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
imul   $0x0,%rdx,%rsi
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%rcx,%rsi,8)
imul   $0x0,%rdx,%rsi
movsd  0xe38(%rip),%xmm0
movsd  %xmm0,0x8(%rcx,%rsi,8)
imul   $0x0,%rdx,%rsi
movsd  0xe4e(%rip),%xmm0
movsd  %xmm0,0x10(%rcx,%rsi,8)
movsd  0xe38(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    %rdx,%rsi
shl    $0x0,%rsi
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,(%rcx,%rsi,8)
mov    %rdx,%rsi
shl    $0x0,%rsi
movsd  0xe09(%rip),%xmm0
movsd  %xmm0,0x8(%rcx,%rsi,8)
mov    %rdx,%rsi
shl    $0x0,%rsi
movsd  0xdec(%rip),%xmm0
movsd  %xmm0,0x10(%rcx,%rsi,8)
movsd  0xdd6(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    %rdx,%rsi
shl    $0x1,%rsi
movsd  0xdba(%rip),%xmm0
movsd  %xmm0,(%rcx,%rsi,8)
mov    %rdx,%rsi
shl    $0x1,%rsi
movsd  0xd9e(%rip),%xmm0
movsd  %xmm0,0x8(%rcx,%rsi,8)
shl    $0x1,%rdx
movsd  0xd84(%rip),%xmm0
movsd  %xmm0,0x10(%rcx,%rdx,8)
movsd  0xd6e(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c8 <main+0x198>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    129e <main+0x16e>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x8(%rbp),%edi
call   1050 <JacobisMethod@plt>
mov    -0x58(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1040 <print@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1319 <main+0x1e9>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12ef <main+0x1bf>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x8(%rbp),%edi
call   1030 <GaussSeidalMethod@plt>
mov    -0x58(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1040 <print@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movabs $0x4022000000000000,%rax
mov    %rax,0x80(%rsp)
movabs $0x4028000000000000,%rax
mov    %rax,0x30(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rbx
lea    0x20(%rsp),%r14
lea    0x40(%rsp),%r15
mov    $0x3,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <JacobisMethod@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1040 <print@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    $0x3,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <GaussSeidalMethod@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1040 <print@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca double, i64 %10
store i64 %10, i64* %4
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = alloca double, i64 %14
store i64 %14, i64* %5
%16 = load i32, i32* %2
%17 = zext i32 %16 to i64
%18 = load i32, i32* %2
%19 = zext i32 %18 to i64
%20 = mul nuw i64 %17, %19
%21 = alloca double, i64 %20
store i64 %17, i64* %6
store i64 %19, i64* %7
%22 = mul nsw i64 0, %19
%23 = getelementptr inbounds double, double* %21, i64 %22
%24 = getelementptr inbounds double, double* %23, i64 0
store double 8.000000e+00, double* %24
%25 = mul nsw i64 0, %19
%26 = getelementptr inbounds double, double* %21, i64 %25
%27 = getelementptr inbounds double, double* %26, i64 1
store double 2.000000e+00, double* %27
%28 = mul nsw i64 0, %19
%29 = getelementptr inbounds double, double* %21, i64 %28
%30 = getelementptr inbounds double, double* %29, i64 2
store double -2.000000e+00, double* %30
%31 = getelementptr inbounds double, double* %15, i64 0
store double 8.000000e+00, double* %31
%32 = mul nsw i64 1, %19
%33 = getelementptr inbounds double, double* %21, i64 %32
%34 = getelementptr inbounds double, double* %33, i64 0
store double 1.000000e+00, double* %34
%35 = mul nsw i64 1, %19
%36 = getelementptr inbounds double, double* %21, i64 %35
%37 = getelementptr inbounds double, double* %36, i64 1
store double -8.000000e+00, double* %37
%38 = mul nsw i64 1, %19
%39 = getelementptr inbounds double, double* %21, i64 %38
%40 = getelementptr inbounds double, double* %39, i64 2
store double 3.000000e+00, double* %40
%41 = getelementptr inbounds double, double* %15, i64 1
store double -4.000000e+00, double* %41
%42 = mul nsw i64 2, %19
%43 = getelementptr inbounds double, double* %21, i64 %42
%44 = getelementptr inbounds double, double* %43, i64 0
store double 2.000000e+00, double* %44
%45 = mul nsw i64 2, %19
%46 = getelementptr inbounds double, double* %21, i64 %45
%47 = getelementptr inbounds double, double* %46, i64 1
store double 1.000000e+00, double* %47
%48 = mul nsw i64 2, %19
%49 = getelementptr inbounds double, double* %21, i64 %48
%50 = getelementptr inbounds double, double* %49, i64 2
store double 9.000000e+00, double* %50
%51 = getelementptr inbounds double, double* %15, i64 2
store double 1.200000e+01, double* %51
store i32 0, i32* %8
br label %52
52: ; preds = %60, %0
%53 = load i32, i32* %8
%54 = load i32, i32* %2
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %63
56: ; preds = %52
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %12, i64 %58
store double 0.000000e+00, double* %59
br label %60
60: ; preds = %56
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %52
63: ; preds = %52
%64 = load i32, i32* %2
%65 = bitcast double* %21 to double**
%66 = call i32 @JacobisMethod(i32 %64, double* %12, double* %15, double** %65)
%67 = load i32, i32* %2
%68 = call i32 @print(i32 %67, double* %12)
store i32 0, i32* %8
br label %69
69: ; preds = %77, %63
%70 = load i32, i32* %8
%71 = load i32, i32* %2
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %12, i64 %75
store double 0.000000e+00, double* %76
br label %77
77: ; preds = %73
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %69
80: ; preds = %69
%81 = load i32, i32* %2
%82 = bitcast double* %21 to double**
%83 = call i32 @GaussSeidalMethod(i32 %81, double* %12, double* %15, double** %82)
%84 = load i32, i32* %2
%85 = call i32 @print(i32 %84, double* %12)
store i32 0, i32* %1
%86 = load i8*, i8** %3
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [3 x double]
%2 = bitcast [3 x double]* %1 to i8*
%3 = alloca [3 x double]
%4 = alloca [9 x double]
%5 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%6 = bitcast [9 x double]* %4 to <2 x double>*
store <2 x double> <double 8.000000e+00, double 2.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 2
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double -2.000000e+00, double 1.000000e+00>, <2 x double>* %8
%9 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 4
%10 = bitcast double* %9 to <2 x double>*
store <2 x double> <double -8.000000e+00, double 3.000000e+00>, <2 x double>* %10
%11 = bitcast [3 x double]* %3 to <2 x double>*
store <2 x double> <double 8.000000e+00, double -4.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 6
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 1.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 8
store double 9.000000e+00, double* %14
%15 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
store double 1.200000e+01, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%17 = bitcast [9 x double]* %4 to double**
%18 = call i32 @JacobisMethod(i32 3, double* %16, double* %5, double** %17)
%19 = call i32 @print(i32 3, double* %16)
%20 = call i32 @GaussSeidalMethod(i32 3, double* %16, double* %5, double** %17)
%21 = call i32 @print(i32 3, double* %16)
ret i32 0
}