#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 atoi(char *);
int /*<<< orphan*/ init_array(int, double **);
int jacobi(int, double **, double);
int /*<<< orphan*/ print_array(int, double **);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int n = 8;
  if (argc > 1) {
    if ((n = atoi(argv[1])) < 2) {
      printf("Mesh size must must be greater than 2, use default\n");
      n = 8;
    }
  }
  double a[n][n];
  init_array(n, a);
  int cnt = jacobi(n, a, 0.001);
  printf("Mesh size: %d x %d, epsilon=%6.4f, total Jacobi iterations: %d\n", n,
         n, 0.001, cnt);
  if (0)
    print_array(n, a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    119a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x2,%eax
jge    1195 <main+0x55>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x8,-0x14(%rbp)
jmp    119a <main+0x5a>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <init_array@plt>
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edi
movsd  0xe18(%rip),%xmm0
call   1030 <jacobi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x34(%rbp),%ecx
lea    0xe3c(%rip),%rdi
movsd  0xdf8(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    $0x8,%r14d
cmp    $0x2,%edi
jl     1185 <main+0x35>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
cmp    $0x1,%eax
jg     1185 <main+0x35>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
mov    $0x8,%r14d
mov    %r14d,%eax
imul   %rax,%rax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r14d,%edi
mov    %rbx,%rsi
call   1060 <init_array@plt>
movsd  0xe4c(%rip),%xmm0
mov    %r14d,%edi
mov    %rbx,%rsi
call   1030 <jacobi@plt>
lea    0xe42(%rip),%rdi
mov    %r14d,%esi
mov    %r14d,%edx
movsd  0xe2c(%rip),%xmm0
mov    %eax,%ecx
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Mesh size must must be greater than 2, use default\0A\00"
@.str.1 = [64 x i8] c"Mesh size: %d x %d, epsilon=%6.4f, total Jacobi iterations: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8, i32* %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 8, i32* %6
br label %21
21: ; preds = %19, %13
br label %22
22: ; preds = %21, %2
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = call i8* @llvm.stacksave()
store i8* %27, i8** %7
%28 = mul nuw i64 %24, %26
%29 = alloca double, i64 %28
store i64 %24, i64* %8
store i64 %26, i64* %9
%30 = load i32, i32* %6
%31 = bitcast double* %29 to double**
%32 = call i32 @init_array(i32 %30, double** %31)
%33 = load i32, i32* %6
%34 = bitcast double* %29 to double**
%35 = call i32 @jacobi(i32 %33, double** %34, double 1.000000e-03)
store i32 %35, i32* %10
%36 = load i32, i32* %6
%37 = load i32, i32* %6
%38 = load i32, i32* %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37, double 1.000000e-03, i32 %38)
%40 = load i8*, i8** %7
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str.1 = [64 x i8] c"Mesh size: %d x %d, epsilon=%6.4f, total Jacobi iterations: %d\0A\00"
@str = [51 x i8] c"Mesh size must must be greater than 2, use default\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %4, %9, %2
%12 = phi i32 [ 8, %9 ], [ %7, %4 ], [ 8, %2 ]
%13 = zext i32 %12 to i64
%14 = mul nuw nsw i64 %13, %13
%15 = alloca double*, i64 %14
%16 = call i32 @init_array(i32 %12, double** %15)
%17 = call i32 @jacobi(i32 %12, double** %15, double 1.000000e-03)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %12, double 1.000000e-03, i32 %17)
ret i32 0
}