#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*/ conv(double *, int, double *, int, double *, int);
int /*<<< orphan*/ free(double *);
double *malloc(int);
void i_conv(double *sigIn, int sigInLength, double *sigOut, int sigOutLength,
            double *filter, int filterLength) {
  int count = 0;
  int bufferLength = 0;
  int outLength = 0;
  double *pBuf;
  double *pOutBuf;
  bufferLength = 2 * sigInLength;
  pBuf = malloc(bufferLength * sizeof(double));
  for (count = 0; count < sigInLength; count++) {
    pBuf[count] = sigIn[count];
    pBuf[count + sigInLength] = sigIn[count];
  }
  outLength = filterLength + 2 * sigInLength - 1;
  pOutBuf = malloc(outLength * sizeof(double));
  conv(pBuf, bufferLength, pOutBuf, outLength, filter, filterLength);
  free(pBuf);
  for (count = 0; count < sigOutLength; count++)
    sigOut[count] = pOutBuf[filterLength + count];
  free(pOutBuf);
  return;
}


x86 assembly (clang, -O0):
<i_conv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d9 <i_conv+0xa9>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1186 <i_conv+0x56>
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x38(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
call   1040 <conv@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1261 <i_conv+0x131>
mov    -0x48(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1228 <i_conv+0xf8>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i_conv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r15d
mov    %r8,0x10(%rsp)
mov    %ecx,%r12d
mov    %rdx,0x8(%rsp)
mov    %esi,%ebx
mov    %rdi,%r14
lea    (%rbx,%rbx,1),%r13d
mov    %esi,%edi
shl    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
test   %ebx,%ebx
jle    125a <i_conv+0x11a>
mov    %ebx,%eax
cmp    $0x4,%ebx
jae    118a <i_conv+0x4a>
xor    %ecx,%ecx
jmp    1234 <i_conv+0xf4>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rdx,%rdx
je     12c9 <i_conv+0x189>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
lea    0x30(%rbp),%rbx
lea    0x30(,%rax,8),%rdx
add    %rbp,%rdx
xor    %esi,%esi
nop
movups (%r14,%rsi,8),%xmm0
movups 0x10(%r14,%rsi,8),%xmm1
movups %xmm0,-0x30(%rbx,%rsi,8)
movups %xmm1,-0x20(%rbx,%rsi,8)
movups %xmm0,-0x30(%rdx,%rsi,8)
movups %xmm1,-0x20(%rdx,%rsi,8)
movups 0x20(%r14,%rsi,8),%xmm0
movups 0x30(%r14,%rsi,8),%xmm1
movups %xmm0,-0x10(%rbx,%rsi,8)
movups %xmm1,(%rbx,%rsi,8)
movups %xmm0,-0x10(%rdx,%rsi,8)
movups %xmm1,(%rdx,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    11c0 <i_conv+0x80>
test   $0x1,%r8b
je     122f <i_conv+0xef>
movups (%r14,%rsi,8),%xmm0
movups 0x10(%r14,%rsi,8),%xmm1
movups %xmm0,0x0(%rbp,%rsi,8)
movups %xmm1,0x10(%rbp,%rsi,8)
add    %rax,%rsi
movups %xmm0,0x0(%rbp,%rsi,8)
movups %xmm1,0x10(%rbp,%rsi,8)
cmp    %rax,%rcx
je     125a <i_conv+0x11a>
lea    0x0(,%rax,8),%rdx
add    %rbp,%rdx
nop
movsd  (%r14,%rcx,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rcx,8)
movsd  %xmm0,(%rdx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1240 <i_conv+0x100>
lea    (%r15,%r13,1),%eax
lea    (%r15,%r13,1),%r14d
add    $0xffffffff,%r14d
lea    -0x8(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %rax,%rdx
mov    %r14d,%ecx
mov    0x10(%rsp),%r8
mov    %r15d,%r9d
call   1040 <conv@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
test   %r12d,%r12d
jle    12b3 <i_conv+0x173>
movslq %r15d,%rax
lea    (%rbx,%rax,8),%rsi
mov    %r12d,%edx
shl    $0x3,%rdx
mov    0x8(%rsp),%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
xor    %esi,%esi
test   $0x1,%r8b
jne    120d <i_conv+0xcd>
jmp    122f <i_conv+0xef>

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

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