#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 */
void convolute(double quantity, double *function, double *output, size_t length,
               size_t offset) {
  size_t i;
  for (i = 0; i < length; i++) {
    output[offset + i + 1] += quantity * function[i];
  }
}


x86 assembly (clang, -O0):
<convolute>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1172 <convolute+0x72>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
movsd  0x8(%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1121 <convolute+0x21>
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolute>:
test   %rdx,%rdx
je     12be <convolute+0x1be>
cmp    $0x4,%rdx
jb     1139 <convolute+0x39>
lea    (%rsi,%rcx,8),%r8
add    $0x8,%r8
lea    (%rdi,%rdx,8),%rax
cmp    %rax,%r8
jae    11c0 <convolute+0xc0>
lea    (%rcx,%rdx,1),%rax
lea    (%rsi,%rax,8),%rax
add    $0x8,%rax
cmp    %rdi,%rax
jbe    11c0 <convolute+0xc0>
xor    %r8d,%r8d
mov    %r8,%rax
not    %rax
test   $0x1,%dl
je     1165 <convolute+0x65>
movsd  (%rdi,%r8,8),%xmm1
or     $0x1,%r8
lea    (%r8,%rcx,1),%r9
mulsd  %xmm0,%xmm1
addsd  (%rsi,%r9,8),%xmm1
movsd  %xmm1,(%rsi,%r9,8)
add    %rdx,%rax
je     12be <convolute+0x1be>
lea    (%rsi,%rcx,8),%rax
add    $0x10,%rax
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdi,%r8,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  -0x8(%rax,%r8,8),%xmm1
movsd  %xmm1,-0x8(%rax,%r8,8)
movsd  0x8(%rdi,%r8,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rax,%r8,8),%xmm1
movsd  %xmm1,(%rax,%r8,8)
lea    0x2(%r8),%rcx
mov    %rcx,%r8
cmp    %rcx,%rdx
jne    1180 <convolute+0x80>
jmp    12be <convolute+0x1be>
mov    %rdx,%r8
and    $0xfffffffffffffffc,%r8
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%r8),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12bf <convolute+0x1bf>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
lea    (%rsi,%rcx,8),%r11
add    $0x38,%r11
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movupd (%rdi,%rax,8),%xmm2
movupd 0x10(%rdi,%rax,8),%xmm3
mulpd  %xmm1,%xmm2
movupd -0x30(%r11,%rax,8),%xmm4
addpd  %xmm2,%xmm4
movupd -0x20(%r11,%rax,8),%xmm2
movupd -0x10(%r11,%rax,8),%xmm5
movupd (%r11,%rax,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,-0x30(%r11,%rax,8)
movupd %xmm3,-0x20(%r11,%rax,8)
movupd 0x20(%rdi,%rax,8),%xmm2
movupd 0x30(%rdi,%rax,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,-0x10(%r11,%rax,8)
movupd %xmm3,(%r11,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1200 <convolute+0x100>
test   $0x1,%r9b
je     12b5 <convolute+0x1b5>
movupd (%rdi,%rax,8),%xmm2
movupd 0x10(%rdi,%rax,8),%xmm3
or     $0x1,%rax
add    %rcx,%rax
movupd (%rsi,%rax,8),%xmm4
movupd 0x10(%rsi,%rax,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rsi,%rax,8)
movupd %xmm3,0x10(%rsi,%rax,8)
cmp    %rdx,%r8
jne    113c <convolute+0x3c>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    127d <convolute+0x17d>
jmp    12b5 <convolute+0x1b5>

LLVM IR (-O0):
define void @convolute(double %0, double* %1, double* %2, i64 %3, i64 %4) {
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store double %0, double* %6
store double* %1, double** %7
store double* %2, double** %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i64 0, i64* %11
br label %12
12: ; preds = %30, %5
%13 = load i64, i64* %11
%14 = load i64, i64* %9
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load double, double* %6
%18 = load double*, double** %7
%19 = load i64, i64* %11
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %8
%23 = load i64, i64* %10
%24 = load i64, i64* %11
%25 = add i64 %23, %24
%26 = add i64 %25, 1
%27 = getelementptr inbounds double, double* %22, i64 %26
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %17, double %21, double %28)
store double %29, double* %27
br label %30
30: ; preds = %16
%31 = load i64, i64* %11
%32 = add i64 %31, 1
store i64 %32, i64* %11
br label %12
33: ; preds = %12
ret void
}

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