#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 LinearAD_DiracIC_advectiveVelocity(int *, double *, int, double, double *,
                                       double *);
scalar_t__ LinearAD_DiracIC_diffusiveVelocity(int *, double *, int, double,
                                              double *, double *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int LinearAD_DiracIC_totalVelocity(int *iwork, double *rwork, int nPoints,
                                   double T, double *x, double *f) {
  int i, j, iret;
  double *f_adv = (double *)malloc(nPoints * 3 * sizeof(double));
  iret = LinearAD_DiracIC_advectiveVelocity(iwork, rwork, nPoints, T, x, f_adv);
  iret += LinearAD_DiracIC_diffusiveVelocity(iwork, rwork, nPoints, T, x, f);
  for (i = 0; i < nPoints; i++) {
    for (j = 0; j < 3; j++) {
      f[i * 3 + j] += f_adv[i * 3 + j];
    }
  }
  free(f_adv);
  return iret;
}


x86 assembly (clang, -O0):
<LinearAD_DiracIC_totalVelocity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
imul   $0x3,-0x14(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   1060 <LinearAD_DiracIC_advectiveVelocity@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1040 <LinearAD_DiracIC_diffusiveVelocity@plt>
mov    %rax,%rcx
movslq -0x3c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <LinearAD_DiracIC_totalVelocity+0xef>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    121c <LinearAD_DiracIC_totalVelocity+0xdc>
mov    -0x48(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11d9 <LinearAD_DiracIC_totalVelocity+0x99>
jmp    1221 <LinearAD_DiracIC_totalVelocity+0xe1>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c6 <LinearAD_DiracIC_totalVelocity+0x86>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LinearAD_DiracIC_totalVelocity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r12
movsd  %xmm0,0x10(%rsp)
mov    %edx,%ebp
mov    %rsi,%r13
mov    %rdi,%r15
lea    0x0(,%rbp,8),%eax
lea    (%rax,%rax,2),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x10(%rsp),%xmm0
mov    %r12,%rcx
mov    %rax,%r8
call   1060 <LinearAD_DiracIC_advectiveVelocity@plt>
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
movsd  0x10(%rsp),%xmm0
mov    %r12,%rcx
mov    %rbx,%r8
call   1040 <LinearAD_DiracIC_diffusiveVelocity@plt>
test   %ebp,%ebp
jle    1230 <LinearAD_DiracIC_totalVelocity+0xf0>
mov    %ebp,%ecx
cmp    $0x1,%ebp
je     11dc <LinearAD_DiracIC_totalVelocity+0x9c>
lea    0x0(,%rcx,8),%rdx
lea    (%rdx,%rdx,2),%rdx
mov    %r14,%rsi
add    %rdx,%rsi
cmp    %rbx,%rsi
jbe    124f <LinearAD_DiracIC_totalVelocity+0x10f>
add    %rbx,%rdx
cmp    %rdx,%r14
jae    124f <LinearAD_DiracIC_totalVelocity+0x10f>
xor    %edx,%edx
lea    (%rdx,%rdx,2),%rsi
lea    0x10(,%rsi,8),%rsi
sub    %rdx,%rcx
nopl   (%rax)
movsd  -0x10(%r14,%rsi,1),%xmm0
addsd  -0x10(%rbx,%rsi,1),%xmm0
movsd  %xmm0,-0x10(%rbx,%rsi,1)
movsd  -0x8(%r14,%rsi,1),%xmm0
addsd  -0x8(%rbx,%rsi,1),%xmm0
movsd  %xmm0,-0x8(%rbx,%rsi,1)
movsd  (%r14,%rsi,1),%xmm0
addsd  (%rbx,%rsi,1),%xmm0
movsd  %xmm0,(%rbx,%rsi,1)
add    $0x18,%rsi
add    $0xffffffffffffffff,%rcx
jne    11f0 <LinearAD_DiracIC_totalVelocity+0xb0>
mov    0xc(%rsp),%ebx
add    %eax,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%edx
and    $0xfffffffe,%edx
lea    -0x2(%rdx),%rsi
mov    %rsi,%rbp
shr    %rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     1406 <LinearAD_DiracIC_totalVelocity+0x2c6>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%r14,%rsi,8),%xmm1
movupd 0x10(%r14,%rsi,8),%xmm8
movupd 0x20(%r14,%rsi,8),%xmm3
movapd %xmm8,%xmm4
movsd  %xmm1,%xmm4
movupd (%rbx,%rsi,8),%xmm5
movupd 0x10(%rbx,%rsi,8),%xmm2
movupd 0x20(%rbx,%rsi,8),%xmm7
movupd 0x30(%rbx,%rsi,8),%xmm0
movapd %xmm2,%xmm6
movsd  %xmm5,%xmm6
addpd  %xmm4,%xmm6
shufpd $0x1,%xmm3,%xmm1
shufpd $0x1,%xmm7,%xmm5
addpd  %xmm1,%xmm5
movsd  %xmm8,%xmm3
movsd  %xmm2,%xmm7
addpd  %xmm3,%xmm7
movapd %xmm5,%xmm1
unpckhpd %xmm7,%xmm1
shufpd $0x2,%xmm6,%xmm7
unpcklpd %xmm5,%xmm6
movupd %xmm6,(%rbx,%rsi,8)
movupd %xmm7,0x10(%rbx,%rsi,8)
movupd %xmm1,0x20(%rbx,%rsi,8)
movupd 0x30(%r14,%rsi,8),%xmm1
movupd 0x40(%r14,%rsi,8),%xmm2
movupd 0x50(%r14,%rsi,8),%xmm3
movupd 0x50(%rbx,%rsi,8),%xmm4
movupd 0x40(%rbx,%rsi,8),%xmm5
movapd %xmm2,%xmm6
movsd  %xmm1,%xmm6
movapd %xmm5,%xmm7
movsd  %xmm0,%xmm7
addpd  %xmm6,%xmm7
shufpd $0x1,%xmm3,%xmm1
shufpd $0x1,%xmm4,%xmm0
addpd  %xmm1,%xmm0
movsd  %xmm2,%xmm3
movsd  %xmm5,%xmm4
addpd  %xmm3,%xmm4
movapd %xmm0,%xmm1
unpckhpd %xmm4,%xmm1
shufpd $0x2,%xmm7,%xmm4
unpcklpd %xmm0,%xmm7
movupd %xmm7,0x30(%rbx,%rsi,8)
movupd %xmm4,0x40(%rbx,%rsi,8)
movupd %xmm1,0x50(%rbx,%rsi,8)
add    $0xc,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1280 <LinearAD_DiracIC_totalVelocity+0x140>
test   $0x1,%bpl
je     13f8 <LinearAD_DiracIC_totalVelocity+0x2b8>
movupd (%r14,%rsi,8),%xmm0
movupd 0x10(%r14,%rsi,8),%xmm1
movupd 0x20(%r14,%rsi,8),%xmm2
movupd (%rbx,%rsi,8),%xmm3
movupd 0x10(%rbx,%rsi,8),%xmm4
movupd 0x20(%rbx,%rsi,8),%xmm5
movapd %xmm1,%xmm6
movsd  %xmm0,%xmm6
movapd %xmm4,%xmm7
movsd  %xmm3,%xmm7
addpd  %xmm6,%xmm7
shufpd $0x1,%xmm2,%xmm0
shufpd $0x1,%xmm5,%xmm3
addpd  %xmm0,%xmm3
movsd  %xmm1,%xmm2
movsd  %xmm4,%xmm5
addpd  %xmm2,%xmm5
movapd %xmm3,%xmm0
unpckhpd %xmm5,%xmm0
shufpd $0x2,%xmm7,%xmm5
unpcklpd %xmm3,%xmm7
movupd %xmm7,(%rbx,%rsi,8)
movupd %xmm5,0x10(%rbx,%rsi,8)
movupd %xmm0,0x20(%rbx,%rsi,8)
cmp    %rcx,%rdx
je     1230 <LinearAD_DiracIC_totalVelocity+0xf0>
jmp    11de <LinearAD_DiracIC_totalVelocity+0x9e>
xor    %esi,%esi
test   $0x1,%bpl
jne    1383 <LinearAD_DiracIC_totalVelocity+0x243>
jmp    13f8 <LinearAD_DiracIC_totalVelocity+0x2b8>

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

LLVM IR (-O2):
define i32 @LinearAD_DiracIC_totalVelocity(i32* %0, double* %1, i32 %2, double %3, double* %4, double* %5) {
%7 = mul i32 %2, 24
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = inttoptr i64 %8 to i8*
%11 = tail call i32 @LinearAD_DiracIC_advectiveVelocity(i32* %0, double* %1, i32 %2, double %3, double* %4, double* %9)
%12 = tail call i64 @LinearAD_DiracIC_diffusiveVelocity(i32* %0, double* %1, i32 %2, double %3, double* %4, double* %5)
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %126
14: ; preds = %6
%15 = zext i32 %2 to i64
%16 = icmp eq i32 %2, 1
br i1 %16, label %102, label %17
17: ; preds = %14
%18 = mul nuw nsw i64 %15, 3
%19 = getelementptr double, double* %5, i64 %18
%20 = bitcast double* %19 to i8*
%21 = getelementptr double, double* %9, i64 %18
%22 = icmp ugt double* %21, %5
%23 = icmp ult i8* %10, %20
%24 = and i1 %22, %23
br i1 %24, label %102, label %25
25: ; preds = %17
%26 = and i64 %15, 4294967294
%27 = add nsw i64 %26, -2
%28 = lshr exact i64 %27, 1
%29 = add nuw i64 %28, 1
%30 = and i64 %29, 1
%31 = icmp eq i64 %27, 0
br i1 %31, label %79, label %32
32: ; preds = %25
%33 = and i64 %29, -2
br label %34
34: ; preds = %34, %32
%35 = phi i64 [ 0, %32 ], [ %74, %34 ]
%36 = phi i64 [ 0, %32 ], [ %75, %34 ]
%37 = mul nuw nsw i64 %35, 3
%38 = getelementptr inbounds double, double* %9, i64 %37
%39 = bitcast double* %38 to <6 x double>*
%40 = load <6 x double>, <6 x double>* %39
%41 = getelementptr inbounds double, double* %5, i64 %37
%42 = bitcast double* %41 to <6 x double>*
%43 = load <6 x double>, <6 x double>* %42
%44 = fadd <6 x double> %40, %43
%45 = shufflevector <6 x double> %44, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%46 = fadd <6 x double> %40, %43
%47 = shufflevector <6 x double> %46, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%48 = fadd <6 x double> %40, %43
%49 = shufflevector <6 x double> %48, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%50 = getelementptr inbounds double, double* %5, i64 %37
%51 = bitcast double* %50 to <6 x double>*
%52 = shufflevector <2 x double> %45, <2 x double> %47, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%53 = shufflevector <2 x double> %49, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%54 = shufflevector <4 x double> %52, <4 x double> %53, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %54, <6 x double>* %51
%55 = or i64 %35, 2
%56 = mul nuw nsw i64 %55, 3
%57 = getelementptr inbounds double, double* %9, i64 %56
%58 = bitcast double* %57 to <6 x double>*
%59 = load <6 x double>, <6 x double>* %58
%60 = getelementptr inbounds double, double* %5, i64 %56
%61 = bitcast double* %60 to <6 x double>*
%62 = load <6 x double>, <6 x double>* %61
%63 = fadd <6 x double> %59, %62
%64 = shufflevector <6 x double> %63, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%65 = fadd <6 x double> %59, %62
%66 = shufflevector <6 x double> %65, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%67 = fadd <6 x double> %59, %62
%68 = shufflevector <6 x double> %67, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%69 = getelementptr inbounds double, double* %5, i64 %56
%70 = bitcast double* %69 to <6 x double>*
%71 = shufflevector <2 x double> %64, <2 x double> %66, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%72 = shufflevector <2 x double> %68, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%73 = shufflevector <4 x double> %71, <4 x double> %72, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %73, <6 x double>* %70
%74 = add nuw i64 %35, 4
%75 = add nuw i64 %36, 2
%76 = icmp eq i64 %75, %33
br i1 %76, label %77, label %34
77: ; preds = %34
%78 = mul i64 %74, 3
br label %79
79: ; preds = %77, %25
%80 = phi i64 [ 0, %25 ], [ %78, %77 ]
%81 = icmp eq i64 %30, 0
br i1 %81, label %100, label %82
82: ; preds = %79
%83 = getelementptr inbounds double, double* %9, i64 %80
%84 = bitcast double* %83 to <6 x double>*
%85 = load <6 x double>, <6 x double>* %84
%86 = getelementptr inbounds double, double* %5, i64 %80
%87 = bitcast double* %86 to <6 x double>*
%88 = load <6 x double>, <6 x double>* %87
%89 = fadd <6 x double> %85, %88
%90 = shufflevector <6 x double> %89, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%91 = fadd <6 x double> %85, %88
%92 = shufflevector <6 x double> %91, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%93 = fadd <6 x double> %85, %88
%94 = shufflevector <6 x double> %93, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%95 = getelementptr inbounds double, double* %5, i64 %80
%96 = bitcast double* %95 to <6 x double>*
%97 = shufflevector <2 x double> %90, <2 x double> %92, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%98 = shufflevector <2 x double> %94, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%99 = shufflevector <4 x double> %97, <4 x double> %98, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %99, <6 x double>* %96
br label %100
100: ; preds = %79, %82
%101 = icmp eq i64 %26, %15
br i1 %101, label %126, label %102
102: ; preds = %17, %14, %100
%103 = phi i64 [ 0, %17 ], [ 0, %14 ], [ %26, %100 ]
br label %104
104: ; preds = %102, %104
%105 = phi i64 [ %124, %104 ], [ %103, %102 ]
%106 = mul nuw nsw i64 %105, 3
%107 = getelementptr inbounds double, double* %9, i64 %106
%108 = load double, double* %107
%109 = getelementptr inbounds double, double* %5, i64 %106
%110 = load double, double* %109
%111 = fadd double %108, %110
store double %111, double* %109
%112 = add nuw nsw i64 %106, 1
%113 = getelementptr inbounds double, double* %9, i64 %112
%114 = load double, double* %113
%115 = getelementptr inbounds double, double* %5, i64 %112
%116 = load double, double* %115
%117 = fadd double %114, %116
store double %117, double* %115
%118 = add nuw nsw i64 %106, 2
%119 = getelementptr inbounds double, double* %9, i64 %118
%120 = load double, double* %119
%121 = getelementptr inbounds double, double* %5, i64 %118
%122 = load double, double* %121
%123 = fadd double %120, %122
store double %123, double* %121
%124 = add nuw nsw i64 %105, 1
%125 = icmp eq i64 %124, %15
br i1 %125, label %126, label %104
126: ; preds = %104, %100, %6
%127 = trunc i64 %12 to i32
%128 = add i32 %11, %127
%129 = tail call i32 @free(double* %9)
ret i32 %128
}