#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*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ trapz(int *, int *, double *, double *, double *);
void innerprod_q(int *m1, double *t, double *q1, double *q2, double *out) {
  int k;
  double *q;
  int m = *m1;
  int n1 = 1;
  q = (double *)malloc(m * sizeof(double));
  for (k = 0; k < m; k++)
    q[k] = q1[k] * q2[k];
  trapz(m1, &n1, t, q, out);
  free(q);
}


x86 assembly (clang, -O0):
<innerprod_q>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    11b7 <innerprod_q+0x87>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1176 <innerprod_q+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    -0x40(%rbp),%rsi
call   1040 <trapz@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<innerprod_q>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdi),%r14d
movl   $0x1,0xc(%rsp)
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
test   %r14d,%r14d
jle    1340 <innerprod_q+0x210>
cmp    $0x4,%r14d
jae    1229 <innerprod_q+0xf9>
xor    %eax,%eax
mov    %rax,%rcx
not    %rcx
add    %r14,%rcx
mov    %r14,%rdx
and    $0x3,%rdx
je     11bc <innerprod_q+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
mulsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
jne    11a0 <innerprod_q+0x70>
cmp    $0x3,%rcx
jb     1340 <innerprod_q+0x210>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
mulsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
movsd  0x8(%rbx,%rax,8),%xmm0
mulsd  0x8(%r13,%rax,8),%xmm0
movsd  %xmm0,0x8(%rbp,%rax,8)
movsd  0x10(%rbx,%rax,8),%xmm0
mulsd  0x10(%r13,%rax,8),%xmm0
movsd  %xmm0,0x10(%rbp,%rax,8)
movsd  0x18(%rbx,%rax,8),%xmm0
mulsd  0x18(%r13,%rax,8),%xmm0
movsd  %xmm0,0x18(%rbp,%rax,8)
add    $0x4,%rax
cmp    %rax,%r14
jne    11d0 <innerprod_q+0xa0>
jmp    1340 <innerprod_q+0x210>
lea    0x0(,%r14,8),%rax
add    %rbp,%rax
lea    (%rbx,%r14,8),%rcx
cmp    %rcx,%rbp
setb   %dil
cmp    %rbx,%rax
seta   %dl
lea    0x0(,%r14,8),%rcx
add    %r13,%rcx
cmp    %rcx,%rbp
setb   %cl
cmp    %r13,%rax
seta   %sil
xor    %eax,%eax
test   %dl,%dil
jne    117f <innerprod_q+0x4f>
and    %sil,%cl
jne    117f <innerprod_q+0x4f>
mov    %r14d,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rcx
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
test   %rcx,%rcx
je     136f <innerprod_q+0x23f>
mov    %rdx,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rcx,8),%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm1
movupd 0x0(%r13,%rcx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x10(%r13,%rcx,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,0x0(%rbp,%rcx,8)
movupd %xmm0,0x10(%rbp,%rcx,8)
movupd 0x20(%rbx,%rcx,8),%xmm0
movupd 0x30(%rbx,%rcx,8),%xmm1
movupd 0x20(%r13,%rcx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x30(%r13,%rcx,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,0x20(%rbp,%rcx,8)
movupd %xmm0,0x30(%rbp,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%rsi
jne    12a0 <innerprod_q+0x170>
test   $0x1,%dl
je     1337 <innerprod_q+0x207>
movupd (%rbx,%rcx,8),%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm1
movupd 0x0(%r13,%rcx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x10(%r13,%rcx,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,0x0(%rbp,%rcx,8)
movupd %xmm0,0x10(%rbp,%rcx,8)
cmp    %r14,%rax
jne    117f <innerprod_q+0x4f>
lea    0xc(%rsp),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    0x10(%rsp),%r8
call   1040 <trapz@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ecx,%ecx
test   $0x1,%dl
jne    130a <innerprod_q+0x1da>
jmp    1337 <innerprod_q+0x207>

LLVM IR (-O0):
define void @innerprod_q(i32* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
store i32 %16, i32* %13
store i32 1, i32* %14
%17 = load i32, i32* %13
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to double*
store double* %22, double** %12
store i32 0, i32* %11
br label %23
23: ; preds = %43, %5
%24 = load i32, i32* %11
%25 = load i32, i32* %13
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %46
27: ; preds = %23
%28 = load double*, double** %8
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %9
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = fmul double %32, %37
%39 = load double*, double** %12
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double %38, double* %42
br label %43
43: ; preds = %27
%44 = load i32, i32* %11
%45 = add nsw i32 %44, 1
store i32 %45, i32* %11
br label %23
46: ; preds = %23
%47 = load i32*, i32** %6
%48 = load double*, double** %7
%49 = load double*, double** %12
%50 = load double*, double** %10
%51 = call i32 @trapz(i32* %47, i32* %14, double* %48, double* %49, double* %50)
%52 = load double*, double** %12
%53 = call i32 @free(double* %52)
ret void
}

LLVM IR (-O2):
define void @innerprod_q(i32* %0, double* %1, double* nocapture %2, double* nocapture %3, double* %4) {
%6 = alloca i32
%7 = load i32, i32* %0
%8 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%9 = shl i32 %7, 3
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double*
%12 = inttoptr i64 %10 to i8*
%13 = icmp sgt i32 %7, 0
br i1 %13, label %14, label %158
14: ; preds = %5
%15 = zext i32 %7 to i64
%16 = icmp ult i32 %7, 4
br i1 %16, label %106, label %17
17: ; preds = %14
%18 = getelementptr double, double* %11, i64 %15
%19 = getelementptr double, double* %2, i64 %15
%20 = bitcast double* %19 to i8*
%21 = getelementptr double, double* %3, i64 %15
%22 = bitcast double* %21 to i8*
%23 = icmp ult i8* %12, %20
%24 = icmp ugt double* %18, %2
%25 = and i1 %23, %24
%26 = icmp ult i8* %12, %22
%27 = icmp ugt double* %18, %3
%28 = and i1 %26, %27
%29 = or i1 %25, %28
br i1 %29, label %106, label %30
30: ; preds = %17
%31 = and i64 %15, 4294967292
%32 = add nsw i64 %31, -4
%33 = lshr exact i64 %32, 2
%34 = add nuw nsw i64 %33, 1
%35 = and i64 %34, 1
%36 = icmp eq i64 %32, 0
br i1 %36, label %82, label %37
37: ; preds = %30
%38 = and i64 %34, 9223372036854775806
br label %39
39: ; preds = %39, %37
%40 = phi i64 [ 0, %37 ], [ %79, %39 ]
%41 = phi i64 [ 0, %37 ], [ %80, %39 ]
%42 = getelementptr inbounds double, double* %2, i64 %40
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %3, i64 %40
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %48, i64 2
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = fmul <2 x double> %44, %50
%55 = fmul <2 x double> %47, %53
%56 = getelementptr inbounds double, double* %11, i64 %40
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %54, <2 x double>* %57
%58 = getelementptr inbounds double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %55, <2 x double>* %59
%60 = or i64 %40, 4
%61 = getelementptr inbounds double, double* %2, i64 %60
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %3, i64 %60
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %67, i64 2
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = fmul <2 x double> %63, %69
%74 = fmul <2 x double> %66, %72
%75 = getelementptr inbounds double, double* %11, i64 %60
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %73, <2 x double>* %76
%77 = getelementptr inbounds double, double* %75, i64 2
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %74, <2 x double>* %78
%79 = add nuw i64 %40, 8
%80 = add i64 %41, 2
%81 = icmp eq i64 %80, %38
br i1 %81, label %82, label %39
82: ; preds = %39, %30
%83 = phi i64 [ 0, %30 ], [ %79, %39 ]
%84 = icmp eq i64 %35, 0
br i1 %84, label %104, label %85
85: ; preds = %82
%86 = getelementptr inbounds double, double* %2, i64 %83
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = getelementptr inbounds double, double* %86, i64 2
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = getelementptr inbounds double, double* %3, i64 %83
%93 = bitcast double* %92 to <2 x double>*
%94 = load <2 x double>, <2 x double>* %93
%95 = getelementptr inbounds double, double* %92, i64 2
%96 = bitcast double* %95 to <2 x double>*
%97 = load <2 x double>, <2 x double>* %96
%98 = fmul <2 x double> %88, %94
%99 = fmul <2 x double> %91, %97
%100 = getelementptr inbounds double, double* %11, i64 %83
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> %98, <2 x double>* %101
%102 = getelementptr inbounds double, double* %100, i64 2
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %99, <2 x double>* %103
br label %104
104: ; preds = %82, %85
%105 = icmp eq i64 %31, %15
br i1 %105, label %158, label %106
106: ; preds = %17, %14, %104
%107 = phi i64 [ 0, %17 ], [ 0, %14 ], [ %31, %104 ]
%108 = xor i64 %107, -1
%109 = add nsw i64 %108, %15
%110 = and i64 %15, 3
%111 = icmp eq i64 %110, 0
br i1 %111, label %124, label %112
112: ; preds = %106, %112
%113 = phi i64 [ %121, %112 ], [ %107, %106 ]
%114 = phi i64 [ %122, %112 ], [ 0, %106 ]
%115 = getelementptr inbounds double, double* %2, i64 %113
%116 = load double, double* %115
%117 = getelementptr inbounds double, double* %3, i64 %113
%118 = load double, double* %117
%119 = fmul double %116, %118
%120 = getelementptr inbounds double, double* %11, i64 %113
store double %119, double* %120
%121 = add nuw nsw i64 %113, 1
%122 = add i64 %114, 1
%123 = icmp eq i64 %122, %110
br i1 %123, label %124, label %112
124: ; preds = %112, %106
%125 = phi i64 [ %107, %106 ], [ %121, %112 ]
%126 = icmp ult i64 %109, 3
br i1 %126, label %158, label %127
127: ; preds = %124, %127
%128 = phi i64 [ %156, %127 ], [ %125, %124 ]
%129 = getelementptr inbounds double, double* %2, i64 %128
%130 = load double, double* %129
%131 = getelementptr inbounds double, double* %3, i64 %128
%132 = load double, double* %131
%133 = fmul double %130, %132
%134 = getelementptr inbounds double, double* %11, i64 %128
store double %133, double* %134
%135 = add nuw nsw i64 %128, 1
%136 = getelementptr inbounds double, double* %2, i64 %135
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %3, i64 %135
%139 = load double, double* %138
%140 = fmul double %137, %139
%141 = getelementptr inbounds double, double* %11, i64 %135
store double %140, double* %141
%142 = add nuw nsw i64 %128, 2
%143 = getelementptr inbounds double, double* %2, i64 %142
%144 = load double, double* %143
%145 = getelementptr inbounds double, double* %3, i64 %142
%146 = load double, double* %145
%147 = fmul double %144, %146
%148 = getelementptr inbounds double, double* %11, i64 %142
store double %147, double* %148
%149 = add nuw nsw i64 %128, 3
%150 = getelementptr inbounds double, double* %2, i64 %149
%151 = load double, double* %150
%152 = getelementptr inbounds double, double* %3, i64 %149
%153 = load double, double* %152
%154 = fmul double %151, %153
%155 = getelementptr inbounds double, double* %11, i64 %149
store double %154, double* %155
%156 = add nuw nsw i64 %128, 4
%157 = icmp eq i64 %156, %15
br i1 %157, label %158, label %127
158: ; preds = %124, %127, %104, %5
%159 = call i32 @trapz(i32* %0, i32* %6, double* %1, double* %11, double* %4)
%160 = call i32 @free(double* %11)
ret void
}