#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_BRANCH(double *, double *, double *, int, int,
                                         int, int, double, double, int);
void update_2D_BRANCH(double *phi_a, double *phi_b, double *u_buff, int iT,
                      int nX, int nY, int bc_phi, double delta_t, double alpha,
                      int scheme) {
  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_BRANCH(phi_old, phi_new, u_buff, iX, iY, nX, nY, delta_t,
                            alpha, scheme);
  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_BRANCH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%eax
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    1188 <update_2D_BRANCH+0x58>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1198 <update_2D_BRANCH+0x68>
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    121e <update_2D_BRANCH+0xee>
movl   $0x2,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    120b <update_2D_BRANCH+0xdb>
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),%r10d
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <update_cell_2D_BRANCH@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11b7 <update_2D_BRANCH+0x87>
jmp    1210 <update_2D_BRANCH+0xe0>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    119f <update_2D_BRANCH+0x6f>
cmpl   $0x1,0x10(%rbp)
jne    1241 <update_2D_BRANCH+0x111>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
call   1050 <Phi_2D_BC_1@plt>
jmp    1264 <update_2D_BRANCH+0x134>
cmpl   $0x2,0x10(%rbp)
jne    125f <update_2D_BRANCH+0x12f>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1,%ecx
call   1030 <Phi_2D_BC_2@plt>
jmp    1264 <update_2D_BRANCH+0x134>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_2D_BRANCH>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r13d
mov    %r8d,%ebx
mov    %rdi,%r8
test   $0x1,%cl
mov    %rsi,%rbp
cmove  %rdi,%rbp
mov    0x70(%rsp),%ecx
mov    %ecx,0x8(%rsp)
cmove  %rsi,%r8
cmp    $0x5,%ebx
jl     120e <update_2D_BRANCH+0xde>
mov    0x78(%rsp),%r12d
lea    -0x2(%rbx),%ecx
mov    %ecx,0xc(%rsp)
mov    $0x4,%esi
sub    %r13d,%esi
mov    $0x2,%r15d
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %r8,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdx,0x10(%rsp)
jmp    11ab <update_2D_BRANCH+0x7b>
nopl   (%rax)
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
je     120e <update_2D_BRANCH+0xde>
cmp    $0x5,%r13d
jl     11a0 <update_2D_BRANCH+0x70>
mov    $0x2,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r8,%rsi
mov    %r15d,%ecx
mov    %r14d,%r8d
mov    %ebx,%r9d
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
push   %r12
push   %r13
call   1040 <update_cell_2D_BRANCH@plt>
mov    0x28(%rsp),%rsi
mov    0x20(%rsp),%rdx
mov    0x30(%rsp),%r8
add    $0x10,%rsp
lea    (%rsi,%r14,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
mov    %ecx,%r14d
cmp    $0x2,%eax
jne    11c0 <update_2D_BRANCH+0x90>
jmp    11a0 <update_2D_BRANCH+0x70>
mov    0x8(%rsp),%ecx
cmp    $0x2,%ecx
je     123c <update_2D_BRANCH+0x10c>
cmp    $0x1,%ecx
jne    125c <update_2D_BRANCH+0x12c>
mov    %r8,%rdi
mov    %ebx,%esi
mov    %r13d,%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    %r8,%rdi
mov    %ebx,%esi
mov    %r13d,%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_BRANCH(double* %0, double* %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %6, double %7, double %8, i32 %9) {
%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 i32
%23 = alloca double*
%24 = alloca double*
store double* %0, double** %11
store double* %1, double** %12
store double* %2, double** %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store double %7, double* %18
store double %8, double* %19
store i32 %9, i32* %20
%25 = load i32, i32* %14
%26 = srem i32 %25, 2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %10
%29 = load double*, double** %11
store double* %29, double** %23
%30 = load double*, double** %12
store double* %30, double** %24
br label %34
31: ; preds = %10
%32 = load double*, double** %12
store double* %32, double** %23
%33 = load double*, double** %11
store double* %33, double** %24
br label %34
34: ; preds = %31, %28
store i32 2, i32* %21
br label %35
35: ; preds = %62, %34
%36 = load i32, i32* %21
%37 = load i32, i32* %15
%38 = sub nsw i32 %37, 2
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %65
40: ; preds = %35
store i32 2, i32* %22
br label %41
41: ; preds = %58, %40
%42 = load i32, i32* %22
%43 = load i32, i32* %16
%44 = sub nsw i32 %43, 2
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %61
46: ; preds = %41
%47 = load double*, double** %23
%48 = load double*, double** %24
%49 = load double*, double** %13
%50 = load i32, i32* %21
%51 = load i32, i32* %22
%52 = load i32, i32* %15
%53 = load i32, i32* %16
%54 = load double, double* %18
%55 = load double, double* %19
%56 = load i32, i32* %20
%57 = call i32 @update_cell_2D_BRANCH(double* %47, double* %48, double* %49, i32 %50, i32 %51, i32 %52, i32 %53, double %54, double %55, i32 %56)
br label %58
58: ; preds = %46
%59 = load i32, i32* %22
%60 = add nsw i32 %59, 1
store i32 %60, i32* %22
br label %41
61: ; preds = %41
br label %62
62: ; preds = %61
%63 = load i32, i32* %21
%64 = add nsw i32 %63, 1
store i32 %64, i32* %21
br label %35
65: ; preds = %35
%66 = load i32, i32* %17
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load double*, double** %24
%70 = load i32, i32* %15
%71 = load i32, i32* %16
%72 = call i32 @Phi_2D_BC_1(double* %69, i32 %70, i32 %71, i32 1)
br label %82
73: ; preds = %65
%74 = load i32, i32* %17
%75 = icmp eq i32 %74, 2
br i1 %75, label %76, label %81
76: ; preds = %73
%77 = load double*, double** %24
%78 = load i32, i32* %15
%79 = load i32, i32* %16
%80 = call i32 @Phi_2D_BC_2(double* %77, i32 %78, i32 %79, i32 1)
br label %81
81: ; preds = %76, %73
br label %82
82: ; preds = %81, %68
ret void
}

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