#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*/ read_face(int, int, int, int, int, int, int, double *,
                             double *);
void gather_fv_2D(double *sc_old, double *sc_fv, int iX, int iY, int nX, int nY,
                  double delta_t) {
  int tid;
  double sum_face = 0.;
  double sc_face;
  tid = iY * nX + iX;
  read_face(iX, iY, nX, nY, 0, 0, 0, &sc_face, sc_fv);
  sum_face += sc_face;
  read_face(iX, iY, nX, nY, -1, 0, 0, &sc_face, sc_fv);
  sum_face -= sc_face;
  read_face(iX, iY, nX, nY, 0, 0, 1, &sc_face, sc_fv);
  sum_face += sc_face;
  read_face(iX, iY, nX, nY, 0, -1, 1, &sc_face, sc_fv);
  sum_face -= sc_face;
  *(sc_old + tid) = *(sc_old + tid) + 1. * delta_t * sum_face;
}


x86 assembly (clang, -O0):
<gather_fv_2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
xor    %r9d,%r9d
lea    -0x40(%rbp),%r10
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <read_face@plt>
movsd  -0x40(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
lea    -0x40(%rbp),%r10
movl   $0x0,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <read_face@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
xor    %r9d,%r9d
lea    -0x40(%rbp),%r10
mov    %r9d,%r8d
movl   $0x1,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <read_face@plt>
movsd  -0x40(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
lea    -0x40(%rbp),%r10
movl   $0x1,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <read_face@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  0xd99(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gather_fv_2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
mov    %r9d,%r15d
mov    %r8d,%r13d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,0x18(%rsp)
mov    %r8d,%r14d
imul   %ecx,%r14d
add    %edx,%r14d
sub    $0x8,%rsp
lea    0x10(%rsp),%rax
mov    %edx,%edi
mov    %ecx,%esi
mov    %r8d,%edx
mov    %r9d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %r12
push   %rax
push   $0x0
call   1030 <read_face@plt>
add    $0x20,%rsp
xorpd  %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
push   %r12
lea    0x18(%rsp),%rax
push   %rax
push   $0x0
call   1030 <read_face@plt>
add    $0x20,%rsp
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %r12
lea    0x18(%rsp),%rax
push   %rax
push   $0x1
call   1030 <read_face@plt>
add    $0x20,%rsp
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
sub    $0x8,%rsp
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
mov    $0xffffffff,%r9d
push   %r12
lea    0x18(%rsp),%rax
push   %rax
push   $0x1
call   1030 <read_face@plt>
add    $0x20,%rsp
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movslq %r14d,%rax
mulsd  0x20(%rsp),%xmm0
mov    0x18(%rsp),%rcx
addsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,(%rcx,%rax,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gather_fv_2D(double* %0, double* %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%16 = alloca double
%17 = alloca double
store double* %0, double** %8
store double* %1, double** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double %6, double* %14
store double 0.000000e+00, double* %16
%18 = load i32, i32* %11
%19 = load i32, i32* %12
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %10
%22 = add nsw i32 %20, %21
store i32 %22, i32* %15
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = load i32, i32* %12
%26 = load i32, i32* %13
%27 = load double*, double** %9
%28 = call i32 @read_face(i32 %23, i32 %24, i32 %25, i32 %26, i32 0, i32 0, i32 0, double* %17, double* %27)
%29 = load double, double* %17
%30 = load double, double* %16
%31 = fadd double %30, %29
store double %31, double* %16
%32 = load i32, i32* %10
%33 = load i32, i32* %11
%34 = load i32, i32* %12
%35 = load i32, i32* %13
%36 = load double*, double** %9
%37 = call i32 @read_face(i32 %32, i32 %33, i32 %34, i32 %35, i32 -1, i32 0, i32 0, double* %17, double* %36)
%38 = load double, double* %17
%39 = load double, double* %16
%40 = fsub double %39, %38
store double %40, double* %16
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = load i32, i32* %13
%45 = load double*, double** %9
%46 = call i32 @read_face(i32 %41, i32 %42, i32 %43, i32 %44, i32 0, i32 0, i32 1, double* %17, double* %45)
%47 = load double, double* %17
%48 = load double, double* %16
%49 = fadd double %48, %47
store double %49, double* %16
%50 = load i32, i32* %10
%51 = load i32, i32* %11
%52 = load i32, i32* %12
%53 = load i32, i32* %13
%54 = load double*, double** %9
%55 = call i32 @read_face(i32 %50, i32 %51, i32 %52, i32 %53, i32 0, i32 -1, i32 1, double* %17, double* %54)
%56 = load double, double* %17
%57 = load double, double* %16
%58 = fsub double %57, %56
store double %58, double* %16
%59 = load double*, double** %8
%60 = load i32, i32* %15
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
%63 = load double, double* %62
%64 = load double, double* %14
%65 = fmul double 1.000000e+00, %64
%66 = load double, double* %16
%67 = call double @llvm.fmuladd.f64(double %65, double %66, double %63)
%68 = load double*, double** %8
%69 = load i32, i32* %15
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
ret void
}

LLVM IR (-O2):
define void @gather_fv_2D(double* nocapture %0, double* %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
%8 = alloca double
%9 = bitcast double* %8 to i8*
%10 = mul nsw i32 %4, %3
%11 = add nsw i32 %10, %2
%12 = call i32 @read_face(i32 %2, i32 %3, i32 %4, i32 %5, i32 0, i32 0, i32 0, double* %8, double* %1)
%13 = load double, double* %8
%14 = fadd double %13, 0.000000e+00
%15 = call i32 @read_face(i32 %2, i32 %3, i32 %4, i32 %5, i32 -1, i32 0, i32 0, double* %8, double* %1)
%16 = load double, double* %8
%17 = fsub double %14, %16
%18 = call i32 @read_face(i32 %2, i32 %3, i32 %4, i32 %5, i32 0, i32 0, i32 1, double* %8, double* %1)
%19 = load double, double* %8
%20 = fadd double %17, %19
%21 = call i32 @read_face(i32 %2, i32 %3, i32 %4, i32 %5, i32 0, i32 -1, i32 1, double* %8, double* %1)
%22 = load double, double* %8
%23 = fsub double %20, %22
%24 = sext i32 %11 to i64
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double %6, double %23, double %26)
store double %27, double* %25
ret void
}