#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 */
double sqrt(int);
scalar_t__ util_malloc_(int);
double *sharp_Ylmgen_get_norm(int lmax, int spin) {
  const double pi = 3.141592653589793238462643383279502884197;
  double *res = ((double *)util_malloc_((lmax + 1) * sizeof(double)));
  double spinsign = (spin > 0) ? -1.0 : 1.0;
  if (spin == 0) {
    for (int l = 0; l <= lmax; ++l)
      res[l] = 1.;
    return res;
  }
  spinsign = (spin & 1) ? -spinsign : spinsign;
  for (int l = 0; l <= lmax; ++l)
    res[l] = (l < spin) ? 0. : spinsign * 0.5 * sqrt((2 * l + 1) / (4 * pi));
  return res;
}


x86 assembly (clang, -O0):
<sharp_Ylmgen_get_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  0xeda(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <util_malloc_@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
movsd  0xea3(%rip),%xmm0
movsd  0xea3(%rip),%xmm1
movsd  %xmm1,-0x40(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x38(%rbp)
jg     1182 <sharp_Ylmgen_get_norm+0x62>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11d9 <sharp_Ylmgen_get_norm+0xb9>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11cc <sharp_Ylmgen_get_norm+0xac>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe4f(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119d <sharp_Ylmgen_get_norm+0x7d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12bb <sharp_Ylmgen_get_norm+0x19b>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     120e <sharp_Ylmgen_get_norm+0xee>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1218 <sharp_Ylmgen_get_norm+0xf8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12b3 <sharp_Ylmgen_get_norm+0x193>
mov    -0x30(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    124e <sharp_Ylmgen_get_norm+0x12e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1293 <sharp_Ylmgen_get_norm+0x173>
movsd  0xdca(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x30(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xda3(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1229 <sharp_Ylmgen_get_norm+0x109>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sharp_Ylmgen_get_norm>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%r14d
lea    0x8(,%r14,8),%edi
call   1030 <util_malloc_@plt>
mov    %rax,%r12
xor    %eax,%eax
test   %ebp,%ebp
setg   %cl
je     11d2 <sharp_Ylmgen_get_norm+0xb2>
test   %r14d,%r14d
js     130d <sharp_Ylmgen_get_norm+0x1ed>
mov    %cl,%al
lea    0xea0(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm1
test   $0x1,%bpl
je     1173 <sharp_Ylmgen_get_norm+0x53>
xorpd  0xe9d(%rip),%xmm1
mulsd  0xeb5(%rip),%xmm1
movslq %ebp,%r15
add    $0x1,%r14d
mov    $0x1,%ebp
xor    %ebx,%ebx
movapd %xmm1,(%rsp)
jmp    11a6 <sharp_Ylmgen_get_norm+0x86>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
add    $0x2,%ebp
cmp    %rbx,%r14
je     130d <sharp_Ylmgen_get_norm+0x1ed>
xorpd  %xmm0,%xmm0
cmp    %r15,%rbx
jl     1190 <sharp_Ylmgen_get_norm+0x70>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  0xe7a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
jmp    1190 <sharp_Ylmgen_get_norm+0x70>
test   %r14d,%r14d
js     130d <sharp_Ylmgen_get_norm+0x1ed>
lea    0x1(%r14),%eax
cmp    $0x3,%r14d
jae    11ec <sharp_Ylmgen_get_norm+0xcc>
xor    %ecx,%ecx
jmp    12e9 <sharp_Ylmgen_get_norm+0x1c9>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x7,%edx
cmp    $0x1c,%rdi
jae    1212 <sharp_Ylmgen_get_norm+0xf2>
xor    %edi,%edi
jmp    12b5 <sharp_Ylmgen_get_norm+0x195>
and    $0xfffffffffffffff8,%rsi
xor    %edi,%edi
movapd 0xe00(%rip),%xmm0
movupd %xmm0,(%r12,%rdi,8)
movupd %xmm0,0x10(%r12,%rdi,8)
movupd %xmm0,0x20(%r12,%rdi,8)
movupd %xmm0,0x30(%r12,%rdi,8)
movupd %xmm0,0x40(%r12,%rdi,8)
movupd %xmm0,0x50(%r12,%rdi,8)
movupd %xmm0,0x60(%r12,%rdi,8)
movupd %xmm0,0x70(%r12,%rdi,8)
movupd %xmm0,0x80(%r12,%rdi,8)
movupd %xmm0,0x90(%r12,%rdi,8)
movupd %xmm0,0xa0(%r12,%rdi,8)
movupd %xmm0,0xb0(%r12,%rdi,8)
movupd %xmm0,0xc0(%r12,%rdi,8)
movupd %xmm0,0xd0(%r12,%rdi,8)
movupd %xmm0,0xe0(%r12,%rdi,8)
movupd %xmm0,0xf0(%r12,%rdi,8)
add    $0x20,%rdi
add    $0xfffffffffffffff8,%rsi
jne    1220 <sharp_Ylmgen_get_norm+0x100>
test   %rdx,%rdx
je     12e4 <sharp_Ylmgen_get_norm+0x1c4>
lea    (%r12,%rdi,8),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movapd 0xd50(%rip),%xmm0
movupd %xmm0,-0x10(%rsi,%rdi,1)
movupd %xmm0,(%rsi,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    12d0 <sharp_Ylmgen_get_norm+0x1b0>
cmp    %rax,%rcx
je     130d <sharp_Ylmgen_get_norm+0x1ed>
movabs $0x3ff0000000000000,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rdx,(%r12,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1300 <sharp_Ylmgen_get_norm+0x1e0>
mov    %r12,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @sharp_Ylmgen_get_norm(i32 %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double 0x400921FB54442D18, double* %6
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @util_malloc_(i32 %15)
%17 = inttoptr i64 %16 to double*
store double* %17, double** %7
%18 = load i32, i32* %5
%19 = icmp sgt i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, double -1.000000e+00, double 1.000000e+00
store double %21, double* %8
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %2
store i32 0, i32* %9
br label %25
25: ; preds = %34, %24
%26 = load i32, i32* %9
%27 = load i32, i32* %4
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load double*, double** %7
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double 1.000000e+00, double* %33
br label %34
34: ; preds = %29
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %25
37: ; preds = %25
%38 = load double*, double** %7
store double* %38, double** %3
br label %81
39: ; preds = %2
%40 = load i32, i32* %5
%41 = and i32 %40, 1
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load double, double* %8
%45 = fneg double %44
br label %48
46: ; preds = %39
%47 = load double, double* %8
br label %48
48: ; preds = %46, %43
%49 = phi double [ %45, %43 ], [ %47, %46 ]
store double %49, double* %8
store i32 0, i32* %10
br label %50
50: ; preds = %76, %48
%51 = load i32, i32* %10
%52 = load i32, i32* %4
%53 = icmp sle i32 %51, %52
br i1 %53, label %54, label %79
54: ; preds = %50
%55 = load i32, i32* %10
%56 = load i32, i32* %5
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %59
58: ; preds = %54
br label %70
59: ; preds = %54
%60 = load double, double* %8
%61 = fmul double %60, 5.000000e-01
%62 = load i32, i32* %10
%63 = mul nsw i32 2, %62
%64 = add nsw i32 %63, 1
%65 = sitofp i32 %64 to double
%66 = fdiv double %65, 0x402921FB54442D18
%67 = fptosi double %66 to i32
%68 = call double @sqrt(i32 %67)
%69 = fmul double %61, %68
br label %70
70: ; preds = %59, %58
%71 = phi double [ 0.000000e+00, %58 ], [ %69, %59 ]
%72 = load double*, double** %7
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
store double %71, double* %75
br label %76
76: ; preds = %70
%77 = load i32, i32* %10
%78 = add nsw i32 %77, 1
store i32 %78, i32* %10
br label %50
79: ; preds = %50
%80 = load double*, double** %7
store double* %80, double** %3
br label %81
81: ; preds = %79, %37
%82 = load double*, double** %3
ret double* %82
}

LLVM IR (-O2):
define double* @sharp_Ylmgen_get_norm(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = add i32 %3, 8
%5 = tail call i64 @util_malloc_(i32 %4)
%6 = inttoptr i64 %5 to double*
%7 = icmp sgt i32 %1, 0
%8 = select i1 %7, double -1.000000e+00, double 1.000000e+00
%9 = icmp eq i32 %1, 0
%10 = icmp slt i32 %0, 0
br i1 %9, label %11, label %92
11: ; preds = %2
br i1 %10, label %119, label %12
12: ; preds = %11
%13 = add nuw i32 %0, 1
%14 = zext i32 %13 to i64
%15 = icmp ult i32 %0, 3
br i1 %15, label %85, 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, 7
%22 = icmp ult i64 %18, 28
br i1 %22, label %70, label %23
23: ; preds = %16
%24 = and i64 %20, 9223372036854775800
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %67, %25 ]
%27 = phi i64 [ 0, %23 ], [ %68, %25 ]
%28 = getelementptr inbounds double, double* %6, i64 %26
%29 = bitcast double* %28 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %29
%30 = getelementptr inbounds double, double* %28, i64 2
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %31
%32 = or i64 %26, 4
%33 = getelementptr inbounds double, double* %6, i64 %32
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %34
%35 = getelementptr inbounds double, double* %33, i64 2
%36 = bitcast double* %35 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %36
%37 = or i64 %26, 8
%38 = getelementptr inbounds double, double* %6, i64 %37
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %39
%40 = getelementptr inbounds double, double* %38, i64 2
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %41
%42 = or i64 %26, 12
%43 = getelementptr inbounds double, double* %6, i64 %42
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %46
%47 = or i64 %26, 16
%48 = getelementptr inbounds double, double* %6, i64 %47
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %51
%52 = or i64 %26, 20
%53 = getelementptr inbounds double, double* %6, i64 %52
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %54
%55 = getelementptr inbounds double, double* %53, i64 2
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %56
%57 = or i64 %26, 24
%58 = getelementptr inbounds double, double* %6, i64 %57
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %61
%62 = or i64 %26, 28
%63 = getelementptr inbounds double, double* %6, i64 %62
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %64
%65 = getelementptr inbounds double, double* %63, i64 2
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %66
%67 = add nuw i64 %26, 32
%68 = add i64 %27, 8
%69 = icmp eq i64 %68, %24
br i1 %69, label %70, label %25
70: ; preds = %25, %16
%71 = phi i64 [ 0, %16 ], [ %67, %25 ]
%72 = icmp eq i64 %21, 0
br i1 %72, label %83, label %73
73: ; preds = %70, %73
%74 = phi i64 [ %80, %73 ], [ %71, %70 ]
%75 = phi i64 [ %81, %73 ], [ 0, %70 ]
%76 = getelementptr inbounds double, double* %6, i64 %74
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %77
%78 = getelementptr inbounds double, double* %76, i64 2
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %79
%80 = add nuw i64 %74, 4
%81 = add i64 %75, 1
%82 = icmp eq i64 %81, %21
br i1 %82, label %83, label %73
83: ; preds = %73, %70
%84 = icmp eq i64 %17, %14
br i1 %84, label %119, label %85
85: ; preds = %12, %83
%86 = phi i64 [ 0, %12 ], [ %17, %83 ]
br label %87
87: ; preds = %85, %87
%88 = phi i64 [ %90, %87 ], [ %86, %85 ]
%89 = getelementptr inbounds double, double* %6, i64 %88
store double 1.000000e+00, double* %89
%90 = add nuw nsw i64 %88, 1
%91 = icmp eq i64 %90, %14
br i1 %91, label %119, label %87
92: ; preds = %2
br i1 %10, label %119, label %93
93: ; preds = %92
%94 = and i32 %1, 1
%95 = icmp eq i32 %94, 0
%96 = fneg double %8
%97 = select i1 %95, double %8, double %96
%98 = fmul double %97, 5.000000e-01
%99 = sext i32 %1 to i64
%100 = add nuw i32 %0, 1
%101 = zext i32 %100 to i64
br label %102
102: ; preds = %93, %114
%103 = phi i64 [ 0, %93 ], [ %117, %114 ]
%104 = icmp slt i64 %103, %99
br i1 %104, label %114, label %105
105: ; preds = %102
%106 = trunc i64 %103 to i32
%107 = shl i32 %106, 1
%108 = or i32 %107, 1
%109 = sitofp i32 %108 to double
%110 = fdiv double %109, 0x402921FB54442D18
%111 = fptosi double %110 to i32
%112 = tail call double @sqrt(i32 %111)
%113 = fmul double %98, %112
br label %114
114: ; preds = %102, %105
%115 = phi double [ %113, %105 ], [ 0.000000e+00, %102 ]
%116 = getelementptr inbounds double, double* %6, i64 %103
store double %115, double* %116
%117 = add nuw nsw i64 %103, 1
%118 = icmp eq i64 %117, %101
br i1 %118, label %119, label %102
119: ; preds = %114, %87, %83, %92, %11
ret double* %6
}