#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*/ Forward_SO3_Naive(int, double *, double *, double *,
                                     double *, double *, double *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
void Forward_SO3_Naive_W(int bw, double *rsignal, double *isignal,
                         double *rcoeffs, double *icoeffs) {
  int n, n3;
  double *workspace1, *workspace2;
  n = 2 * bw;
  n3 = n * n * n;
  workspace1 = (double *)malloc(sizeof(double) * 4 * n3);
  workspace2 = (double *)malloc(sizeof(double) * (26 * bw + 2 * bw * bw));
  if ((workspace1 == NULL) || (workspace2 == NULL)) {
    perror("Error in allocating memory");
    exit(1);
  }
  Forward_SO3_Naive(bw, rsignal, isignal, rcoeffs, icoeffs, workspace1,
                    workspace2);
  free(workspace2);
  free(workspace1);
}


x86 assembly (clang, -O0):
<Forward_SO3_Naive_W>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x5,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
imul   $0x1a,-0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
imul   -0x4(%rbp),%ecx
add    %ecx,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11cc <Forward_SO3_Naive_W+0x7c>
cmpq   $0x0,-0x40(%rbp)
jne    11e2 <Forward_SO3_Naive_W+0x92>
lea    0xe2d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <Forward_SO3_Naive@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Forward_SO3_Naive_W>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%ebx
lea    (%rbx,%rbx,1),%eax
imul   %eax,%edi
imul   %eax,%edi
shl    $0x6,%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
lea    (%rbx,%rbx,1),%edi
add    $0x1a,%edi
imul   %ebx,%edi
shl    $0x3,%edi
call   1040 <malloc@plt>
test   %rbp,%rbp
je     11da <Forward_SO3_Naive_W+0x8a>
mov    %rax,%r14
test   %rax,%rax
je     11da <Forward_SO3_Naive_W+0x8a>
mov    %r14,(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    0x10(%rsp),%r8
mov    %rbp,%r9
call   1050 <Forward_SO3_Naive@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xe1f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Error in allocating memory\00"
define void @Forward_SO3_Naive_W(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 i32
%13 = alloca double*
%14 = alloca double*
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 = mul nsw i32 2, %15
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = load i32, i32* %11
%19 = mul nsw i32 %17, %18
%20 = load i32, i32* %11
%21 = mul nsw i32 %19, %20
store i32 %21, i32* %12
%22 = load i32, i32* %12
%23 = sext i32 %22 to i64
%24 = mul i64 32, %23
%25 = trunc i64 %24 to i32
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to double*
store double* %27, double** %13
%28 = load i32, i32* %6
%29 = mul nsw i32 26, %28
%30 = load i32, i32* %6
%31 = mul nsw i32 2, %30
%32 = load i32, i32* %6
%33 = mul nsw i32 %31, %32
%34 = add nsw i32 %29, %33
%35 = sext i32 %34 to i64
%36 = mul i64 8, %35
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %14
%40 = load double*, double** %13
%41 = icmp eq double* %40, null
br i1 %41, label %45, label %42
42: ; preds = %5
%43 = load double*, double** %14
%44 = icmp eq double* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42, %5
%46 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %42
%49 = load i32, i32* %6
%50 = load double*, double** %7
%51 = load double*, double** %8
%52 = load double*, double** %9
%53 = load double*, double** %10
%54 = load double*, double** %13
%55 = load double*, double** %14
%56 = call i32 @Forward_SO3_Naive(i32 %49, double* %50, double* %51, double* %52, double* %53, double* %54, double* %55)
%57 = load double*, double** %14
%58 = call i32 @free(double* %57)
%59 = load double*, double** %13
%60 = call i32 @free(double* %59)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Error in allocating memory\00"
define void @Forward_SO3_Naive_W(i32 %0, double* %1, double* %2, double* %3, double* %4) {
%6 = shl nsw i32 %0, 1
%7 = shl i32 %0, 6
%8 = mul i32 %7, %6
%9 = mul i32 %8, %6
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double*
%12 = add i32 %6, 26
%13 = shl i32 %0, 3
%14 = mul i32 %13, %12
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
%17 = icmp eq i64 %10, 0
%18 = icmp eq i64 %15, 0
%19 = select i1 %17, i1 true, i1 %18
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %5
%24 = tail call i32 @Forward_SO3_Naive(i32 %0, double* %1, double* %2, double* %3, double* %4, double* %11, double* %16)
%25 = tail call i32 @free(double* %16)
%26 = tail call i32 @free(double* %11)
ret void
}