#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*/ Phi_2D_BC_1(double *, int, int, int);
int /*<<< orphan*/ Phi_2D_BC_2(double *, int, int, int);
int /*<<< orphan*/ update_cell_2D_quickest_a_lliffe(double **, double **,
                                                    double *, int, int, int,
                                                    int, double, double);
void update_2D_quickest_a_lliffe(double **phi_a, double **phi_b, double *u_buff,
                                 int iT, int nX, int nY, int bc_phi,
                                 double delta_t, double alpha) {
  int iX;
  int iY;
  double **phi_old;
  double **phi_new;
  if (iT % 2 == 0) {
    phi_old = phi_a;
    phi_new = phi_b;
  } else {
    phi_old = phi_b;
    phi_new = phi_a;
  }
#pragma omp parallel for private(iX, iY)
  for (iX = 2; iX < (nX - 2); iX++)
    for (iY = 2; iY < (nY - 2); iY++)
      update_cell_2D_quickest_a_lliffe(phi_old, phi_new, u_buff, iX, iY, nX, nY,
                                       delta_t, alpha);
  if (bc_phi == 1)
    Phi_2D_BC_1(*phi_new, nX, nY, 1.);
  else if (bc_phi == 2)
    Phi_2D_BC_2(*phi_new, nX, nY, 1.);
}


x86 assembly (clang, -O0):
<update_2D_quickest_a_lliffe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <update_2D_quickest_a_lliffe+0x55>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1195 <update_2D_quickest_a_lliffe+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x2,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1212 <update_2D_quickest_a_lliffe+0xe2>
movl   $0x2,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11ff <update_2D_quickest_a_lliffe+0xcf>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%eax
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    %eax,(%rsp)
call   1040 <update_cell_2D_quickest_a_lliffe@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11b4 <update_2D_quickest_a_lliffe+0x84>
jmp    1204 <update_2D_quickest_a_lliffe+0xd4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119c <update_2D_quickest_a_lliffe+0x6c>
cmpl   $0x1,0x10(%rbp)
jne    1238 <update_2D_quickest_a_lliffe+0x108>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
call   1050 <Phi_2D_BC_1@plt>
jmp    125e <update_2D_quickest_a_lliffe+0x12e>
cmpl   $0x2,0x10(%rbp)
jne    1259 <update_2D_quickest_a_lliffe+0x129>
mov    -0x50(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
call   1030 <Phi_2D_BC_2@plt>
jmp    125e <update_2D_quickest_a_lliffe+0x12e>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_2D_quickest_a_lliffe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r12d
mov    %r8d,%eax
mov    %rdi,%rbx
test   $0x1,%cl
mov    %rsi,%rbp
cmove  %rdi,%rbp
mov    0x70(%rsp),%ecx
mov    %ecx,0x10(%rsp)
cmove  %rsi,%rbx
cmp    $0x5,%r8d
jl     1208 <update_2D_quickest_a_lliffe+0xd8>
mov    %rdx,%r15
lea    -0x2(%rax),%ecx
mov    %ecx,0x14(%rsp)
mov    $0x4,%esi
sub    %r12d,%esi
mov    $0x2,%r13d
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rsi,0x18(%rsp)
jmp    11ab <update_2D_quickest_a_lliffe+0x7b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    0x14(%rsp),%r13d
je     1208 <update_2D_quickest_a_lliffe+0xd8>
cmp    $0x5,%r12d
jl     11a0 <update_2D_quickest_a_lliffe+0x70>
mov    $0x2,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r12d,(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r13d,%ecx
mov    %r14d,%r8d
mov    %eax,%r9d
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
call   1040 <update_cell_2D_quickest_a_lliffe@plt>
mov    0x18(%rsp),%rsi
lea    (%rsi,%r14,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
mov    %ecx,%r14d
cmp    $0x2,%eax
mov    0x20(%rsp),%rax
jne    11c0 <update_2D_quickest_a_lliffe+0x90>
jmp    11a0 <update_2D_quickest_a_lliffe+0x70>
mov    0x10(%rsp),%ecx
cmp    $0x2,%ecx
je     1236 <update_2D_quickest_a_lliffe+0x106>
cmp    $0x1,%ecx
jne    1256 <update_2D_quickest_a_lliffe+0x126>
mov    (%rbx),%rdi
mov    %eax,%esi
mov    %r12d,%edx
mov    $0x1,%ecx
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <Phi_2D_BC_1@plt>
mov    (%rbx),%rdi
mov    %eax,%esi
mov    %r12d,%edx
mov    $0x1,%ecx
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <Phi_2D_BC_2@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @update_2D_quickest_a_lliffe(double** %0, double** %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8) {
%10 = alloca double**
%11 = alloca double**
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
%21 = alloca double**
%22 = alloca double**
store double** %0, double*** %10
store double** %1, double*** %11
store double* %2, double** %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store double %7, double* %17
store double %8, double* %18
%23 = load i32, i32* %13
%24 = srem i32 %23, 2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %9
%27 = load double**, double*** %10
store double** %27, double*** %21
%28 = load double**, double*** %11
store double** %28, double*** %22
br label %32
29: ; preds = %9
%30 = load double**, double*** %11
store double** %30, double*** %21
%31 = load double**, double*** %10
store double** %31, double*** %22
br label %32
32: ; preds = %29, %26
store i32 2, i32* %19
br label %33
33: ; preds = %59, %32
%34 = load i32, i32* %19
%35 = load i32, i32* %14
%36 = sub nsw i32 %35, 2
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %62
38: ; preds = %33
store i32 2, i32* %20
br label %39
39: ; preds = %55, %38
%40 = load i32, i32* %20
%41 = load i32, i32* %15
%42 = sub nsw i32 %41, 2
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %58
44: ; preds = %39
%45 = load double**, double*** %21
%46 = load double**, double*** %22
%47 = load double*, double** %12
%48 = load i32, i32* %19
%49 = load i32, i32* %20
%50 = load i32, i32* %14
%51 = load i32, i32* %15
%52 = load double, double* %17
%53 = load double, double* %18
%54 = call i32 @update_cell_2D_quickest_a_lliffe(double** %45, double** %46, double* %47, i32 %48, i32 %49, i32 %50, i32 %51, double %52, double %53)
br label %55
55: ; preds = %44
%56 = load i32, i32* %20
%57 = add nsw i32 %56, 1
store i32 %57, i32* %20
br label %39
58: ; preds = %39
br label %59
59: ; preds = %58
%60 = load i32, i32* %19
%61 = add nsw i32 %60, 1
store i32 %61, i32* %19
br label %33
62: ; preds = %33
%63 = load i32, i32* %16
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load double**, double*** %22
%67 = load double*, double** %66
%68 = load i32, i32* %14
%69 = load i32, i32* %15
%70 = call i32 @Phi_2D_BC_1(double* %67, i32 %68, i32 %69, i32 1)
br label %81
71: ; preds = %62
%72 = load i32, i32* %16
%73 = icmp eq i32 %72, 2
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = load double**, double*** %22
%76 = load double*, double** %75
%77 = load i32, i32* %14
%78 = load i32, i32* %15
%79 = call i32 @Phi_2D_BC_2(double* %76, i32 %77, i32 %78, i32 1)
br label %80
80: ; preds = %74, %71
br label %81
81: ; preds = %80, %65
ret void
}

LLVM IR (-O2):
define void @update_2D_quickest_a_lliffe(double** %0, double** %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8) {
%10 = and i32 %3, 1
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, double** %0, double** %1
%13 = select i1 %11, double** %1, double** %0
%14 = add i32 %4, -2
%15 = icmp sgt i32 %4, 4
br i1 %15, label %16, label %29
16: ; preds = %9
%17 = add i32 %5, -2
%18 = icmp sgt i32 %5, 4
br label %19
19: ; preds = %16, %26
%20 = phi i32 [ 2, %16 ], [ %27, %26 ]
br i1 %18, label %21, label %26
21: ; preds = %19, %21
%22 = phi i32 [ %24, %21 ], [ 2, %19 ]
%23 = tail call i32 @update_cell_2D_quickest_a_lliffe(double** %12, double** %13, double* %2, i32 %20, i32 %22, i32 %4, i32 %5, double %7, double %8)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, %17
br i1 %25, label %26, label %21
26: ; preds = %21, %19
%27 = add nuw nsw i32 %20, 1
%28 = icmp eq i32 %27, %14
br i1 %28, label %29, label %19
29: ; preds = %26, %9
switch i32 %6, label %36 [
i32 1, label %30
i32 2, label %33
]
30: ; preds = %29
%31 = load double*, double** %13
%32 = tail call i32 @Phi_2D_BC_1(double* %31, i32 %4, i32 %5, i32 1)
br label %36
33: ; preds = %29
%34 = load double*, double** %13
%35 = tail call i32 @Phi_2D_BC_2(double* %34, i32 %4, i32 %5, i32 1)
br label %36
36: ; preds = %29, %33, %30
ret void
}