; LLVM IR from Discngine/fpocket :: src (asa)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @get_points_on_sphere(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr null, ptr %3, align 8, !tbaa !9
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = mul i64 4, %11
  %13 = mul i64 %12, 3
  %14 = call noalias ptr @malloc(i64 noundef %13) #5
  store ptr %14, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %15 = call double @sqrt(double noundef 5.000000e+00) #4
  %16 = fsub double 3.000000e+00, %15
  %17 = fmul double 0x400921FB54442D18, %16
  %18 = fptrunc double %17 to float
  store float %18, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sitofp i32 %19 to float
  %21 = fpext float %20 to double
  %22 = fdiv double 2.000000e+00, %21
  %23 = fptrunc double %22 to float
  store float %23, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %83, %1
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %86

28:                                               ; preds = %24
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = sitofp i32 %29 to float
  %31 = load float, ptr %5, align 4, !tbaa !11
  %32 = fmul float %30, %31
  %33 = fpext float %32 to double
  %34 = fsub double %33, 1.000000e+00
  %35 = load float, ptr %5, align 4, !tbaa !11
  %36 = fpext float %35 to double
  %37 = fdiv double %36, 2.000000e+00
  %38 = fadd double %34, %37
  %39 = fptrunc double %38 to float
  store float %39, ptr %6, align 4, !tbaa !11
  %40 = load float, ptr %6, align 4, !tbaa !11
  %41 = load float, ptr %6, align 4, !tbaa !11
  %42 = fmul float %40, %41
  %43 = fpext float %42 to double
  %44 = fsub double 1.000000e+00, %43
  %45 = call double @sqrt(double noundef %44) #4
  %46 = fptrunc double %45 to float
  store float %46, ptr %7, align 4, !tbaa !11
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = sitofp i32 %47 to float
  %49 = load float, ptr %4, align 4, !tbaa !11
  %50 = fmul float %48, %49
  store float %50, ptr %8, align 4, !tbaa !11
  %51 = load float, ptr %8, align 4, !tbaa !11
  %52 = fpext float %51 to double
  %53 = call double @cos(double noundef %52) #4
  %54 = load float, ptr %7, align 4, !tbaa !11
  %55 = fpext float %54 to double
  %56 = fmul double %53, %55
  %57 = fptrunc double %56 to float
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !5
  %60 = mul nsw i32 3, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %58, i64 %61
  store float %57, ptr %62, align 4, !tbaa !11
  %63 = load float, ptr %6, align 4, !tbaa !11
  %64 = load ptr, ptr %3, align 8, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = mul nsw i32 3, %65
  %67 = add nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %64, i64 %68
  store float %63, ptr %69, align 4, !tbaa !11
  %70 = load float, ptr %8, align 4, !tbaa !11
  %71 = fpext float %70 to double
  %72 = call double @sin(double noundef %71) #4
  %73 = load float, ptr %7, align 4, !tbaa !11
  %74 = fpext float %73 to double
  %75 = fmul double %72, %74
  %76 = fptrunc double %75 to float
  %77 = load ptr, ptr %3, align 8, !tbaa !9
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = mul nsw i32 3, %78
  %80 = add nsw i32 %79, 2
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds float, ptr %77, i64 %81
  store float %76, ptr %82, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %28
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %9, align 4, !tbaa !5
  br label %24, !llvm.loop !13

86:                                               ; preds = %24
  %87 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %87
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(write, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @get_points_on_sphere(i32 noundef %0) local_unnamed_addr #1 {
  %2 = sext i32 %0 to i64
  %3 = mul nsw i64 %2, 12
  %4 = tail call noalias ptr @malloc(i64 noundef %3) #3
  %5 = sitofp i32 %0 to float
  %6 = fdiv float 2.000000e+00, %5
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %8 = fpext float %6 to double
  %9 = fmul double %8, 5.000000e-01
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %11 = trunc nuw nsw i64 %indvars.iv to i32
  %12 = uitofp nneg i32 %11 to float
  %13 = fmul float %6, %12
  %14 = fpext float %13 to double
  %15 = fadd double %14, -1.000000e+00
  %16 = fadd double %9, %15
  %17 = fptrunc double %16 to float
  %18 = fmul float %17, %17
  %19 = fpext float %18 to double
  %20 = fsub double 1.000000e+00, %19
  %21 = tail call double @sqrt(double noundef %20) #4
  %22 = fptrunc double %21 to float
  %23 = fmul float %12, 0x4003331FE0000000
  %24 = fpext float %23 to double
  %25 = tail call double @cos(double noundef %24) #4
  %26 = fpext float %22 to double
  %27 = fmul double %25, %26
  %28 = fptrunc double %27 to float
  %.idx = mul i64 %indvars.iv, 12
  %29 = getelementptr inbounds i8, ptr %4, i64 %.idx
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 4
  store float %17, ptr %30, align 4, !tbaa !5
  %31 = tail call double @sin(double noundef %24) #4
  %32 = fmul double %31, %26
  %33 = fptrunc double %32 to float
  %34 = getelementptr inbounds i8, ptr %29, i64 8
  store float %33, ptr %34, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !9

._crit_edge:                                      ; preds = %10, %1
  ret ptr %4
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind memory(write, inaccessiblemem: readwrite) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind allocsize(0) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass