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


x86 assembly (clang, -O0):
<LinearAD_DiracIC_advectiveVelocity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x58(%rbp),%r8
call   1050 <LinearAD_DiracIC@plt>
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121b <LinearAD_DiracIC_advectiveVelocity+0xeb>
movl   $0x0,-0x60(%rbp)
cmpl   $0x3,-0x60(%rbp)
jge    1208 <LinearAD_DiracIC_advectiveVelocity+0xd8>
movslq -0x60(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
imul   $0x3,-0x5c(%rbp),%ecx
add    -0x60(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11c6 <LinearAD_DiracIC_advectiveVelocity+0x96>
jmp    120d <LinearAD_DiracIC_advectiveVelocity+0xdd>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11b3 <LinearAD_DiracIC_advectiveVelocity+0x83>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x64(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LinearAD_DiracIC_advectiveVelocity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r15
mov    %rcx,%r14
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%r13
movsd  (%rsi),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsi),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsi),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x0(,%r12,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
movsd  0x8(%rsp),%xmm0
mov    %r14,%rcx
mov    %rax,%r8
call   1050 <LinearAD_DiracIC@plt>
movapd 0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
movapd 0x30(%rsp),%xmm7
mov    %eax,%r14d
test   %r12d,%r12d
jle    1226 <LinearAD_DiracIC_advectiveVelocity+0xf6>
mov    %r12d,%eax
cmp    $0x1,%r12d
je     11d3 <LinearAD_DiracIC_advectiveVelocity+0xa3>
lea    (%rbx,%rax,8),%rcx
cmp    %r15,%rcx
jbe    1240 <LinearAD_DiracIC_advectiveVelocity+0x110>
lea    (%rax,%rax,2),%rcx
lea    (%r15,%rcx,8),%rcx
cmp    %rcx,%rbx
jae    1240 <LinearAD_DiracIC_advectiveVelocity+0x110>
xor    %ecx,%ecx
lea    (%rcx,%rcx,2),%rdx
lea    (%r15,%rdx,8),%rdx
add    $0x10,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm0
mulsd  %xmm7,%xmm0
movsd  %xmm0,-0x10(%rdx)
movsd  (%rbx,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rdx)
movsd  (%rbx,%rcx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rdx)
add    $0x1,%rcx
add    $0x18,%rdx
cmp    %rcx,%rax
jne    11f0 <LinearAD_DiracIC_advectiveVelocity+0xc0>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ecx
and    $0xfffffffe,%ecx
movapd %xmm7,%xmm8
unpcklpd %xmm7,%xmm8
movapd %xmm1,%xmm9
unpcklpd %xmm1,%xmm9
movapd %xmm2,%xmm0
unpcklpd %xmm2,%xmm0
lea    -0x2(%rcx),%rdx
mov    %rdx,%rsi
shr    %rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     1360 <LinearAD_DiracIC_advectiveVelocity+0x230>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rbx,%rdx,8),%xmm3
movapd %xmm8,%xmm4
mulpd  %xmm3,%xmm4
movapd %xmm9,%xmm5
mulpd  %xmm3,%xmm5
mulpd  %xmm0,%xmm3
movapd %xmm4,%xmm6
unpcklpd %xmm5,%xmm6
movsd  %xmm3,%xmm4
movhlps %xmm5,%xmm3
movups %xmm3,0x20(%rbp)
movupd %xmm4,0x10(%rbp)
movupd %xmm6,0x0(%rbp)
movupd 0x10(%rbx,%rdx,8),%xmm3
movapd %xmm8,%xmm4
mulpd  %xmm3,%xmm4
movapd %xmm9,%xmm5
mulpd  %xmm3,%xmm5
mulpd  %xmm0,%xmm3
movapd %xmm4,%xmm6
unpcklpd %xmm5,%xmm6
movsd  %xmm3,%xmm4
movhlps %xmm5,%xmm3
movups %xmm3,0x50(%rbp)
movupd %xmm4,0x40(%rbp)
movupd %xmm6,0x30(%rbp)
add    $0x4,%rdx
add    $0x60,%rbp
add    $0xfffffffffffffffe,%rdi
jne    1290 <LinearAD_DiracIC_advectiveVelocity+0x160>
test   $0x1,%sil
je     1352 <LinearAD_DiracIC_advectiveVelocity+0x222>
movupd (%rbx,%rdx,8),%xmm3
mulpd  %xmm3,%xmm8
mulpd  %xmm3,%xmm9
mulpd  %xmm3,%xmm0
lea    (%rdx,%rdx,2),%rdx
movapd %xmm8,%xmm3
unpcklpd %xmm9,%xmm3
movsd  %xmm0,%xmm8
movhlps %xmm9,%xmm0
movups %xmm0,0x20(%r15,%rdx,8)
movupd %xmm8,0x10(%r15,%rdx,8)
movupd %xmm3,(%r15,%rdx,8)
cmp    %rax,%rcx
je     1226 <LinearAD_DiracIC_advectiveVelocity+0xf6>
jmp    11d5 <LinearAD_DiracIC_advectiveVelocity+0xa5>
xor    %edx,%edx
test   $0x1,%sil
jne    1315 <LinearAD_DiracIC_advectiveVelocity+0x1e5>
jmp    1352 <LinearAD_DiracIC_advectiveVelocity+0x222>

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

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