#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 *);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
scalar_t__ opj_malloc(int);
int upandconv(double *nXPS, double *LPS, int lenXPS, int lenLPS) {
  int i, j;
  double *tmp = (double *)opj_malloc(2 * lenXPS * sizeof(double));
  memset(tmp, 0, 2 * lenXPS * sizeof(double));
  for (i = 0; i < lenXPS; i++) {
    *(tmp + 2 * i) = *(nXPS + i);
    *(nXPS + i) = 0;
  }
  for (i = 0; i < 2 * lenXPS; i++) {
    for (j = 0; j < lenLPS; j++) {
      *(nXPS + i + j) = *(nXPS + i + j) + *(tmp + i) * *(LPS + j);
    }
  }
  free(tmp);
  return 2 * lenXPS + lenLPS - 1;
}


x86 assembly (clang, -O0):
<upandconv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <opj_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c6 <upandconv+0x96>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <upandconv+0x4d>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1264 <upandconv+0x134>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1251 <upandconv+0x121>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <upandconv+0xb5>
jmp    1256 <upandconv+0x126>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cd <upandconv+0x9d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    -0x18(%rbp),%eax
sub    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upandconv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x0(%r13,%r13,1),%eax
mov    %rax,(%rsp)
mov    %edx,%ebp
shl    $0x4,%ebp
mov    %ebp,%edi
call   1050 <opj_malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
test   %r13d,%r13d
jle    13ab <upandconv+0x27b>
mov    %r13d,%eax
cmp    $0x1,%r13d
jne    1184 <upandconv+0x54>
xor    %ecx,%ecx
jmp    11c4 <upandconv+0x94>
mov    %eax,%edx
and    $0xfffffffe,%edx
lea    0x10(%r12),%rsi
xor    %ecx,%ecx
movsd  (%r15,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rsi)
movq   $0x0,(%r15,%rcx,8)
movsd  0x8(%r15,%rcx,8),%xmm0
movsd  %xmm0,(%rsi)
movq   $0x0,0x8(%r15,%rcx,8)
add    $0x2,%rcx
add    $0x20,%rsi
cmp    %rcx,%rdx
jne    1190 <upandconv+0x60>
test   $0x1,%al
je     11e3 <upandconv+0xb3>
movsd  (%r15,%rcx,8),%xmm0
mov    %rcx,%rax
shl    $0x4,%rax
movsd  %xmm0,(%r12,%rax,1)
movq   $0x0,(%r15,%rcx,8)
test   %r13d,%r13d
jle    13ab <upandconv+0x27b>
mov    (%rsp),%rax
cmp    $0x2,%eax
mov    $0x1,%r8d
cmovge %eax,%r8d
mov    %r14d,%ecx
lea    (%rbx,%rcx,8),%rax
mov    %rax,0x18(%rsp)
mov    %ecx,%eax
and    $0xfffffffc,%eax
mov    %rax,0x10(%rsp)
mov    %rcx,%rax
neg    %rax
mov    %rax,0x20(%rsp)
lea    0x10(%r15),%rbp
lea    0x0(,%rcx,8),%rdx
and    $0xffffffffffffffe0,%rdx
lea    0x8(%r15),%rsi
xor    %edi,%edi
mov    %r14,0x8(%rsp)
jmp    1255 <upandconv+0x125>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdi
add    $0x8,%rbp
add    $0x8,%rsi
cmp    %r8,%rdi
je     13ab <upandconv+0x27b>
test   %r14d,%r14d
jle    1240 <upandconv+0x110>
lea    (%r15,%rdi,8),%r13
cmp    $0x4,%r14d
jae    1270 <upandconv+0x140>
xor    %r9d,%r9d
jmp    1330 <upandconv+0x200>
nopl   0x0(%rax)
mov    %r8,%r14
lea    (%rdi,%rcx,1),%rax
lea    (%r15,%rax,8),%r9
lea    (%r12,%rdi,8),%r8
lea    (%r12,%rdi,8),%rax
add    $0x8,%rax
cmp    %rax,%r13
setb   %al
cmp    %r9,%r8
setb   %r11b
cmp    0x18(%rsp),%r13
setb   %r10b
cmp    %rbx,%r9
seta   %r8b
test   %r11b,%al
jne    131f <upandconv+0x1ef>
mov    $0x0,%r9d
and    %r8b,%r10b
mov    %r14,%r8
mov    0x8(%rsp),%r14
jne    1330 <upandconv+0x200>
movsd  (%r12,%rdi,8),%xmm0
unpcklpd %xmm0,%xmm0
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movupd -0x10(%rbp,%rax,1),%xmm1
movupd 0x0(%rbp,%rax,1),%xmm2
movupd (%rbx,%rax,1),%xmm3
movupd 0x10(%rbx,%rax,1),%xmm4
mulpd  %xmm0,%xmm3
addpd  %xmm1,%xmm3
mulpd  %xmm0,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm3,-0x10(%rbp,%rax,1)
movupd %xmm4,0x0(%rbp,%rax,1)
add    $0x20,%rax
cmp    %rax,%rdx
jne    12d0 <upandconv+0x1a0>
mov    0x10(%rsp),%rax
mov    %rax,%r9
cmp    %rcx,%rax
je     1240 <upandconv+0x110>
jmp    1330 <upandconv+0x200>
xor    %r9d,%r9d
mov    %r14,%r8
mov    0x8(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %r9,%rax
test   $0x1,%cl
je     1359 <upandconv+0x229>
movsd  (%r12,%rdi,8),%xmm0
mulsd  (%rbx,%r9,8),%xmm0
addsd  0x0(%r13,%r9,8),%xmm0
movsd  %xmm0,0x0(%r13,%r9,8)
mov    %r9,%rax
or     $0x1,%rax
not    %r9
cmp    0x20(%rsp),%r9
je     1240 <upandconv+0x110>
nopw   0x0(%rax,%rax,1)
movsd  (%r12,%rdi,8),%xmm0
mulsd  (%rbx,%rax,8),%xmm0
addsd  -0x8(%rsi,%rax,8),%xmm0
movsd  %xmm0,-0x8(%rsi,%rax,8)
movsd  (%r12,%rdi,8),%xmm0
mulsd  0x8(%rbx,%rax,8),%xmm0
addsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
add    $0x2,%rax
cmp    %rax,%rcx
jne    1370 <upandconv+0x240>
jmp    1240 <upandconv+0x110>
mov    %r12,%rdi
call   1030 <free@plt>
mov    (%rsp),%rax
add    %r14d,%eax
add    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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