; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @r8vec_cheby_zero_new(i32 noundef %0, double noundef %1, double noundef %2) #4 {
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store double 0x400921FB54442D18, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = mul i64 %13, 8
  %15 = call noalias ptr @malloc(i64 noundef %14) #6
  store ptr %15, ptr %11, align 8, !tbaa !11
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %25

18:                                               ; preds = %3
  %19 = load double, ptr %5, align 8, !tbaa !9
  %20 = load double, ptr %6, align 8, !tbaa !9
  %21 = fadd double %19, %20
  %22 = fdiv double %21, 2.000000e+00
  %23 = load ptr, ptr %11, align 8, !tbaa !11
  %24 = getelementptr inbounds double, ptr %23, i64 0
  store double %22, ptr %24, align 8, !tbaa !9
  br label %73

25:                                               ; preds = %3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %69, %25
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %72

30:                                               ; preds = %26
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = sub nsw i32 %31, %32
  %34 = mul nsw i32 2, %33
  %35 = sub nsw i32 %34, 1
  %36 = sitofp i32 %35 to double
  %37 = fmul double %36, 0x400921FB54442D18
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = mul nsw i32 2, %38
  %40 = sitofp i32 %39 to double
  %41 = fdiv double %37, %40
  store double %41, ptr %10, align 8, !tbaa !9
  %42 = load double, ptr %10, align 8, !tbaa !9
  %43 = call double @cos(double noundef %42) #5
  store double %43, ptr %7, align 8, !tbaa !9
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = srem i32 %44, 2
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %55

47:                                               ; preds = %30
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = mul nsw i32 2, %48
  %50 = add nsw i32 %49, 1
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = icmp eq i32 %50, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %47
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %53, %47
  br label %55

55:                                               ; preds = %54, %30
  %56 = load double, ptr %7, align 8, !tbaa !9
  %57 = fsub double 1.000000e+00, %56
  %58 = load double, ptr %5, align 8, !tbaa !9
  %59 = load double, ptr %7, align 8, !tbaa !9
  %60 = fadd double 1.000000e+00, %59
  %61 = load double, ptr %6, align 8, !tbaa !9
  %62 = fmul double %60, %61
  %63 = call double @llvm.fmuladd.f64(double %57, double %58, double %62)
  %64 = fdiv double %63, 2.000000e+00
  %65 = load ptr, ptr %11, align 8, !tbaa !11
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %65, i64 %67
  store double %64, ptr %68, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %55
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !5
  br label %26, !llvm.loop !13

72:                                               ; preds = %26
  br label %73

73:                                               ; preds = %72, %18
  %74 = load ptr, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %74
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

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

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

; Function Attrs: nofree nounwind memory(write, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @r8vec_cheby_zero_new(i32 noundef %0, double noundef %1, double noundef %2) local_unnamed_addr #3 {
  %4 = sext i32 %0 to i64
  %5 = shl nsw i64 %4, 3
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #4
  %7 = icmp eq i32 %0, 1
  br i1 %7, label %28, label %.preheader

.preheader:                                       ; preds = %3
  %8 = icmp sgt i32 %0, 0
  br i1 %8, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %9 = shl nuw nsw i32 %0, 1
  %10 = uitofp nneg i32 %9 to double
  %11 = and i32 %0, 1
  %.not = icmp eq i32 %11, 0
  %wide.trip.count29 = zext nneg i32 %0 to i64
  br i1 %.not, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %12 = trunc i64 %indvars.iv to i32
  %.tr = sub i32 %0, %12
  %13 = shl i32 %.tr, 1
  %14 = add i32 %13, -1
  %15 = sitofp i32 %14 to double
  %16 = fmul double %15, 0x400921FB54442D18
  %17 = fdiv double %16, %10
  %18 = tail call double @cos(double noundef %17) #5
  %19 = shl nuw nsw i64 %indvars.iv, 1
  %20 = or disjoint i64 %19, 1
  %21 = icmp eq i64 %20, %wide.trip.count29
  %.0.us = select i1 %21, double 0.000000e+00, double %18
  %22 = fsub double 1.000000e+00, %.0.us
  %23 = fadd double %.0.us, 1.000000e+00
  %24 = fmul double %23, %2
  %25 = tail call double @llvm.fmuladd.f64(double %22, double %1, double %24)
  %26 = fmul double %25, 5.000000e-01
  %27 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  store double %26, ptr %27, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count29
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !9

28:                                               ; preds = %3
  %29 = fadd double %1, %2
  %30 = fmul double %29, 5.000000e-01
  store double %30, ptr %6, align 8, !tbaa !5
  br label %.loopexit

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph.split ], [ 0, %.lr.ph ]
  %31 = trunc i64 %indvars.iv26 to i32
  %.tr31 = sub i32 %0, %31
  %32 = shl i32 %.tr31, 1
  %33 = add i32 %32, -1
  %34 = sitofp i32 %33 to double
  %35 = fmul double %34, 0x400921FB54442D18
  %36 = fdiv double %35, %10
  %37 = tail call double @cos(double noundef %36) #5
  %38 = fsub double 1.000000e+00, %37
  %39 = fadd double %37, 1.000000e+00
  %40 = fmul double %39, %2
  %41 = tail call double @llvm.fmuladd.f64(double %38, double %1, double %40)
  %42 = fmul double %41, 5.000000e-01
  %43 = getelementptr inbounds double, ptr %6, i64 %indvars.iv26
  store double %42, ptr %43, align 8, !tbaa !5
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count29
  br i1 %exitcond30.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !9

.loopexit:                                        ; preds = %.lr.ph.split.us, %.lr.ph.split, %.preheader, %28
  ret ptr %6
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #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 = { 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 #4 = { nounwind allocsize(0) }
attributes #5 = { 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 = !{!"double", !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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass