#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*/ abort();
int /*<<< orphan*/ allocate_matrix(double ***, int, int);
int /*<<< orphan*/ compute_f_g(double **, double **, double **, double **,
                               double **, double, int, int, double, double,
                               double, double, double, double);
int /*<<< orphan*/ compute_rhs(double **, double **, double **, double, double,
                               double, int, int);
int /*<<< orphan*/ correct_velocities(double **, double **, double **,
                                      double **, double **, int, int, double,
                                      double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free_matrix(double ***, int);
int /*<<< orphan*/ free_memory(double **, double **, double **, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(int);
double max_residual_norm(double **, double **, double **, int, int, double,
                         double);
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read_file(char *, double *, double *, double *, double *,
                             int *, double *, double *, double *, double *,
                             double *, double *, int *, int *, int *, int *,
                             double *, double *, int *, int *, double ***,
                             double ***, double ***);
double select_time_step(double, double, double, double, int, int, double **,
                        double **);
int /*<<< orphan*/ set_boundary_conditions(int, int, int, int, double **,
                                           double **, double **, int, int);
int /*<<< orphan*/ sor_cycle(double **, double **, double, int, int, double,
                             double);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ write_file(char *, double *, double *, double *, double *,
                              int *, double *, double *, double *, double *,
                              double *, double *, int *, int *, int *, int *,
                              double *, double *, int *, int *, double ***,
                              double ***, double ***);
int main(int argc, char **argv) {
  double t, t_file, t_end, tau;
  int itermax;
  double epsilon, omega, gamma;
  double gx, gy, re;
  int w_left, w_right, w_top, w_bottom;
  double dx, dy;
  int nx, ny;
  double **P, **U, **V;
  double **F, **G, **RHS, **RES;
  double dt = 0.0;
  double res;
  long n = 0;
  int it = 0;
  int nfile = 0;
  double t_file_elapsed = 0.0;
  char filename[50];
  char *simulation_id;
  char *dot;
  int c;
  while ((c = getopt(argc, argv, "hv")) != -1)
    switch (c) {
    case 'h':
      printf("usage: %s [OPTIONS] FILENAME\n"
             "where FILENAME is a valid input file.\n"
             "-h\tDisplay help\n"
             "-v\tDisplay version information\n",
             argv[0]);
      return 0;
      break;
    case 'v':
      printf("%s: A Navier Stokes solver in 2D using finite differences, "
             "version %.1f\n"
             "Written by Anders Damsgaard, "
             "https://github.com/anders-dc/ns2dfd\n",
             argv[0], 0.1);
      return 0;
      break;
    case '?':
      if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c`.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x`.\n", optopt);
      return 1;
    default:
      abort();
    }
  if (optind == argc - 1) {
    read_file(argv[optind], &t, &t_end, &t_file, &tau, &itermax, &epsilon,
              &omega, &gamma, &gx, &gy, &re, &w_left, &w_right, &w_top,
              &w_bottom, &dx, &dy, &nx, &ny, &P, &U, &V);
  } else {
    fprintf(stderr, "%s: no input file specified.\n", argv[0]);
    return 1;
  }
  simulation_id = argv[optind];
  dot = strchr(simulation_id, '.');
  dot[0] = '\0';
  printf("%s: simulation id: `%s`\n", argv[0], simulation_id);
  allocate_matrix(&F, nx + 2, ny + 2);
  allocate_matrix(&G, nx + 2, ny + 2);
  allocate_matrix(&RHS, nx + 2, ny + 2);
  allocate_matrix(&RES, nx + 2, ny + 2);
  while (t <= t_end + dt) {
    dt = select_time_step(tau, re, dx, dy, nx, ny, U, V);
    if (t_file_elapsed >= t_file || n == 0) {
      sprintf(filename, "%s%05d.dat", simulation_id, nfile);
      write_file(filename, &t, &t_end, &t_file, &tau, &itermax, &epsilon,
                 &omega, &gamma, &gx, &gy, &re, &w_left, &w_right, &w_top,
                 &w_bottom, &dx, &dy, &nx, &ny, &P, &U, &V);
      t_file_elapsed = 0.0;
      nfile++;
    }
    printf("t = %f/%.2f s, dt = %f s, it = %d, last output: %d\n", t, t_end, dt,
           it, nfile - 1);
    set_boundary_conditions(w_left, w_right, w_top, w_bottom, P, U, V, nx, ny);
    compute_f_g(F, G, U, V, P, re, nx, ny, dx, dy, gx, gy, dt, gamma);
    compute_rhs(RHS, F, G, dt, dx, dy, nx, ny);
    it = 0;
    res = 1.0e9;
    while ((it <= itermax) && (res >= epsilon)) {
      sor_cycle(P, RHS, omega, nx, ny, dx, dy);
      res = max_residual_norm(RES, P, RHS, nx, ny, dx, dy);
      it++;
    }
    correct_velocities(U, V, F, G, P, nx, ny, dt, dx, dy);
    t += dt;
    n++;
    t_file_elapsed += dt;
  }
  puts("\n");
  free_memory(P, U, V, nx);
  free_matrix(&F, nx + 2);
  free_matrix(&G, nx + 2);
  free_matrix(&RHS, nx + 2);
  free_matrix(&RES, nx + 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x278,%rsp
movl   $0x0,-0x2c(%rbp)
mov    %edi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movq   $0x0,-0x108(%rbp)
movl   $0x0,-0x10c(%rbp)
movl   $0x0,-0x110(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
mov    -0x30(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    0xd6b(%rip),%rdx
call   1130 <getopt@plt>
mov    %eax,-0x164(%rbp)
cmp    $0xffffffff,%eax
je     13b4 <main+0x174>
mov    -0x164(%rbp),%eax
mov    %eax,-0x168(%rbp)
sub    $0x3f,%eax
je     1345 <main+0x105>
jmp    12d3 <main+0x93>
mov    -0x168(%rbp),%eax
sub    $0x68,%eax
je     12fb <main+0xbb>
jmp    12e7 <main+0xa7>
mov    -0x168(%rbp),%eax
sub    $0x76,%eax
je     131c <main+0xdc>
jmp    13ad <main+0x16d>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    1b88 <main+0x948>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
lea    0xd5c(%rip),%rdi
movsd  0xcd6(%rip),%xmm0
mov    $0x1,%al
call   10a0 <printf@plt>
movl   $0x0,-0x2c(%rbp)
jmp    1b88 <main+0x948>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
call   1120 <isprint@plt>
cmp    $0x0,%eax
je     1381 <main+0x141>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
mov    0x2c7c(%rip),%rax
mov    (%rax),%edx
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
jmp    13a1 <main+0x161>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
mov    0x2c57(%rip),%rax
mov    (%rax),%edx
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1b88 <main+0x948>
mov    $0x0,%al
call   1040 <abort@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1549 <main+0x309>
mov    -0x38(%rbp),%rax
mov    0x2c0a(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x58(%rbp),%r8
lea    -0x5c(%rbp),%r9
lea    -0x68(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
lea    -0x78(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
lea    -0x88(%rbp),%rax
mov    %rax,-0x198(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x190(%rbp)
lea    -0x94(%rbp),%rax
mov    %rax,-0x188(%rbp)
lea    -0x98(%rbp),%rax
mov    %rax,-0x180(%rbp)
lea    -0x9c(%rbp),%rax
mov    %rax,-0x178(%rbp)
lea    -0xa0(%rbp),%r13
lea    -0xa8(%rbp),%r12
lea    -0xb0(%rbp),%r15
lea    -0xb4(%rbp),%r14
lea    -0xb8(%rbp),%rbx
lea    -0xc0(%rbp),%r11
lea    -0xc8(%rbp),%r10
lea    -0xd0(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x1b8(%rbp),%rax
mov    %rax,(%rsp)
mov    -0x1b0(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0x1a8(%rbp),%rax
mov    %rax,0x10(%rsp)
mov    -0x1a0(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    -0x198(%rbp),%rax
mov    %rax,0x20(%rsp)
mov    -0x190(%rbp),%rax
mov    %rax,0x28(%rsp)
mov    -0x188(%rbp),%rax
mov    %rax,0x30(%rsp)
mov    -0x180(%rbp),%rax
mov    %rax,0x38(%rsp)
mov    -0x178(%rbp),%rax
mov    %rax,0x40(%rsp)
mov    -0x170(%rbp),%rax
mov    %r13,0x48(%rsp)
mov    %r12,0x50(%rsp)
mov    %r15,0x58(%rsp)
mov    %r14,0x60(%rsp)
mov    %rbx,0x68(%rsp)
mov    %r11,0x70(%rsp)
mov    %r10,0x78(%rsp)
mov    %rax,0x80(%rsp)
call   10f0 <read_file@plt>
jmp    1573 <main+0x333>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xbe9(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1b88 <main+0x948>
mov    -0x38(%rbp),%rax
mov    0x2a62(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rdi
mov    $0x2e,%esi
call   1090 <strchr@plt>
mov    %rax,-0x160(%rbp)
mov    -0x160(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
mov    -0x158(%rbp),%rdx
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
mov    -0xb8(%rbp),%edx
add    $0x2,%edx
lea    -0xd8(%rbp),%rdi
call   1100 <allocate_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
mov    -0xb8(%rbp),%edx
add    $0x2,%edx
lea    -0xe0(%rbp),%rdi
call   1100 <allocate_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
mov    -0xb8(%rbp),%edx
add    $0x2,%edx
lea    -0xe8(%rbp),%rdi
call   1100 <allocate_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
mov    -0xb8(%rbp),%edx
add    $0x2,%edx
lea    -0xf0(%rbp),%rdi
call   1100 <allocate_matrix@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  -0xf8(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jb     1b01 <main+0x8c1>
movsd  -0x58(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movsd  -0xb0(%rbp),%xmm3
ff
mov    -0xb4(%rbp),%edi
mov    -0xb8(%rbp),%esi
mov    -0xc8(%rbp),%rdx
mov    -0xd0(%rbp),%rcx
call   1050 <select_time_step@plt>
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x118(%rbp),%xmm0
ff
ucomisd -0x48(%rbp),%xmm0
jae    16c3 <main+0x483>
cmpq   $0x0,-0x108(%rbp)
jne    186b <main+0x62b>
lea    -0x150(%rbp),%rdi
mov    -0x158(%rbp),%rdx
mov    -0x110(%rbp),%ecx
lea    0xaa2(%rip),%rsi
call   1150 <sprintf@plt>
lea    -0x150(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x58(%rbp),%r8
lea    -0x5c(%rbp),%r9
lea    -0x68(%rbp),%rax
mov    %rax,-0x208(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x200(%rbp)
lea    -0x78(%rbp),%rax
mov    %rax,-0x1f8(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x1f0(%rbp)
lea    -0x88(%rbp),%rax
mov    %rax,-0x1e8(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
lea    -0x94(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
lea    -0x98(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
lea    -0x9c(%rbp),%rax
mov    %rax,-0x1c8(%rbp)
lea    -0xa0(%rbp),%r13
lea    -0xa8(%rbp),%r12
lea    -0xb0(%rbp),%r15
lea    -0xb4(%rbp),%r14
lea    -0xb8(%rbp),%rbx
lea    -0xc0(%rbp),%r11
lea    -0xc8(%rbp),%r10
lea    -0xd0(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
mov    -0x208(%rbp),%rax
mov    %rax,(%rsp)
mov    -0x200(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    -0x1f8(%rbp),%rax
mov    %rax,0x10(%rsp)
mov    -0x1f0(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    -0x1e8(%rbp),%rax
mov    %rax,0x20(%rsp)
mov    -0x1e0(%rbp),%rax
mov    %rax,0x28(%rsp)
mov    -0x1d8(%rbp),%rax
mov    %rax,0x30(%rsp)
mov    -0x1d0(%rbp),%rax
mov    %rax,0x38(%rsp)
mov    -0x1c8(%rbp),%rax
mov    %rax,0x40(%rsp)
mov    -0x1c0(%rbp),%rax
mov    %r13,0x48(%rsp)
mov    %r12,0x50(%rsp)
mov    %r15,0x58(%rsp)
mov    %r14,0x60(%rsp)
mov    %rbx,0x68(%rsp)
mov    %r11,0x70(%rsp)
mov    %r10,0x78(%rsp)
mov    %rax,0x80(%rsp)
call   10b0 <write_file@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x118(%rbp)
ff
mov    -0x110(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x110(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0xf8(%rbp),%xmm2
ff
mov    -0x10c(%rbp),%esi
mov    -0x110(%rbp),%edx
sub    $0x1,%edx
lea    0x8f8(%rip),%rdi
mov    $0x3,%al
call   10a0 <printf@plt>
mov    -0x94(%rbp),%edi
mov    -0x98(%rbp),%esi
mov    -0x9c(%rbp),%edx
mov    -0xa0(%rbp),%ecx
mov    -0xc0(%rbp),%r8
mov    -0xc8(%rbp),%r9
mov    -0xd0(%rbp),%r11
mov    -0xb4(%rbp),%r10d
mov    -0xb8(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   10c0 <set_boundary_conditions@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0xc8(%rbp),%rdx
mov    -0xd0(%rbp),%rcx
mov    -0xc0(%rbp),%r8
movsd  -0x90(%rbp),%xmm0
ff
mov    -0xb4(%rbp),%r9d
mov    -0xb8(%rbp),%eax
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movsd  -0x80(%rbp),%xmm3
movsd  -0x88(%rbp),%xmm4
ff
movsd  -0xf8(%rbp),%xmm5
ff
movsd  -0x78(%rbp),%xmm6
mov    %eax,(%rsp)
call   1030 <compute_f_g@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
mov    -0xe0(%rbp),%rdx
movsd  -0xf8(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
mov    -0xb4(%rbp),%ecx
mov    -0xb8(%rbp),%r8d
call   1070 <compute_rhs@plt>
movl   $0x0,-0x10c(%rbp)
movsd  0x65f(%rip),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
mov    -0x10c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x5c(%rbp),%ecx
mov    %al,-0x209(%rbp)
jg     19d6 <main+0x796>
movsd  -0x100(%rbp),%xmm0
ff
ucomisd -0x68(%rbp),%xmm0
setae  %al
mov    %al,-0x209(%rbp)
mov    -0x209(%rbp),%al
test   $0x1,%al
jne    19e9 <main+0x7a9>
jmp    1a70 <main+0x830>
mov    -0xc0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
movsd  -0x70(%rbp),%xmm0
mov    -0xb4(%rbp),%edx
mov    -0xb8(%rbp),%ecx
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
call   1140 <sor_cycle@plt>
mov    -0xf0(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    -0xe8(%rbp),%rdx
mov    -0xb4(%rbp),%ecx
mov    -0xb8(%rbp),%r8d
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0xb0(%rbp),%xmm1
ff
call   10d0 <max_residual_norm@plt>
movsd  %xmm0,-0x100(%rbp)
ff
mov    -0x10c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10c(%rbp)
jmp    19a9 <main+0x769>
mov    -0xc8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    -0xd8(%rbp),%rdx
mov    -0xe0(%rbp),%rcx
mov    -0xc0(%rbp),%r8
mov    -0xb4(%rbp),%r9d
mov    -0xb8(%rbp),%eax
movsd  -0xf8(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
mov    %eax,(%rsp)
call   1110 <correct_velocities@plt>
movsd  -0xf8(%rbp),%xmm0
ff
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x108(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x108(%rbp)
movsd  -0xf8(%rbp),%xmm0
ff
addsd  -0x118(%rbp),%xmm0
ff
movsd  %xmm0,-0x118(%rbp)
ff
jmp    1642 <main+0x402>
lea    0x61d(%rip),%rdi
call   1060 <puts@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
mov    -0xd0(%rbp),%rdx
mov    -0xb4(%rbp),%ecx
call   1160 <free_memory@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
lea    -0xd8(%rbp),%rdi
call   1080 <free_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
lea    -0xe0(%rbp),%rdi
call   1080 <free_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
lea    -0xe8(%rbp),%rdi
call   1080 <free_matrix@plt>
mov    -0xb4(%rbp),%esi
add    $0x2,%esi
lea    -0xf0(%rbp),%rdi
call   1080 <free_matrix@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x278,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdb3(%rip),%rdx
call   1130 <getopt@plt>
cmp    $0x67,%eax
jg     12a2 <main+0x62>
cmp    $0xffffffff,%eax
je     12cc <main+0x8c>
cmp    $0x3f,%eax
jne    189b <main+0x65b>
mov    0x2d6c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1120 <isprint@plt>
mov    0x2d44(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     14f6 <main+0x2b6>
lea    0xe73(%rip),%rsi
jmp    14fd <main+0x2bd>
cmp    $0x76,%eax
je     14bd <main+0x27d>
cmp    $0x68,%eax
jne    189b <main+0x65b>
mov    (%rbx),%rsi
lea    0xd55(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    150b <main+0x2cb>
mov    0x2d0d(%rip),%rax
movslq (%rax),%rax
add    $0xffffffff,%ebp
cmp    %ebp,%eax
jne    14da <main+0x29a>
mov    (%rbx,%rax,8),%rdi
sub    $0x8,%rsp
lea    0x38(%rsp),%rax
lea    0x40(%rsp),%rbp
lea    0x18(%rsp),%r10
lea    0x14(%rsp),%r11
lea    0x10(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0x28(%rsp),%r13
lea    0x58(%rsp),%r14
lea    0x50(%rsp),%rsi
lea    0x80(%rsp),%rdx
lea    0xd0(%rsp),%rcx
lea    0xc8(%rsp),%r8
lea    0x34(%rsp),%r9
push   %rax
push   %rbp
push   %r10
push   %r11
push   %r15
push   %r12
push   %r13
push   %r14
lea    0x9c(%rsp),%rax
push   %rax
lea    0xa8(%rsp),%rax
push   %rax
lea    0xb4(%rsp),%rax
push   %rax
lea    0xe8(%rsp),%rax
push   %rax
lea    0x108(%rsp),%rax
push   %rax
lea    0x118(%rsp),%rax
push   %rax
lea    0x128(%rsp),%rax
push   %rax
lea    0x138(%rsp),%rax
push   %rax
lea    0x118(%rsp),%rax
push   %rax
call   10f0 <read_file@plt>
add    $0x90,%rsp
mov    0x2c3b(%rip),%rax
movslq (%rax),%rax
mov    (%rbx,%rax,8),%r14
mov    %r14,%rdi
mov    $0x2e,%esi
call   1090 <strchr@plt>
movb   $0x0,(%rax)
mov    (%rbx),%rsi
lea    0xda1(%rip),%rdi
xor    %r15d,%r15d
mov    %r14,%rdx
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
mov    0xc(%rsp),%edx
add    $0x2,%edx
lea    0x70(%rsp),%rdi
call   1100 <allocate_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
mov    0xc(%rsp),%edx
add    $0x2,%edx
lea    0x68(%rsp),%rdi
call   1100 <allocate_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
mov    0xc(%rsp),%edx
add    $0x2,%edx
lea    0x60(%rsp),%rdi
call   1100 <allocate_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
mov    0xc(%rsp),%edx
add    $0x2,%edx
lea    0x98(%rsp),%rdi
call   1100 <allocate_matrix@plt>
xorpd  %xmm2,%xmm2
movsd  0x78(%rsp),%xmm0
addsd  %xmm2,%xmm0
ucomisd 0x48(%rsp),%xmm0
jae    151f <main+0x2df>
lea    0xcce(%rip),%rdi
call   1060 <puts@plt>
mov    0x10(%rsp),%rdi
mov    0x38(%rsp),%rsi
mov    0x30(%rsp),%rdx
mov    0x8(%rsp),%ecx
call   1160 <free_memory@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
lea    0x70(%rsp),%rdi
call   1080 <free_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
lea    0x68(%rsp),%rdi
call   1080 <free_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
lea    0x60(%rsp),%rdi
call   1080 <free_matrix@plt>
mov    0x8(%rsp),%esi
add    $0x2,%esi
lea    0x98(%rsp),%rdi
call   1080 <free_matrix@plt>
jmp    14d6 <main+0x296>
mov    (%rbx),%rsi
lea    0xbbf(%rip),%rdi
movsd  0xb31(%rip),%xmm0
mov    $0x1,%al
call   10a0 <printf@plt>
xor    %ebx,%ebx
jmp    150b <main+0x2cb>
mov    0x2aef(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc5c(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
jmp    1506 <main+0x2c6>
lea    0xc2a(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    15b1 <main+0x371>
nopl   0x0(%rax)
mov    0x38(%rsp),%rdi
mov    0x30(%rsp),%rsi
mov    0x70(%rsp),%rdx
mov    0x68(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9d
mov    0xc(%rsp),%eax
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
sub    $0x8,%rsp
movsd  0x48(%rsp),%xmm0
push   %rax
call   1110 <correct_velocities@plt>
add    $0x10,%rsp
movsd  0x48(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x48(%rsp)
add    $0x1,%rbp
movsd  0x80(%rsp),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
movsd  0x78(%rsp),%xmm1
addsd  %xmm3,%xmm1
ucomisd %xmm0,%xmm1
jb     1450 <main+0x210>
movsd  %xmm2,0x80(%rsp)
movsd  0xc0(%rsp),%xmm0
movsd  0x88(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x38(%rsp),%rdx
mov    0x30(%rsp),%rcx
call   1050 <select_time_step@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x80(%rsp),%xmm0
ucomisd 0xc8(%rsp),%xmm0
jae    1612 <main+0x3d2>
test   %rbp,%rbp
jne    16f9 <main+0x4b9>
lea    0xd0(%rsp),%rbx
mov    %rbx,%rdi
lea    0xb5c(%rip),%rsi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1150 <sprintf@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0x50(%rsp),%rsi
lea    0x80(%rsp),%rdx
lea    0xd0(%rsp),%rcx
lea    0xc8(%rsp),%r8
lea    0x34(%rsp),%r9
lea    0x38(%rsp),%rax
push   %rax
lea    0x48(%rsp),%rax
push   %rax
lea    0x28(%rsp),%rax
push   %rax
lea    0x2c(%rsp),%rax
push   %rax
lea    0x30(%rsp),%rax
push   %rax
lea    0x48(%rsp),%rax
push   %rax
lea    0x58(%rsp),%rax
push   %rax
lea    0x90(%rsp),%rax
push   %rax
lea    0x9c(%rsp),%rax
push   %rax
lea    0xa8(%rsp),%rax
push   %rax
lea    0xb4(%rsp),%rax
push   %rax
lea    0xe8(%rsp),%rax
push   %rax
lea    0x108(%rsp),%rax
push   %rax
lea    0x118(%rsp),%rax
push   %rax
lea    0x128(%rsp),%rax
push   %rax
lea    0x138(%rsp),%rax
push   %rax
lea    0x118(%rsp),%rax
push   %rax
call   10b0 <write_file@plt>
add    $0x90,%rsp
add    $0x1,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x80(%rsp)
movsd  0x48(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
lea    -0x1(%r15),%edx
lea    0xa7b(%rip),%rdi
movsd  0x40(%rsp),%xmm2
mov    %r13d,%esi
mov    $0x3,%al
call   10a0 <printf@plt>
mov    0x5c(%rsp),%edi
mov    0x58(%rsp),%esi
mov    0x54(%rsp),%edx
mov    0x50(%rsp),%ecx
mov    0x10(%rsp),%r8
mov    0x38(%rsp),%r9
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ebx
sub    $0x8,%rsp
push   %rbx
push   %rax
push   0x48(%rsp)
call   10c0 <set_boundary_conditions@plt>
add    $0x20,%rsp
mov    0x70(%rsp),%rdi
mov    0x68(%rsp),%rsi
mov    0x38(%rsp),%rdx
mov    0x30(%rsp),%rcx
mov    0x10(%rsp),%r8
movsd  0x88(%rsp),%xmm0
mov    0x8(%rsp),%r9d
mov    0xc(%rsp),%eax
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0xa8(%rsp),%xmm3
movsd  0xa0(%rsp),%xmm4
movsd  0xb0(%rsp),%xmm6
sub    $0x8,%rsp
movsd  0x48(%rsp),%xmm5
push   %rax
call   1030 <compute_f_g@plt>
add    $0x10,%rsp
mov    0x60(%rsp),%rdi
mov    0x70(%rsp),%rsi
mov    0x68(%rsp),%rdx
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
movsd  0x40(%rsp),%xmm0
call   1070 <compute_rhs@plt>
xor    %r13d,%r13d
cmpl   $0x0,0x2c(%rsp)
js     1530 <main+0x2f0>
movsd  0x808(%rip),%xmm0
ucomisd 0x90(%rsp),%xmm0
jb     1530 <main+0x2f0>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13d,%r12d
mov    0x10(%rsp),%rdi
mov    0x60(%rsp),%rsi
movsd  0xb8(%rsp),%xmm0
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1140 <sor_cycle@plt>
mov    0x98(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x60(%rsp),%rdx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   10d0 <max_residual_norm@plt>
lea    0x1(%r12),%r13d
cmp    0x2c(%rsp),%r12d
jge    1530 <main+0x2f0>
ucomisd 0x90(%rsp),%xmm0
jae    1820 <main+0x5e0>
jmp    1530 <main+0x2f0>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"hv\00"
@.str.1 = [115 x i8] c"usage: %s [OPTIONS] FILENAME\0Awhere FILENAME is a valid input file.\0A-h\09Display help\0A-v\09Display version information\0A\00"
@.str.2 = [138 x i8] c"%s: A Navier Stokes solver in 2D using finite differences, version %.1f\0AWritten by Anders Damsgaard, https://github.com/anders-dc/ns2dfd\0A\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown option `-%c`.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x`.\0A\00"
@optind = global i32 0
@.str.5 = [30 x i8] c"%s: no input file specified.\0A\00"
@.str.6 = [25 x i8] c"%s: simulation id: `%s`\0A\00"
@.str.7 = [11 x i8] c"%s%05d.dat\00"
@.str.8 = [52 x i8] c"t = %f/%.2f s, dt = %f s, it = %d, last output: %d\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double
%23 = alloca i32
%24 = alloca i32
%25 = alloca double**
%26 = alloca double**
%27 = alloca double**
%28 = alloca double**
%29 = alloca double**
%30 = alloca double**
%31 = alloca double**
%32 = alloca double
%33 = alloca double
%34 = alloca i64
%35 = alloca i32
%36 = alloca i32
%37 = alloca double
%38 = alloca [50 x i8]
%39 = alloca i8*
%40 = alloca i8*
%41 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %32
store i64 0, i64* %34
store i32 0, i32* %35
store i32 0, i32* %36
store double 0.000000e+00, double* %37
br label %42
42: ; preds = %2
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = call i32 @getopt(i32 %43, i8** %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %45, i32* %41
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %74
47: ; preds = %42
%48 = load i32, i32* %41
switch i32 %48, label %72 [
i32 104, label %49
i32 118, label %54
i32 63, label %59
]
49: ; preds = %47
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 0
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0), i8* %52)
store i32 0, i32* %3
br label %268
54: ; preds = %47
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i8* %57, double 1.000000e-01)
store i32 0, i32* %3
br label %268
59: ; preds = %47
%60 = load i32, i32* @optopt
%61 = call i32 @isprint(i32 %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = load i32, i32* @stderr
%65 = load i32, i32* @optopt
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %65)
br label %71
67: ; preds = %59
%68 = load i32, i32* @stderr
%69 = load i32, i32* @optopt
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %67, %63
store i32 1, i32* %3
br label %268
72: ; preds = %47
%73 = call i32 (...) @abort()
unreachable
74: ; preds = %42
%75 = load i32, i32* @optind
%76 = load i32, i32* %4
%77 = sub nsw i32 %76, 1
%78 = icmp eq i32 %75, %77
br i1 %78, label %79, label %86
79: ; preds = %74
%80 = load i8**, i8*** %5
%81 = load i32, i32* @optind
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 @read_file(i8* %84, double* %6, double* %8, double* %7, double* %9, i32* %10, double* %11, double* %12, double* %13, double* %14, double* %15, double* %16, i32* %17, i32* %18, i32* %19, i32* %20, double* %21, double* %22, i32* %23, i32* %24, double*** %25, double*** %26, double*** %27)
br label %92
86: ; preds = %74
%87 = load i32, i32* @stderr
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 0
%90 = load i8*, i8** %89
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %90)
store i32 1, i32* %3
br label %268
92: ; preds = %79
%93 = load i8**, i8*** %5
%94 = load i32, i32* @optind
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8*, i8** %93, i64 %95
%97 = load i8*, i8** %96
store i8* %97, i8** %39
%98 = load i8*, i8** %39
%99 = call i8* @strchr(i8* %98, i8 signext 46)
store i8* %99, i8** %40
%100 = load i8*, i8** %40
%101 = getelementptr inbounds i8, i8* %100, i64 0
store i8 0, i8* %101
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 0
%104 = load i8*, i8** %103
%105 = load i8*, i8** %39
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %104, i8* %105)
%107 = load i32, i32* %23
%108 = add nsw i32 %107, 2
%109 = load i32, i32* %24
%110 = add nsw i32 %109, 2
%111 = call i32 @allocate_matrix(double*** %28, i32 %108, i32 %110)
%112 = load i32, i32* %23
%113 = add nsw i32 %112, 2
%114 = load i32, i32* %24
%115 = add nsw i32 %114, 2
%116 = call i32 @allocate_matrix(double*** %29, i32 %113, i32 %115)
%117 = load i32, i32* %23
%118 = add nsw i32 %117, 2
%119 = load i32, i32* %24
%120 = add nsw i32 %119, 2
%121 = call i32 @allocate_matrix(double*** %30, i32 %118, i32 %120)
%122 = load i32, i32* %23
%123 = add nsw i32 %122, 2
%124 = load i32, i32* %24
%125 = add nsw i32 %124, 2
%126 = call i32 @allocate_matrix(double*** %31, i32 %123, i32 %125)
br label %127
127: ; preds = %229, %92
%128 = load double, double* %6
%129 = load double, double* %8
%130 = load double, double* %32
%131 = fadd double %129, %130
%132 = fcmp ole double %128, %131
br i1 %132, label %133, label %249
133: ; preds = %127
%134 = load double, double* %9
%135 = load double, double* %16
%136 = load double, double* %21
%137 = load double, double* %22
%138 = load i32, i32* %23
%139 = load i32, i32* %24
%140 = load double**, double*** %26
%141 = load double**, double*** %27
%142 = call double @select_time_step(double %134, double %135, double %136, double %137, i32 %138, i32 %139, double** %140, double** %141)
store double %142, double* %32
%143 = load double, double* %37
%144 = load double, double* %7
%145 = fcmp oge double %143, %144
br i1 %145, label %149, label %146
146: ; preds = %133
%147 = load i64, i64* %34
%148 = icmp eq i64 %147, 0
br i1 %148, label %149, label %158
149: ; preds = %146, %133
%150 = getelementptr inbounds [50 x i8], [50 x i8]* %38, i64 0, i64 0
%151 = load i8*, i8** %39
%152 = load i32, i32* %36
%153 = call i32 @sprintf(i8* %150, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %151, i32 %152)
%154 = getelementptr inbounds [50 x i8], [50 x i8]* %38, i64 0, i64 0
%155 = call i32 @write_file(i8* %154, double* %6, double* %8, double* %7, double* %9, i32* %10, double* %11, double* %12, double* %13, double* %14, double* %15, double* %16, i32* %17, i32* %18, i32* %19, i32* %20, double* %21, double* %22, i32* %23, i32* %24, double*** %25, double*** %26, double*** %27)
store double 0.000000e+00, double* %37
%156 = load i32, i32* %36
%157 = add nsw i32 %156, 1
store i32 %157, i32* %36
br label %158
158: ; preds = %149, %146
%159 = load double, double* %6
%160 = load double, double* %8
%161 = load double, double* %32
%162 = load i32, i32* %35
%163 = load i32, i32* %36
%164 = sub nsw i32 %163, 1
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), double %159, double %160, double %161, i32 %162, i32 %164)
%166 = load i32, i32* %17
%167 = load i32, i32* %18
%168 = load i32, i32* %19
%169 = load i32, i32* %20
%170 = load double**, double*** %25
%171 = load double**, double*** %26
%172 = load double**, double*** %27
%173 = load i32, i32* %23
%174 = load i32, i32* %24
%175 = call i32 @set_boundary_conditions(i32 %166, i32 %167, i32 %168, i32 %169, double** %170, double** %171, double** %172, i32 %173, i32 %174)
%176 = load double**, double*** %28
%177 = load double**, double*** %29
%178 = load double**, double*** %26
%179 = load double**, double*** %27
%180 = load double**, double*** %25
%181 = load double, double* %16
%182 = load i32, i32* %23
%183 = load i32, i32* %24
%184 = load double, double* %21
%185 = load double, double* %22
%186 = load double, double* %14
%187 = load double, double* %15
%188 = load double, double* %32
%189 = load double, double* %13
%190 = call i32 @compute_f_g(double** %176, double** %177, double** %178, double** %179, double** %180, double %181, i32 %182, i32 %183, double %184, double %185, double %186, double %187, double %188, double %189)
%191 = load double**, double*** %30
%192 = load double**, double*** %28
%193 = load double**, double*** %29
%194 = load double, double* %32
%195 = load double, double* %21
%196 = load double, double* %22
%197 = load i32, i32* %23
%198 = load i32, i32* %24
%199 = call i32 @compute_rhs(double** %191, double** %192, double** %193, double %194, double %195, double %196, i32 %197, i32 %198)
store i32 0, i32* %35
store double 1.000000e+09, double* %33
br label %200
200: ; preds = %210, %158
%201 = load i32, i32* %35
%202 = load i32, i32* %10
%203 = icmp sle i32 %201, %202
br i1 %203, label %204, label %208
204: ; preds = %200
%205 = load double, double* %33
%206 = load double, double* %11
%207 = fcmp oge double %205, %206
br label %208
208: ; preds = %204, %200
%209 = phi i1 [ false, %200 ], [ %207, %204 ]
br i1 %209, label %210, label %229
210: ; preds = %208
%211 = load double**, double*** %25
%212 = load double**, double*** %30
%213 = load double, double* %12
%214 = load i32, i32* %23
%215 = load i32, i32* %24
%216 = load double, double* %21
%217 = load double, double* %22
%218 = call i32 @sor_cycle(double** %211, double** %212, double %213, i32 %214, i32 %215, double %216, double %217)
%219 = load double**, double*** %31
%220 = load double**, double*** %25
%221 = load double**, double*** %30
%222 = load i32, i32* %23
%223 = load i32, i32* %24
%224 = load double, double* %21
%225 = load double, double* %22
%226 = call double @max_residual_norm(double** %219, double** %220, double** %221, i32 %222, i32 %223, double %224, double %225)
store double %226, double* %33
%227 = load i32, i32* %35
%228 = add nsw i32 %227, 1
store i32 %228, i32* %35
br label %200
229: ; preds = %208
%230 = load double**, double*** %26
%231 = load double**, double*** %27
%232 = load double**, double*** %28
%233 = load double**, double*** %29
%234 = load double**, double*** %25
%235 = load i32, i32* %23
%236 = load i32, i32* %24
%237 = load double, double* %32
%238 = load double, double* %21
%239 = load double, double* %22
%240 = call i32 @correct_velocities(double** %230, double** %231, double** %232, double** %233, double** %234, i32 %235, i32 %236, double %237, double %238, double %239)
%241 = load double, double* %32
%242 = load double, double* %6
%243 = fadd double %242, %241
store double %243, double* %6
%244 = load i64, i64* %34
%245 = add nsw i64 %244, 1
store i64 %245, i64* %34
%246 = load double, double* %32
%247 = load double, double* %37
%248 = fadd double %247, %246
store double %248, double* %37
br label %127
249: ; preds = %127
%250 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%251 = load double**, double*** %25
%252 = load double**, double*** %26
%253 = load double**, double*** %27
%254 = load i32, i32* %23
%255 = call i32 @free_memory(double** %251, double** %252, double** %253, i32 %254)
%256 = load i32, i32* %23
%257 = add nsw i32 %256, 2
%258 = call i32 @free_matrix(double*** %28, i32 %257)
%259 = load i32, i32* %23
%260 = add nsw i32 %259, 2
%261 = call i32 @free_matrix(double*** %29, i32 %260)
%262 = load i32, i32* %23
%263 = add nsw i32 %262, 2
%264 = call i32 @free_matrix(double*** %30, i32 %263)
%265 = load i32, i32* %23
%266 = add nsw i32 %265, 2
%267 = call i32 @free_matrix(double*** %31, i32 %266)
store i32 0, i32* %3
br label %268
268: ; preds = %249, %86, %71, %54, %49
%269 = load i32, i32* %3
ret i32 %269
}

LLVM IR (-O2):
@.str = [3 x i8] c"hv\00"
@.str.1 = [115 x i8] c"usage: %s [OPTIONS] FILENAME\0Awhere FILENAME is a valid input file.\0A-h\09Display help\0A-v\09Display version information\0A\00"
@.str.2 = [138 x i8] c"%s: A Navier Stokes solver in 2D using finite differences, version %.1f\0AWritten by Anders Damsgaard, https://github.com/anders-dc/ns2dfd\0A\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.3 = [23 x i8] c"Unknown option `-%c`.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x`.\0A\00"
@optind = global i32 0
@.str.5 = [30 x i8] c"%s: no input file specified.\0A\00"
@.str.6 = [25 x i8] c"%s: simulation id: `%s`\0A\00"
@.str.7 = [11 x i8] c"%s%05d.dat\00"
@.str.8 = [52 x i8] c"t = %f/%.2f s, dt = %f s, it = %d, last output: %d\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca i32
%21 = alloca i32
%22 = alloca double**
%23 = alloca double**
%24 = alloca double**
%25 = alloca double**
%26 = alloca double**
%27 = alloca double**
%28 = alloca double**
%29 = alloca [50 x i8]
%30 = bitcast double* %3 to i8*
%31 = bitcast double* %4 to i8*
%32 = bitcast double* %5 to i8*
%33 = bitcast double* %6 to i8*
%34 = bitcast i32* %7 to i8*
%35 = bitcast double* %8 to i8*
%36 = bitcast double* %9 to i8*
%37 = bitcast double* %10 to i8*
%38 = bitcast double* %11 to i8*
%39 = bitcast double* %12 to i8*
%40 = bitcast double* %13 to i8*
%41 = bitcast i32* %14 to i8*
%42 = bitcast i32* %15 to i8*
%43 = bitcast i32* %16 to i8*
%44 = bitcast i32* %17 to i8*
%45 = bitcast double* %18 to i8*
%46 = bitcast double* %19 to i8*
%47 = bitcast i32* %20 to i8*
%48 = bitcast i32* %21 to i8*
%49 = bitcast double*** %22 to i8*
%50 = bitcast double*** %23 to i8*
%51 = bitcast double*** %24 to i8*
%52 = bitcast double*** %25 to i8*
%53 = bitcast double*** %26 to i8*
%54 = bitcast double*** %27 to i8*
%55 = bitcast double*** %28 to i8*
%56 = getelementptr inbounds [50 x i8], [50 x i8]* %29, i64 0, i64 0
%57 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %57, label %73 [
i32 -1, label %75
i32 104, label %58
i32 118, label %61
i32 63, label %64
]
58: ; preds = %2
%59 = load i8*, i8** %1
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0), i8* %59)
br label %247
61: ; preds = %2
%62 = load i8*, i8** %1
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i8* %62, double 1.000000e-01)
br label %247
64: ; preds = %2
%65 = load i32, i32* @optopt
%66 = tail call i32 @isprint(i32 %65)
%67 = icmp eq i32 %66, 0
%68 = load i32, i32* @stderr
br i1 %67, label %71, label %69
69: ; preds = %64
%70 = tail call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %65)
br label %247
71: ; preds = %64
%72 = tail call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %65)
br label %247
73: ; preds = %2
%74 = tail call i32 (...) @abort()
unreachable
75: ; preds = %2
%76 = load i32, i32* @optind
%77 = add nsw i32 %0, -1
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %115
79: ; preds = %75
%80 = sext i32 %76 to i64
%81 = getelementptr inbounds i8*, i8** %1, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @read_file(i8* %82, double* %3, double* %5, double* %4, double* %6, i32* %7, double* %8, double* %9, double* %10, double* %11, double* %12, double* %13, i32* %14, i32* %15, i32* %16, i32* %17, double* %18, double* %19, i32* %20, i32* %21, double*** %22, double*** %23, double*** %24)
%84 = load i32, i32* @optind
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %1, i64 %85
%87 = load i8*, i8** %86
%88 = call i8* @strchr(i8* dereferenceable(1) %87, i8 signext 46)
store i8 0, i8* %88
%89 = load i8*, i8** %1
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %89, i8* %87)
%91 = load i32, i32* %20
%92 = add nsw i32 %91, 2
%93 = load i32, i32* %21
%94 = add nsw i32 %93, 2
%95 = call i32 @allocate_matrix(double*** %25, i32 %92, i32 %94)
%96 = load i32, i32* %20
%97 = add nsw i32 %96, 2
%98 = load i32, i32* %21
%99 = add nsw i32 %98, 2
%100 = call i32 @allocate_matrix(double*** %26, i32 %97, i32 %99)
%101 = load i32, i32* %20
%102 = add nsw i32 %101, 2
%103 = load i32, i32* %21
%104 = add nsw i32 %103, 2
%105 = call i32 @allocate_matrix(double*** %27, i32 %102, i32 %104)
%106 = load i32, i32* %20
%107 = add nsw i32 %106, 2
%108 = load i32, i32* %21
%109 = add nsw i32 %108, 2
%110 = call i32 @allocate_matrix(double*** %28, i32 %107, i32 %109)
%111 = load double, double* %3
%112 = load double, double* %5
%113 = fadd double %112, 0.000000e+00
%114 = fcmp ugt double %111, %113
br i1 %114, label %228, label %119
115: ; preds = %75
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %1
%118 = tail call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %117)
br label %247
119: ; preds = %79, %209
%120 = phi double [ %224, %209 ], [ 0.000000e+00, %79 ]
%121 = phi i32 [ %142, %209 ], [ 0, %79 ]
%122 = phi i32 [ %210, %209 ], [ 0, %79 ]
%123 = phi i64 [ %223, %209 ], [ 0, %79 ]
%124 = load double, double* %6
%125 = load double, double* %13
%126 = load double, double* %18
%127 = load double, double* %19
%128 = load i32, i32* %20
%129 = load i32, i32* %21
%130 = load double**, double*** %23
%131 = load double**, double*** %24
%132 = call double @select_time_step(double %124, double %125, double %126, double %127, i32 %128, i32 %129, double** %130, double** %131)
%133 = load double, double* %4
%134 = fcmp oge double %120, %133
%135 = icmp eq i64 %123, 0
%136 = select i1 %134, i1 true, i1 %135
br i1 %136, label %137, label %141
137: ; preds = %119
%138 = call i32 @sprintf(i8* %56, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* %87, i32 %121)
%139 = call i32 @write_file(i8* %56, double* %3, double* %5, double* %4, double* %6, i32* %7, double* %8, double* %9, double* %10, double* %11, double* %12, double* %13, i32* %14, i32* %15, i32* %16, i32* %17, double* %18, double* %19, i32* %20, i32* %21, double*** %22, double*** %23, double*** %24)
%140 = add nsw i32 %121, 1
br label %141
141: ; preds = %119, %137
%142 = phi i32 [ %140, %137 ], [ %121, %119 ]
%143 = phi double [ 0.000000e+00, %137 ], [ %120, %119 ]
%144 = load double, double* %3
%145 = load double, double* %5
%146 = add nsw i32 %142, -1
%147 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), double %144, double %145, double %132, i32 %122, i32 %146)
%148 = load i32, i32* %14
%149 = load i32, i32* %15
%150 = load i32, i32* %16
%151 = load i32, i32* %17
%152 = load double**, double*** %22
%153 = load double**, double*** %23
%154 = load double**, double*** %24
%155 = load i32, i32* %20
%156 = load i32, i32* %21
%157 = call i32 @set_boundary_conditions(i32 %148, i32 %149, i32 %150, i32 %151, double** %152, double** %153, double** %154, i32 %155, i32 %156)
%158 = load double**, double*** %25
%159 = load double**, double*** %26
%160 = load double**, double*** %23
%161 = load double**, double*** %24
%162 = load double**, double*** %22
%163 = load double, double* %13
%164 = load i32, i32* %20
%165 = load i32, i32* %21
%166 = load double, double* %18
%167 = load double, double* %19
%168 = load double, double* %11
%169 = load double, double* %12
%170 = load double, double* %10
%171 = call i32 @compute_f_g(double** %158, double** %159, double** %160, double** %161, double** %162, double %163, i32 %164, i32 %165, double %166, double %167, double %168, double %169, double %132, double %170)
%172 = load double**, double*** %27
%173 = load double**, double*** %25
%174 = load double**, double*** %26
%175 = load double, double* %18
%176 = load double, double* %19
%177 = load i32, i32* %20
%178 = load i32, i32* %21
%179 = call i32 @compute_rhs(double** %172, double** %173, double** %174, double %132, double %175, double %176, i32 %177, i32 %178)
%180 = load i32, i32* %7
%181 = icmp sgt i32 %180, -1
%182 = load double, double* %8
%183 = fcmp ole double %182, 1.000000e+09
%184 = select i1 %181, i1 %183, i1 false
br i1 %184, label %185, label %209
185: ; preds = %141, %185
%186 = phi i32 [ %203, %185 ], [ 0, %141 ]
%187 = load double**, double*** %22
%188 = load double**, double*** %27
%189 = load double, double* %9
%190 = load i32, i32* %20
%191 = load i32, i32* %21
%192 = load double, double* %18
%193 = load double, double* %19
%194 = call i32 @sor_cycle(double** %187, double** %188, double %189, i32 %190, i32 %191, double %192, double %193)
%195 = load double**, double*** %28
%196 = load double**, double*** %22
%197 = load double**, double*** %27
%198 = load i32, i32* %20
%199 = load i32, i32* %21
%200 = load double, double* %18
%201 = load double, double* %19
%202 = call double @max_residual_norm(double** %195, double** %196, double** %197, i32 %198, i32 %199, double %200, double %201)
%203 = add nuw nsw i32 %186, 1
%204 = load i32, i32* %7
%205 = icmp slt i32 %186, %204
%206 = load double, double* %8
%207 = fcmp oge double %202, %206
%208 = select i1 %205, i1 %207, i1 false
br i1 %208, label %185, label %209
209: ; preds = %185, %141
%210 = phi i32 [ 0, %141 ], [ %203, %185 ]
%211 = load double**, double*** %23
%212 = load double**, double*** %24
%213 = load double**, double*** %25
%214 = load double**, double*** %26
%215 = load double**, double*** %22
%216 = load i32, i32* %20
%217 = load i32, i32* %21
%218 = load double, double* %18
%219 = load double, double* %19
%220 = call i32 @correct_velocities(double** %211, double** %212, double** %213, double** %214, double** %215, i32 %216, i32 %217, double %132, double %218, double %219)
%221 = load double, double* %3
%222 = fadd double %132, %221
store double %222, double* %3
%223 = add nuw nsw i64 %123, 1
%224 = fadd double %132, %143
%225 = load double, double* %5
%226 = fadd double %132, %225
%227 = fcmp ugt double %222, %226
br i1 %227, label %228, label %119
228: ; preds = %209, %79
%229 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%230 = load double**, double*** %22
%231 = load double**, double*** %23
%232 = load double**, double*** %24
%233 = load i32, i32* %20
%234 = call i32 @free_memory(double** %230, double** %231, double** %232, i32 %233)
%235 = load i32, i32* %20
%236 = add nsw i32 %235, 2
%237 = call i32 @free_matrix(double*** %25, i32 %236)
%238 = load i32, i32* %20
%239 = add nsw i32 %238, 2
%240 = call i32 @free_matrix(double*** %26, i32 %239)
%241 = load i32, i32* %20
%242 = add nsw i32 %241, 2
%243 = call i32 @free_matrix(double*** %27, i32 %242)
%244 = load i32, i32* %20
%245 = add nsw i32 %244, 2
%246 = call i32 @free_matrix(double*** %28, i32 %245)
br label %247
247: ; preds = %69, %71, %228, %115, %61, %58
%248 = phi i32 [ 0, %61 ], [ 0, %58 ], [ 0, %228 ], [ 1, %115 ], [ 1, %71 ], [ 1, %69 ]
ret i32 %248
}