#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*/ T_bare(double *, int, double const *);
double erf(double);
int exp(double);
double pow(double, int);
int sqrt(double);
void T_gg(double *dip, int ld, const double *r, double sigma) {
  double rx2 = r[0] * r[0];
  double ry2 = r[1] * r[1];
  double rz2 = r[2] * r[2];
  double r2 = rx2 + ry2 + rz2;
  double r5 = pow(r2, 5. / 2);
  double r_sigma = sqrt(r2) / sigma;
  double r_sigma2 = r_sigma * r_sigma;
  double a1 = -2 / sqrt(3.14159265358979323846) * r_sigma * exp(-r_sigma2);
  double zeta1 = erf(r_sigma) + a1;
  double zeta2 = a1 * (2 * r_sigma2);
  T_bare(dip, ld, r);
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      dip[ld * i + j] *= zeta1;
      dip[ld * i + j] -= zeta2 * r[i] * r[j] / r5;
    }
  }
}


x86 assembly (clang, -O0):
<T_gg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe03(%rip),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0xfffffffe,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
movsd  -0x80(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1070 <erf@plt>
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xd8a(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <T_bare@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x3,-0x74(%rbp)
jge    133a <T_gg+0x1ea>
movl   $0x0,-0x78(%rbp)
cmpl   $0x3,-0x78(%rbp)
jge    1327 <T_gg+0x1d7>
movsd  -0x68(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
imul   -0x74(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x70(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x74(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x78(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  -0x48(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
imul   -0x74(%rbp),%ecx
add    -0x78(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    12ac <T_gg+0x15c>
jmp    132c <T_gg+0x1dc>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    129b <T_gg+0x14b>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<T_gg>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm1
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x28(%rsp)
movsd  (%rsp),%xmm0
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xe35(%rip),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0xfffffffe,%eax
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movaps 0xe1d(%rip),%xmm0
xorps  0x10(%rsp),%xmm0
call   1040 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1070 <erf@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1030 <T_bare@plt>
movslq %ebp,%rax
movsd  (%rbx),%xmm0
movsd  (%rsp),%xmm5
mulsd  %xmm5,%xmm0
movsd  %xmm0,(%rbx)
movsd  (%r14),%xmm1
movapd 0x10(%rsp),%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0x28(%rsp),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rbx),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  (%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  0x8(%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x10(%rbx),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  (%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  0x10(%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  (%rbx,%rax,8),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,(%rbx,%rax,8)
movsd  0x8(%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  (%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx,%rax,8)
movsd  0x8(%rbx,%rax,8),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x8(%rbx,%rax,8)
movsd  0x8(%r14),%xmm1
movapd %xmm4,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rbx,%rax,8)
movsd  0x10(%rbx,%rax,8),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x10(%rbx,%rax,8)
movsd  0x8(%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  0x10(%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rbx,%rax,8)
shl    $0x4,%rax
movsd  (%rbx,%rax,1),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,(%rbx,%rax,1)
movsd  0x10(%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  (%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx,%rax,1)
movsd  0x8(%rbx,%rax,1),%xmm0
mulsd  %xmm5,%xmm0
movsd  %xmm0,0x8(%rbx,%rax,1)
movsd  0x10(%r14),%xmm1
mulsd  %xmm4,%xmm1
mulsd  0x8(%r14),%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rbx,%rax,1)
movapd %xmm5,%xmm0
mulsd  0x10(%rbx,%rax,1),%xmm0
movsd  %xmm0,0x10(%rbx,%rax,1)
movapd %xmm0,%xmm2
movsd  0x10(%r14),%xmm0
movapd %xmm4,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm3,%xmm1
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rbx,%rax,1)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @T_gg(double* %0, i32 %1, double* %2, double %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double %3, double* %8
%21 = load double*, double** %7
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %7
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = fmul double %23, %26
store double %27, double* %9
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = load double*, double** %7
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = fmul double %30, %33
store double %34, double* %10
%35 = load double*, double** %7
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = fmul double %37, %40
store double %41, double* %11
%42 = load double, double* %9
%43 = load double, double* %10
%44 = fadd double %42, %43
%45 = load double, double* %11
%46 = fadd double %44, %45
store double %46, double* %12
%47 = load double, double* %12
%48 = call double @pow(double %47, i32 2)
store double %48, double* %13
%49 = load double, double* %12
%50 = call i32 @sqrt(double %49)
%51 = sitofp i32 %50 to double
%52 = load double, double* %8
%53 = fdiv double %51, %52
store double %53, double* %14
%54 = load double, double* %14
%55 = load double, double* %14
%56 = fmul double %54, %55
store double %56, double* %15
%57 = call i32 @sqrt(double 0x400921FB54442D18)
%58 = sdiv i32 -2, %57
%59 = sitofp i32 %58 to double
%60 = load double, double* %14
%61 = fmul double %59, %60
%62 = load double, double* %15
%63 = fneg double %62
%64 = call i32 @exp(double %63)
%65 = sitofp i32 %64 to double
%66 = fmul double %61, %65
store double %66, double* %16
%67 = load double, double* %14
%68 = call double @erf(double %67)
%69 = load double, double* %16
%70 = fadd double %68, %69
store double %70, double* %17
%71 = load double, double* %16
%72 = load double, double* %15
%73 = fmul double 2.000000e+00, %72
%74 = fmul double %71, %73
store double %74, double* %18
%75 = load double*, double** %5
%76 = load i32, i32* %6
%77 = load double*, double** %7
%78 = call i32 @T_bare(double* %75, i32 %76, double* %77)
store i32 0, i32* %19
br label %79
79: ; preds = %127, %4
%80 = load i32, i32* %19
%81 = icmp slt i32 %80, 3
br i1 %81, label %82, label %130
82: ; preds = %79
store i32 0, i32* %20
br label %83
83: ; preds = %123, %82
%84 = load i32, i32* %20
%85 = icmp slt i32 %84, 3
br i1 %85, label %86, label %126
86: ; preds = %83
%87 = load double, double* %17
%88 = load double*, double** %5
%89 = load i32, i32* %6
%90 = load i32, i32* %19
%91 = mul nsw i32 %89, %90
%92 = load i32, i32* %20
%93 = add nsw i32 %91, %92
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %88, i64 %94
%96 = load double, double* %95
%97 = fmul double %96, %87
store double %97, double* %95
%98 = load double, double* %18
%99 = load double*, double** %7
%100 = load i32, i32* %19
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
%103 = load double, double* %102
%104 = fmul double %98, %103
%105 = load double*, double** %7
%106 = load i32, i32* %20
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %105, i64 %107
%109 = load double, double* %108
%110 = fmul double %104, %109
%111 = load double, double* %13
%112 = fdiv double %110, %111
%113 = load double*, double** %5
%114 = load i32, i32* %6
%115 = load i32, i32* %19
%116 = mul nsw i32 %114, %115
%117 = load i32, i32* %20
%118 = add nsw i32 %116, %117
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %113, i64 %119
%121 = load double, double* %120
%122 = fsub double %121, %112
store double %122, double* %120
br label %123
123: ; preds = %86
%124 = load i32, i32* %20
%125 = add nsw i32 %124, 1
store i32 %125, i32* %20
br label %83
126: ; preds = %83
br label %127
127: ; preds = %126
%128 = load i32, i32* %19
%129 = add nsw i32 %128, 1
store i32 %129, i32* %19
br label %79
130: ; preds = %79
ret void
}

LLVM IR (-O2):
define void @T_gg(double* %0, i32 %1, double* %2, double %3) {
%5 = load double, double* %2
%6 = fmul double %5, %5
%7 = getelementptr inbounds double, double* %2, i64 1
%8 = load double, double* %7
%9 = fmul double %8, %8
%10 = getelementptr inbounds double, double* %2, i64 2
%11 = load double, double* %10
%12 = fmul double %11, %11
%13 = fadd double %6, %9
%14 = fadd double %13, %12
%15 = tail call double @pow(double %14, i32 2)
%16 = tail call i32 @sqrt(double %14)
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, %3
%19 = fmul double %18, %18
%20 = tail call i32 @sqrt(double 0x400921FB54442D18)
%21 = sdiv i32 -2, %20
%22 = sitofp i32 %21 to double
%23 = fmul double %18, %22
%24 = fneg double %19
%25 = tail call i32 @exp(double %24)
%26 = sitofp i32 %25 to double
%27 = fmul double %23, %26
%28 = tail call double @erf(double %18)
%29 = fadd double %28, %27
%30 = fmul double %19, 2.000000e+00
%31 = fmul double %30, %27
%32 = tail call i32 @T_bare(double* %0, i32 %1, double* %2)
%33 = sext i32 %1 to i64
%34 = load double, double* %0
%35 = fmul double %29, %34
store double %35, double* %0
%36 = load double, double* %2
%37 = fmul double %31, %36
%38 = fmul double %37, %36
%39 = fdiv double %38, %15
%40 = fsub double %35, %39
store double %40, double* %0
%41 = getelementptr inbounds double, double* %0, i64 1
%42 = load double, double* %41
%43 = fmul double %29, %42
store double %43, double* %41
%44 = load double, double* %2
%45 = fmul double %31, %44
%46 = load double, double* %7
%47 = fmul double %45, %46
%48 = fdiv double %47, %15
%49 = fsub double %43, %48
store double %49, double* %41
%50 = getelementptr inbounds double, double* %0, i64 2
%51 = load double, double* %50
%52 = fmul double %29, %51
store double %52, double* %50
%53 = load double, double* %2
%54 = fmul double %31, %53
%55 = load double, double* %10
%56 = fmul double %54, %55
%57 = fdiv double %56, %15
%58 = fsub double %52, %57
store double %58, double* %50
%59 = getelementptr inbounds double, double* %0, i64 %33
%60 = load double, double* %59
%61 = fmul double %29, %60
store double %61, double* %59
%62 = load double, double* %7
%63 = fmul double %31, %62
%64 = load double, double* %2
%65 = fmul double %63, %64
%66 = fdiv double %65, %15
%67 = fsub double %61, %66
store double %67, double* %59
%68 = add nsw i64 %33, 1
%69 = getelementptr inbounds double, double* %0, i64 %68
%70 = load double, double* %69
%71 = fmul double %29, %70
store double %71, double* %69
%72 = load double, double* %7
%73 = fmul double %31, %72
%74 = fmul double %73, %72
%75 = fdiv double %74, %15
%76 = fsub double %71, %75
store double %76, double* %69
%77 = add nsw i64 %33, 2
%78 = getelementptr inbounds double, double* %0, i64 %77
%79 = load double, double* %78
%80 = fmul double %29, %79
store double %80, double* %78
%81 = load double, double* %7
%82 = fmul double %31, %81
%83 = load double, double* %10
%84 = fmul double %82, %83
%85 = fdiv double %84, %15
%86 = fsub double %80, %85
store double %86, double* %78
%87 = shl nsw i64 %33, 1
%88 = getelementptr inbounds double, double* %0, i64 %87
%89 = load double, double* %88
%90 = fmul double %29, %89
store double %90, double* %88
%91 = load double, double* %10
%92 = fmul double %31, %91
%93 = load double, double* %2
%94 = fmul double %92, %93
%95 = fdiv double %94, %15
%96 = fsub double %90, %95
store double %96, double* %88
%97 = or i64 %87, 1
%98 = getelementptr inbounds double, double* %0, i64 %97
%99 = load double, double* %98
%100 = fmul double %29, %99
store double %100, double* %98
%101 = load double, double* %10
%102 = fmul double %31, %101
%103 = load double, double* %7
%104 = fmul double %102, %103
%105 = fdiv double %104, %15
%106 = fsub double %100, %105
store double %106, double* %98
%107 = add nsw i64 %87, 2
%108 = getelementptr inbounds double, double* %0, i64 %107
%109 = load double, double* %108
%110 = fmul double %29, %109
store double %110, double* %108
%111 = load double, double* %10
%112 = fmul double %31, %111
%113 = fmul double %112, %111
%114 = fdiv double %113, %15
%115 = fsub double %110, %114
store double %115, double* %108
ret void
}