#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
long atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free2DDoubleArray(double **, unsigned int);
int getopt(int, char **, char *);
int /*<<< orphan*/ initializeArray(double **, unsigned int, unsigned int);
double **make2DDoubleArray(unsigned int, unsigned int);
char *optarg;
int /*<<< orphan*/ save(double **, unsigned int, unsigned int, char *);
int /*<<< orphan*/ setupBoundaryConditions(double **, unsigned int,
                                           unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ update(unsigned int, unsigned int, double **, double **);
int main(int argc, char *argv[]) {
  long int s, it;
  unsigned int flag, verbose;
  unsigned int NX, NY, NXPROB, NYPROB;
  double start, end;
  int iz;
  NX = 100;
  NY = 100;
  flag = 0;
  verbose = 0;
  int opt;
  char *file = NULL;
  while ((opt = getopt(argc, argv, "hvs:f:")) != -1) {
    switch (opt) {
    case 'v':
      verbose = 1;
      break;
    case 's':
      if (!(s = atoi(optarg))) {
        fprintf(stderr, "Cannot parse %s value.\n", optarg);
        exit(EXIT_FAILURE);
      }
      NX = NY = s;
      break;
    case 'f':
      file = optarg;
      flag = 1;
      break;
    case 'h':
    default:
      fprintf(stderr, "Usage: %s [-s SIZE] [-f output file]\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  NXPROB = NX - 1;
  NYPROB = NY - 1;
  if (verbose) {
    fprintf(stdout, "[INFO] Setting map size to %d (%dx%d)\n", NX * NY, NX, NY);
    fprintf(stdout, "[INFO] Max iter %d\n", 1000);
  }
  if (verbose && flag) {
    fprintf(stdout, "[INFO] Using output file %s\n", file);
  }
  double **X[2];
  X[0] = make2DDoubleArray(NX, NY);
  X[1] = make2DDoubleArray(NX, NY);
  initializeArray(X[0], NX, NY);
  setupBoundaryConditions(X[0], NX, NY);
  setupBoundaryConditions(X[1], NX, NY);
  iz = 0;
  for (it = 0; it < 1000; it++) {
    update(NXPROB, NYPROB, X[iz], X[1 - iz]);
    iz = 1 - iz;
  }
  if (flag)
    save(X[iz], NX, NY, file);
  free2DDoubleArray(X[0], NX);
  free2DDoubleArray(X[1], NX);
  if (verbose) {
    fprintf(stdout, "[INFO] Convergence after %d steps\n", 1000);
    fprintf(stdout, "[INFO] Problem size %d [%dx%d]\n", NY * NX, NX, NY);
    if (flag)
      fprintf(stdout, "[INFO] Output file  %s\n", file);
  }
  exit(EXIT_SUCCESS);
}


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   $0x64,-0x2c(%rbp)
movl   $0x64,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe59(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x50(%rbp)
cmp    $0xffffffff,%eax
je     12dc <main+0x13c>
mov    -0x50(%rbp),%eax
add    $0xffffff9a,%eax
mov    %eax,%ecx
mov    %rcx,-0x78(%rbp)
sub    $0x10,%eax
ja     12ab <main+0x10b>
mov    -0x78(%rbp),%rax
lea    0xde4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x28(%rbp)
jmp    12d7 <main+0x137>
mov    0x2dc0(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    127d <main+0xdd>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
mov    0x2d9a(%rip),%rax
mov    (%rax),%rdx
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %eax,-0x30(%rbp)
mov    %eax,-0x2c(%rbp)
jmp    12d7 <main+0x137>
mov    0x2d65(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    12d7 <main+0x137>
jmp    12ab <main+0x10b>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    11dd <main+0x3d>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1339 <main+0x199>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
imul   -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xd73(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    $0x3e8,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x0,-0x28(%rbp)
je     1368 <main+0x1c8>
cmpl   $0x0,-0x24(%rbp)
je     1368 <main+0x1c8>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rdx
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <make2DDoubleArray@plt>
mov    %rax,-0x70(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <make2DDoubleArray@plt>
mov    %rax,-0x68(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   10c0 <initializeArray@plt>
mov    -0x70(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1060 <setupBoundaryConditions@plt>
mov    -0x68(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1060 <setupBoundaryConditions@plt>
movl   $0x0,-0x4c(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x3e8,-0x20(%rbp)
jge    140f <main+0x26f>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
movslq -0x4c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdx
mov    $0x1,%eax
sub    -0x4c(%rbp),%eax
cltq
mov    -0x70(%rbp,%rax,8),%rcx
call   1030 <update@plt>
mov    $0x1,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    13c2 <main+0x222>
cmpl   $0x0,-0x24(%rbp)
je     1431 <main+0x291>
movslq -0x4c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x58(%rbp),%rcx
call   1070 <save@plt>
mov    -0x70(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <free2DDoubleArray@plt>
mov    -0x68(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <free2DDoubleArray@plt>
cmpl   $0x0,-0x28(%rbp)
je     14be <main+0x31e>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
mov    $0x3e8,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
imul   -0x2c(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xc77(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     14b9 <main+0x319>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rdx
lea    0xc72(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    14be <main+0x31e>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    $0x64,%eax
mov    %rax,0x8(%rsp)
lea    0xe35(%rip),%r15
mov    0x2e26(%rip),%r13
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    11ea <main+0x4a>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%r12
mov    $0x1,%r14d
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1090 <getopt@plt>
cmp    $0x66,%eax
je     11e0 <main+0x40>
cmp    $0x73,%eax
je     1212 <main+0x72>
cmp    $0x76,%eax
jne    1242 <main+0xa2>
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
jmp    11ea <main+0x4a>
mov    0x0(%r13),%rdi
mov    %rdi,(%rsp)
call   10a0 <atoi@plt>
mov    %rax,%rcx
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    11ea <main+0x4a>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
mov    (%rsp),%rdx
jmp    1276 <main+0xd6>
cmp    $0xffffffff,%eax
jne    1262 <main+0xc2>
mov    0x8(%rsp),%rbp
lea    -0x1(%rbp),%r13d
cmpl   $0x0,0x10(%rsp)
jne    128b <main+0xeb>
test   %r14d,%r14d
setne  %al
jmp    12e2 <main+0x142>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xda9(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2d36(%rip),%rbx
mov    (%rbx),%edi
mov    %ebp,%edx
imul   %ebp,%edx
lea    0xda5(%rip),%rsi
movl   $0x0,(%rsp)
mov    %ebp,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdb0(%rip),%rsi
mov    $0x3e8,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %r14d,%r14d
je     12e5 <main+0x145>
mov    (%rbx),%edi
lea    0xdaa(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%al
mov    %eax,(%rsp)
mov    %ebp,%edi
mov    %ebp,%esi
call   1050 <make2DDoubleArray@plt>
mov    %rax,%r15
mov    %rax,0x20(%rsp)
mov    %ebp,%edi
mov    %ebp,%esi
call   1050 <make2DDoubleArray@plt>
mov    %rax,%rbx
mov    %rax,0x28(%rsp)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
call   10c0 <initializeArray@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
call   1060 <setupBoundaryConditions@plt>
mov    %rbx,0x18(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rbp,0x8(%rsp)
mov    %ebp,%edx
call   1060 <setupBoundaryConditions@plt>
xor    %eax,%eax
mov    $0x3e8,%ebp
mov    %r15,%rbx
nop
mov    %rbx,%rdx
mov    $0x1,%r14d
sub    %eax,%r14d
mov    0x20(%rsp,%r14,8),%rbx
mov    %r13d,%edi
mov    %r13d,%esi
mov    %rbx,%rcx
call   1030 <update@plt>
mov    %r14d,%eax
add    $0xffffffffffffffff,%rbp
jne    1340 <main+0x1a0>
mov    (%rsp),%r14d
test   %r14b,%r14b
mov    0x8(%rsp),%rbp
je     1385 <main+0x1e5>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %r12,%rcx
call   1070 <save@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <free2DDoubleArray@plt>
mov    0x18(%rsp),%rdi
mov    %ebp,%esi
call   1040 <free2DDoubleArray@plt>
cmpl   $0x0,0x10(%rsp)
je     13f0 <main+0x250>
mov    0x2c1f(%rip),%rbx
mov    (%rbx),%edi
lea    0xceb(%rip),%rsi
mov    $0x3e8,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
mov    %ebp,%edx
imul   %ebp,%edx
lea    0xcf4(%rip),%rsi
mov    %ebp,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %r14b,%r14b
je     13f0 <main+0x250>
mov    (%rbx),%edi
lea    0xcfa(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"hvs:f:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [24 x i8] c"Cannot parse %s value.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"Usage: %s [-s SIZE] [-f output file]\0A\00"
@stdout = global i32 0
@.str.3 = [39 x i8] c"[INFO] Setting map size to %d (%dx%d)\0A\00"
@.str.4 = [20 x i8] c"[INFO] Max iter %d\0A\00"
@.str.5 = [29 x i8] c"[INFO] Using output file %s\0A\00"
@.str.6 = [35 x i8] c"[INFO] Convergence after %d steps\0A\00"
@.str.7 = [32 x i8] c"[INFO] Problem size %d [%dx%d]\0A\00"
@.str.8 = [24 x i8] c"[INFO] Output file %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca [2 x double**]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %10
store i32 100, i32* %11
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %18
br label %20
20: ; preds = %52, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %17
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %53
25: ; preds = %20
%26 = load i32, i32* %17
switch i32 %26, label %44 [
i32 118, label %27
i32 115, label %28
i32 102, label %41
i32 104, label %43
]
27: ; preds = %25
store i32 1, i32* %9
br label %52
28: ; preds = %25
%29 = load i8*, i8** @optarg
%30 = call i64 @atoi(i8* %29)
store i64 %30, i64* %6
%31 = icmp ne i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = load i8*, i8** @optarg
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28
%39 = load i64, i64* %6
%40 = trunc i64 %39 to i32
store i32 %40, i32* %11
store i32 %40, i32* %10
br label %52
41: ; preds = %25
%42 = load i8*, i8** @optarg
store i8* %42, i8** %18
store i32 1, i32* %8
br label %52
43: ; preds = %25
br label %44
44: ; preds = %25, %43
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %41, %38, %27
br label %20
53: ; preds = %20
%54 = load i32, i32* %10
%55 = sub i32 %54, 1
store i32 %55, i32* %12
%56 = load i32, i32* %11
%57 = sub i32 %56, 1
store i32 %57, i32* %13
%58 = load i32, i32* %9
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %70
60: ; preds = %53
%61 = load i32, i32* @stdout
%62 = load i32, i32* %10
%63 = load i32, i32* %11
%64 = mul i32 %62, %63
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %64, i32 %65, i32 %66)
%68 = load i32, i32* @stdout
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 1000)
br label %70
70: ; preds = %60, %53
%71 = load i32, i32* %9
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %80
73: ; preds = %70
%74 = load i32, i32* %8
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = load i32, i32* @stdout
%78 = load i8*, i8** %18
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %76, %73, %70
%81 = load i32, i32* %10
%82 = load i32, i32* %11
%83 = call double** @make2DDoubleArray(i32 %81, i32 %82)
%84 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 0
store double** %83, double*** %84
%85 = load i32, i32* %10
%86 = load i32, i32* %11
%87 = call double** @make2DDoubleArray(i32 %85, i32 %86)
%88 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 1
store double** %87, double*** %88
%89 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 0
%90 = load double**, double*** %89
%91 = load i32, i32* %10
%92 = load i32, i32* %11
%93 = call i32 @initializeArray(double** %90, i32 %91, i32 %92)
%94 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 0
%95 = load double**, double*** %94
%96 = load i32, i32* %10
%97 = load i32, i32* %11
%98 = call i32 @setupBoundaryConditions(double** %95, i32 %96, i32 %97)
%99 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 1
%100 = load double**, double*** %99
%101 = load i32, i32* %10
%102 = load i32, i32* %11
%103 = call i32 @setupBoundaryConditions(double** %100, i32 %101, i32 %102)
store i32 0, i32* %16
store i64 0, i64* %7
br label %104
104: ; preds = %122, %80
%105 = load i64, i64* %7
%106 = icmp slt i64 %105, 1000
br i1 %106, label %107, label %125
107: ; preds = %104
%108 = load i32, i32* %12
%109 = load i32, i32* %13
%110 = load i32, i32* %16
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 %111
%113 = load double**, double*** %112
%114 = load i32, i32* %16
%115 = sub nsw i32 1, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 %116
%118 = load double**, double*** %117
%119 = call i32 @update(i32 %108, i32 %109, double** %113, double** %118)
%120 = load i32, i32* %16
%121 = sub nsw i32 1, %120
store i32 %121, i32* %16
br label %122
122: ; preds = %107
%123 = load i64, i64* %7
%124 = add nsw i64 %123, 1
store i64 %124, i64* %7
br label %104
125: ; preds = %104
%126 = load i32, i32* %8
%127 = icmp ne i32 %126, 0
br i1 %127, label %128, label %137
128: ; preds = %125
%129 = load i32, i32* %16
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 %130
%132 = load double**, double*** %131
%133 = load i32, i32* %10
%134 = load i32, i32* %11
%135 = load i8*, i8** %18
%136 = call i32 @save(double** %132, i32 %133, i32 %134, i8* %135)
br label %137
137: ; preds = %128, %125
%138 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 0
%139 = load double**, double*** %138
%140 = load i32, i32* %10
%141 = call i32 @free2DDoubleArray(double** %139, i32 %140)
%142 = getelementptr inbounds [2 x double**], [2 x double**]* %19, i64 0, i64 1
%143 = load double**, double*** %142
%144 = load i32, i32* %10
%145 = call i32 @free2DDoubleArray(double** %143, i32 %144)
%146 = load i32, i32* %9
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %165
148: ; preds = %137
%149 = load i32, i32* @stdout
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 1000)
%151 = load i32, i32* @stdout
%152 = load i32, i32* %11
%153 = load i32, i32* %10
%154 = mul i32 %152, %153
%155 = load i32, i32* %10
%156 = load i32, i32* %11
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %154, i32 %155, i32 %156)
%158 = load i32, i32* %8
%159 = icmp ne i32 %158, 0
br i1 %159, label %160, label %164
160: ; preds = %148
%161 = load i32, i32* @stdout
%162 = load i8*, i8** %18
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %161, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %162)
br label %164
164: ; preds = %160, %148
br label %165
165: ; preds = %164, %137
%166 = load i32, i32* @EXIT_SUCCESS
%167 = call i32 @exit(i32 %166)
unreachable
}

LLVM IR (-O2):
@.str = [7 x i8] c"hvs:f:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [24 x i8] c"Cannot parse %s value.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"Usage: %s [-s SIZE] [-f output file]\0A\00"
@stdout = global i32 0
@.str.3 = [39 x i8] c"[INFO] Setting map size to %d (%dx%d)\0A\00"
@.str.4 = [20 x i8] c"[INFO] Max iter %d\0A\00"
@.str.5 = [29 x i8] c"[INFO] Using output file %s\0A\00"
@.str.6 = [35 x i8] c"[INFO] Convergence after %d steps\0A\00"
@.str.7 = [32 x i8] c"[INFO] Problem size %d [%dx%d]\0A\00"
@.str.8 = [24 x i8] c"[INFO] Output file %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x double**]
br label %4
4: ; preds = %26, %2
%5 = phi i32 [ %27, %26 ], [ 100, %2 ]
%6 = phi i32 [ %10, %26 ], [ 0, %2 ]
%7 = phi i32 [ %14, %26 ], [ 0, %2 ]
%8 = phi i8* [ %15, %26 ], [ null, %2 ]
br label %9
9: ; preds = %13, %4
%10 = phi i32 [ %6, %4 ], [ 1, %13 ]
%11 = phi i32 [ %7, %4 ], [ %14, %13 ]
%12 = phi i8* [ %8, %4 ], [ %15, %13 ]
br label %13
13: ; preds = %9, %28
%14 = phi i32 [ 1, %28 ], [ %11, %9 ]
%15 = phi i8* [ %29, %28 ], [ %12, %9 ]
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %16, label %30 [
i32 -1, label %36
i32 118, label %9
i32 115, label %17
i32 102, label %28
]
17: ; preds = %13
%18 = load i8*, i8** @optarg
%19 = tail call i64 @atoi(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %17
%27 = trunc i64 %19 to i32
br label %4
28: ; preds = %13
%29 = load i8*, i8** @optarg
br label %13
30: ; preds = %13
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %1
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %13
%37 = add i32 %5, -1
%38 = add i32 %5, -1
%39 = icmp eq i32 %10, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = icmp ne i32 %14, 0
br label %52
42: ; preds = %36
%43 = load i32, i32* @stdout
%44 = mul i32 %5, %5
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %5, i32 %5)
%46 = load i32, i32* @stdout
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 1000)
%48 = icmp eq i32 %14, 0
br i1 %48, label %52, label %49
49: ; preds = %42
%50 = load i32, i32* @stdout
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %15)
br label %52
52: ; preds = %40, %49, %42
%53 = phi i1 [ %41, %40 ], [ true, %49 ], [ false, %42 ]
%54 = bitcast [2 x double**]* %3 to i8*
%55 = tail call double** @make2DDoubleArray(i32 %5, i32 %5)
%56 = getelementptr inbounds [2 x double**], [2 x double**]* %3, i64 0, i64 0
store double** %55, double*** %56
%57 = tail call double** @make2DDoubleArray(i32 %5, i32 %5)
%58 = getelementptr inbounds [2 x double**], [2 x double**]* %3, i64 0, i64 1
store double** %57, double*** %58
%59 = tail call i32 @initializeArray(double** %55, i32 %5, i32 %5)
%60 = tail call i32 @setupBoundaryConditions(double** %55, i32 %5, i32 %5)
%61 = tail call i32 @setupBoundaryConditions(double** %57, i32 %5, i32 %5)
br label %62
62: ; preds = %52, %62
%63 = phi double** [ %55, %52 ], [ %69, %62 ]
%64 = phi i64 [ 0, %52 ], [ %71, %62 ]
%65 = phi i32 [ 0, %52 ], [ %66, %62 ]
%66 = sub nsw i32 1, %65
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds [2 x double**], [2 x double**]* %3, i64 0, i64 %67
%69 = load double**, double*** %68
%70 = tail call i32 @update(i32 %37, i32 %38, double** %63, double** %69)
%71 = add nuw nsw i64 %64, 1
%72 = icmp eq i64 %71, 1000
br i1 %72, label %73, label %62
73: ; preds = %62
br i1 %53, label %74, label %76
74: ; preds = %73
%75 = tail call i32 @save(double** %69, i32 %5, i32 %5, i8* %15)
br label %76
76: ; preds = %74, %73
%77 = tail call i32 @free2DDoubleArray(double** %55, i32 %5)
%78 = tail call i32 @free2DDoubleArray(double** %57, i32 %5)
br i1 %39, label %88, label %79
79: ; preds = %76
%80 = load i32, i32* @stdout
%81 = tail call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 1000)
%82 = load i32, i32* @stdout
%83 = mul i32 %5, %5
%84 = tail call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %83, i32 %5, i32 %5)
br i1 %53, label %85, label %88
85: ; preds = %79
%86 = load i32, i32* @stdout
%87 = tail call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %15)
br label %88
88: ; preds = %79, %85, %76
%89 = load i32, i32* @EXIT_SUCCESS
%90 = tail call i32 @exit(i32 %89)
unreachable
}