#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CosEvalPts2(int, double *);
int /*<<< orphan*/ SinEvalPts2(int, double *);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ wigSpec_L2(int, int, double *, double *, int, double *);
int main(int argc, char **argv) {
  int i, m1, m2, bw, n;
  double *workspace;
  double *sinPts, *cosPts, *result;
  FILE *fp;
  if (argc < 5) {
    fprintf(stdout, "Usage: test_wigSpec m1 m2 bw output_file_name\n");
    exit(0);
  }
  m1 = atoi(argv[1]);
  m2 = atoi(argv[2]);
  bw = atoi(argv[3]);
  n = 2 * bw;
  workspace = (double *)malloc(sizeof(double) * 3 * n);
  sinPts = workspace;
  cosPts = sinPts + n;
  result = cosPts + n;
  SinEvalPts2(n, sinPts);
  CosEvalPts2(n, cosPts);
  wigSpec_L2(m1, m2, sinPts, cosPts, n, result);
  fp = fopen(argv[4], "w");
  for (i = 0; i < n; i++)
    fprintf(fp, "%.15f\n", result[i]);
  fclose(fp);
  free(workspace);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11df <main+0x3f>
mov    0x2e19(%rip),%rax
movslq (%rax),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
imul   $0x18,%rax,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   1060 <SinEvalPts2@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
call   1040 <CosEvalPts2@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x48(%rbp),%r9
call   1090 <wigSpec_L2@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xd94(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12e4 <main+0x144>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd62(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12ab <main+0x10b>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x4,%edi
jle    12bf <main+0x10f>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
call   10b0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    0x10(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x18(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r12d
lea    (%r12,%r12,1),%eax
mov    %eax,0x10(%rsp)
movslq %eax,%r13
mov    %r12d,%eax
shl    $0x4,%eax
lea    (%rax,%rax,2),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    (%rax,%r13,8),%rbp
lea    0x0(,%r13,8),%r14
add    %rbp,%r14
mov    %r13d,%edi
mov    %rax,%rsi
call   1060 <SinEvalPts2@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
call   1040 <CosEvalPts2@plt>
mov    0x8(%rsp),%edi
mov    0x14(%rsp),%esi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r13d,%r8d
mov    %r14,%r9
call   1090 <wigSpec_L2@plt>
mov    0x20(%r15),%rdi
lea    0xdd5(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r13
test   %r12d,%r12d
jle    129c <main+0xec>
mov    0x10(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
xor    %ebp,%ebp
lea    0xdb2(%rip),%r15
nop
movsd  (%r14,%rbp,8),%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1280 <main+0xd0>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d1a(%rip),%rax
movslq (%rax),%rcx
lea    0xd30(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [47 x i8] c"Usage: test_wigSpec m1 m2 bw output_file_name\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%.15f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 5
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stdout
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = mul nsw i32 2, %37
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = mul i64 24, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
store double* %44, double** %11
%45 = load double*, double** %11
store double* %45, double** %12
%46 = load double*, double** %12
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double* %49, double** %13
%50 = load double*, double** %13
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double* %53, double** %14
%54 = load i32, i32* %10
%55 = load double*, double** %12
%56 = call i32 @SinEvalPts2(i32 %54, double* %55)
%57 = load i32, i32* %10
%58 = load double*, double** %13
%59 = call i32 @CosEvalPts2(i32 %57, double* %58)
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = load double*, double** %12
%63 = load double*, double** %13
%64 = load i32, i32* %10
%65 = load double*, double** %14
%66 = call i32 @wigSpec_L2(i32 %60, i32 %61, double* %62, double* %63, i32 %64, double* %65)
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 4
%69 = load i8*, i8** %68
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %70, i32** %15
store i32 0, i32* %6
br label %71
71: ; preds = %83, %24
%72 = load i32, i32* %6
%73 = load i32, i32* %10
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %86
75: ; preds = %71
%76 = load i32*, i32** %15
%77 = load double*, double** %14
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %81)
br label %83
83: ; preds = %75
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %71
86: ; preds = %71
%87 = load i32*, i32** %15
%88 = call i32 @fclose(i32* %87)
%89 = load double*, double** %11
%90 = call i32 @free(double* %89)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [47 x i8] c"Usage: test_wigSpec m1 m2 bw output_file_name\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%.15f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i64 46, i64 1, i32* %7)
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = shl i32 %19, 1
%21 = sext i32 %20 to i64
%22 = mul i32 %19, 48
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = getelementptr inbounds double, double* %24, i64 %21
%26 = getelementptr inbounds double, double* %25, i64 %21
%27 = tail call i32 @SinEvalPts2(i32 %20, double* %24)
%28 = tail call i32 @CosEvalPts2(i32 %20, double* %25)
%29 = tail call i32 @wigSpec_L2(i32 %13, i32 %16, double* %24, double* %25, i32 %20, double* %26)
%30 = getelementptr inbounds i8*, i8** %1, i64 4
%31 = load i8*, i8** %30
%32 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp sgt i32 %19, 0
br i1 %33, label %34, label %44
34: ; preds = %10
%35 = call i32 @llvm.smax.i32(i32 %20, i32 1)
%36 = zext i32 %35 to i64
br label %37
37: ; preds = %34, %37
%38 = phi i64 [ 0, %34 ], [ %42, %37 ]
%39 = getelementptr inbounds double, double* %26, i64 %38
%40 = load double, double* %39
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %40)
%42 = add nuw nsw i64 %38, 1
%43 = icmp eq i64 %42, %36
br i1 %43, label %44, label %37
44: ; preds = %37, %10
%45 = tail call i32 @fclose(i32* %32)
%46 = tail call i32 @free(double* %24)
ret i32 0
}