#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 */
scalar_t__ floor(double);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, unsigned int);
void partial_linear_stacks(double *dsigN, float *sigall, double *w,
                           unsigned int max, unsigned int nsamp,
                           unsigned int Kmax, unsigned int mtr) {
  unsigned int itr, gtr, n;
  float *sig;
  double da1, *pd1;
  memset(dsigN, 0, Kmax * max * sizeof(double));
  for (itr = 0; itr < mtr; itr++) {
    sig = sigall + itr * max;
    gtr = (unsigned int)floor((double)(itr * Kmax) / (double)mtr);
    pd1 = dsigN + gtr * max;
    da1 = (w != NULL) ? w[itr] : 1;
    for (n = 0; n < nsamp; n++)
      pd1[n] += da1 * (double)sig[n];
  }
}


x86 assembly (clang, -O0):
<partial_linear_stacks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    0x10(%rbp),%eax
jae    125d <partial_linear_stacks+0x13d>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   %edx,%ecx
lea    (%rax,%rcx,4),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
mov    0x10(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11df <partial_linear_stacks+0xbf>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11f1 <partial_linear_stacks+0xd1>
movsd  0xe19(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    11f1 <partial_linear_stacks+0xd1>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    124a <partial_linear_stacks+0x12a>
movsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm2
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1202 <partial_linear_stacks+0xe2>
jmp    124f <partial_linear_stacks+0x12f>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1163 <partial_linear_stacks+0x43>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partial_linear_stacks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %rdx,0x60(%rsp)
mov    %rsi,0x8(%rsp)
mov    0xa0(%rsp),%ebp
mov    %ecx,%edx
mov    %r9d,0x14(%rsp)
imul   %r9d,%edx
shl    $0x3,%edx
xor    %r12d,%r12d
mov    %rdi,0x18(%rsp)
xor    %esi,%esi
call   1030 <memset@plt>
test   %ebp,%ebp
je     1374 <partial_linear_stacks+0x254>
mov    %ebp,%ebp
cvtsi2sd %rbp,%xmm0
movsd  %xmm0,0x58(%rsp)
mov    %r15d,%r14d
mov    %r14d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x48(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x40(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x38(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x30(%rsp)
mov    0x8(%rsp),%rax
add    $0x18,%rax
mov    %rax,0x28(%rsp)
mov    0x18(%rsp),%rax
add    $0x30,%rax
mov    %rax,0x20(%rsp)
xor    %r13d,%r13d
mov    %rbp,0x50(%rsp)
jmp    11e0 <partial_linear_stacks+0xc0>
nop
add    $0x1,%r13
add    %ebx,%r12d
cmp    %rbp,%r13
je     1374 <partial_linear_stacks+0x254>
mov    %r13d,%eax
imul   0x14(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x58(%rsp),%xmm0
call   1040 <floor@plt>
movsd  0xdfd(%rip),%xmm0
mov    0x60(%rsp),%rcx
test   %rcx,%rcx
je     1213 <partial_linear_stacks+0xf3>
movsd  (%rcx,%r13,8),%xmm0
test   %r15d,%r15d
je     11d0 <partial_linear_stacks+0xb0>
imul   %ebx,%eax
mov    %r12d,%edx
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
cmp    $0x4,%r15d
jae    1240 <partial_linear_stacks+0x120>
xor    %eax,%eax
jmp    1336 <partial_linear_stacks+0x216>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x40(%rsp)
je     1365 <partial_linear_stacks+0x245>
mov    0x28(%rsp),%rsi
lea    (%rsi,%rdx,4),%rsi
mov    0x20(%rsp),%rdi
lea    (%rdi,%rax,8),%rdi
mov    0x30(%rsp),%rbp
xor    %eax,%eax
nopl   (%rax)
cvtps2pd -0x18(%rsi,%rax,4),%xmm2
cvtps2pd -0x10(%rsi,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
movupd -0x30(%rdi,%rax,8),%xmm4
addpd  %xmm2,%xmm4
movupd -0x20(%rdi,%rax,8),%xmm2
movupd -0x10(%rdi,%rax,8),%xmm5
movupd (%rdi,%rax,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,-0x30(%rdi,%rax,8)
movupd %xmm3,-0x20(%rdi,%rax,8)
cvtps2pd -0x8(%rsi,%rax,4),%xmm2
cvtps2pd (%rsi,%rax,4),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,-0x10(%rdi,%rax,8)
movupd %xmm3,(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rbp
jne    1270 <partial_linear_stacks+0x150>
testb  $0x1,0x38(%rsp)
je     1320 <partial_linear_stacks+0x200>
mov    %r13d,%esi
imul   %ebx,%esi
mov    0x8(%rsp),%rdi
lea    (%rdi,%rsi,4),%rsi
cvtps2pd (%rsi,%rax,4),%xmm2
cvtps2pd 0x8(%rsi,%rax,4),%xmm3
movupd (%rcx,%rax,8),%xmm4
movupd 0x10(%rcx,%rax,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rcx,%rax,8)
movupd %xmm3,0x10(%rcx,%rax,8)
mov    0x48(%rsp),%rsi
mov    %rsi,%rax
cmp    %r14,%rsi
mov    0x50(%rsp),%rbp
je     11d0 <partial_linear_stacks+0xb0>
mov    0x8(%rsp),%rsi
lea    (%rsi,%rdx,4),%rdx
nop
movss  (%rdx,%rax,4),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,(%rcx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r14
jne    1340 <partial_linear_stacks+0x220>
jmp    11d0 <partial_linear_stacks+0xb0>
xor    %eax,%eax
testb  $0x1,0x38(%rsp)
jne    12e2 <partial_linear_stacks+0x1c2>
jmp    1320 <partial_linear_stacks+0x200>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @partial_linear_stacks(double* %0, float* %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca double*
%9 = alloca float*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca float*
%19 = alloca double
%20 = alloca double*
store double* %0, double** %8
store float* %1, float** %9
store double* %2, double** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%21 = load double*, double** %8
%22 = load i32, i32* %13
%23 = load i32, i32* %11
%24 = mul i32 %22, %23
%25 = zext i32 %24 to i64
%26 = mul i64 %25, 8
%27 = trunc i64 %26 to i32
%28 = call i32 @memset(double* %21, i32 0, i32 %27)
store i32 0, i32* %15
br label %29
29: ; preds = %88, %7
%30 = load i32, i32* %15
%31 = load i32, i32* %14
%32 = icmp ult i32 %30, %31
br i1 %32, label %33, label %91
33: ; preds = %29
%34 = load float*, float** %9
%35 = load i32, i32* %15
%36 = load i32, i32* %11
%37 = mul i32 %35, %36
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds float, float* %34, i64 %38
store float* %39, float** %18
%40 = load i32, i32* %15
%41 = load i32, i32* %13
%42 = mul i32 %40, %41
%43 = uitofp i32 %42 to double
%44 = load i32, i32* %14
%45 = uitofp i32 %44 to double
%46 = fdiv double %43, %45
%47 = call i64 @floor(double %46)
%48 = trunc i64 %47 to i32
store i32 %48, i32* %16
%49 = load double*, double** %8
%50 = load i32, i32* %16
%51 = load i32, i32* %11
%52 = mul i32 %50, %51
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds double, double* %49, i64 %53
store double* %54, double** %20
%55 = load double*, double** %10
%56 = icmp ne double* %55, null
br i1 %56, label %57, label %63
57: ; preds = %33
%58 = load double*, double** %10
%59 = load i32, i32* %15
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
br label %64
63: ; preds = %33
br label %64
64: ; preds = %63, %57
%65 = phi double [ %62, %57 ], [ 1.000000e+00, %63 ]
store double %65, double* %19
store i32 0, i32* %17
br label %66
66: ; preds = %84, %64
%67 = load i32, i32* %17
%68 = load i32, i32* %12
%69 = icmp ult i32 %67, %68
br i1 %69, label %70, label %87
70: ; preds = %66
%71 = load double, double* %19
%72 = load float*, float** %18
%73 = load i32, i32* %17
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds float, float* %72, i64 %74
%76 = load float, float* %75
%77 = fpext float %76 to double
%78 = load double*, double** %20
%79 = load i32, i32* %17
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load double, double* %81
%83 = call double @llvm.fmuladd.f64(double %71, double %77, double %82)
store double %83, double* %81
br label %84
84: ; preds = %70
%85 = load i32, i32* %17
%86 = add i32 %85, 1
store i32 %86, i32* %17
br label %66
87: ; preds = %66
br label %88
88: ; preds = %87
%89 = load i32, i32* %15
%90 = add i32 %89, 1
store i32 %90, i32* %15
br label %29
91: ; preds = %29
ret void
}

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