; 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"

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [28 x i8], align 1

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_norm(i32 noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @r8vec_any_normal(i32 noundef %0, ptr noundef %1) #5 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 2
  br i1 %14, label %15, label %22

15:                                               ; preds = %2
  %16 = load ptr, ptr @stderr, align 8, !tbaa !9
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str) #6
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.160) #6
  %20 = load ptr, ptr @stderr, align 8, !tbaa !9
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.161) #6
  call void @exit(i32 noundef 1) #7
  unreachable

22:                                               ; preds = %2
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = mul i64 %24, 8
  %26 = call noalias ptr @malloc(i64 noundef %25) #8
  store ptr %26, ptr %9, align 8, !tbaa !9
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = call double @r8vec_norm(i32 noundef %27, ptr noundef %28)
  %30 = fcmp oeq double %29, 0.000000e+00
  br i1 %30, label %31, label %37

31:                                               ; preds = %22
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  call void @r8vec_zeros(i32 noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %9, align 8, !tbaa !9
  %35 = getelementptr inbounds double, ptr %34, i64 0
  store double 1.000000e+00, ptr %35, align 8, !tbaa !11
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %36, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %120

37:                                               ; preds = %22
  store i32 -1, ptr %7, align 4, !tbaa !5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !11
  store i32 -1, ptr %8, align 4, !tbaa !5
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %86, %37
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %89

42:                                               ; preds = %38
  %43 = load double, ptr %11, align 8, !tbaa !11
  %44 = call double @llvm.fabs.f64(double %43)
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = call double @llvm.fabs.f64(double %49)
  %51 = fcmp olt double %44, %50
  br i1 %51, label %55, label %52

52:                                               ; preds = %42
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = icmp eq i32 %53, -1
  br i1 %54, label %55, label %85

55:                                               ; preds = %52, %42
  %56 = load double, ptr %10, align 8, !tbaa !11
  %57 = call double @llvm.fabs.f64(double %56)
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %58, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !11
  %63 = call double @llvm.fabs.f64(double %62)
  %64 = fcmp olt double %57, %63
  br i1 %64, label %68, label %65

65:                                               ; preds = %55
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = icmp eq i32 %66, -1
  br i1 %67, label %68, label %77

68:                                               ; preds = %65, %55
  %69 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %69, ptr %8, align 4, !tbaa !5
  %70 = load double, ptr %10, align 8, !tbaa !11
  store double %70, ptr %11, align 8, !tbaa !11
  %71 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %71, ptr %7, align 4, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !9
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !11
  store double %76, ptr %10, align 8, !tbaa !11
  br label %84

77:                                               ; preds = %65
  %78 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %78, ptr %8, align 4, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %79, i64 %81
  %83 = load double, ptr %82, align 8, !tbaa !11
  store double %83, ptr %11, align 8, !tbaa !11
  br label %84

84:                                               ; preds = %77, %68
  br label %85

85:                                               ; preds = %84, %52
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %6, align 4, !tbaa !5
  br label %38, !llvm.loop !13

89:                                               ; preds = %38
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = load ptr, ptr %9, align 8, !tbaa !9
  call void @r8vec_zeros(i32 noundef %90, ptr noundef %91)
  %92 = load double, ptr %11, align 8, !tbaa !11
  %93 = fneg double %92
  %94 = load double, ptr %11, align 8, !tbaa !11
  %95 = load double, ptr %11, align 8, !tbaa !11
  %96 = load double, ptr %10, align 8, !tbaa !11
  %97 = load double, ptr %10, align 8, !tbaa !11
  %98 = fmul double %96, %97
  %99 = call double @llvm.fmuladd.f64(double %94, double %95, double %98)
  %100 = call double @sqrt(double noundef %99) #6
  %101 = fdiv double %93, %100
  %102 = load ptr, ptr %9, align 8, !tbaa !9
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr %102, i64 %104
  store double %101, ptr %105, align 8, !tbaa !11
  %106 = load double, ptr %10, align 8, !tbaa !11
  %107 = load double, ptr %11, align 8, !tbaa !11
  %108 = load double, ptr %11, align 8, !tbaa !11
  %109 = load double, ptr %10, align 8, !tbaa !11
  %110 = load double, ptr %10, align 8, !tbaa !11
  %111 = fmul double %109, %110
  %112 = call double @llvm.fmuladd.f64(double %107, double %108, double %111)
  %113 = call double @sqrt(double noundef %112) #6
  %114 = fdiv double %106, %113
  %115 = load ptr, ptr %9, align 8, !tbaa !9
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds double, ptr %115, i64 %117
  store double %114, ptr %118, align 8, !tbaa !11
  %119 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %119, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %120

120:                                              ; preds = %89, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %121 = load ptr, ptr %3, align 8
  ret ptr %121
}

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_zeros(i32 noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { noreturn 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"double", !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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.160 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.161 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

; Function Attrs: nounwind uwtable
declare dso_local double @r8vec_norm(i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @r8vec_any_normal(i32 noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = icmp slt i32 %0, 2
  br i1 %3, label %4, label %11

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str) #6
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.160) #6
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.161) #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

11:                                               ; preds = %2
  %12 = zext nneg i32 %0 to i64
  %13 = shl nuw nsw i64 %12, 3
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #8
  %15 = tail call double @r8vec_norm(i32 noundef %0, ptr noundef %1)
  %16 = fcmp oeq double %15, 0.000000e+00
  br i1 %16, label %17, label %.lr.ph

17:                                               ; preds = %11
  tail call void @r8vec_zeros(i32 noundef %0, ptr noundef %14)
  store double 1.000000e+00, ptr %14, align 8, !tbaa !9
  br label %39

.lr.ph:                                           ; preds = %11, %29
  %indvars.iv = phi i64 [ %indvars.iv.next, %29 ], [ 0, %11 ]
  %.061 = phi double [ %.1, %29 ], [ 0.000000e+00, %11 ]
  %.04760 = phi double [ %.148, %29 ], [ 0.000000e+00, %11 ]
  %.05059 = phi i32 [ %.151, %29 ], [ -1, %11 ]
  %.05258 = phi i32 [ %.153, %29 ], [ -1, %11 ]
  %18 = tail call double @llvm.fabs.f64(double %.061)
  %19 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = tail call double @llvm.fabs.f64(double %20)
  %22 = fcmp olt double %18, %21
  %23 = icmp eq i32 %.05059, -1
  %or.cond = select i1 %22, i1 true, i1 %23
  br i1 %or.cond, label %24, label %29

24:                                               ; preds = %.lr.ph
  %25 = tail call double @llvm.fabs.f64(double %.04760)
  %26 = fcmp olt double %25, %21
  %27 = icmp eq i32 %.05258, -1
  %or.cond3 = select i1 %26, i1 true, i1 %27
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %.054..052 = select i1 %or.cond3, i32 %28, i32 %.05258
  %.052..054 = select i1 %or.cond3, i32 %.05258, i32 %28
  %..047 = select i1 %or.cond3, double %20, double %.04760
  %.047. = select i1 %or.cond3, double %.04760, double %20
  br label %29

29:                                               ; preds = %24, %.lr.ph
  %.153 = phi i32 [ %.05258, %.lr.ph ], [ %.054..052, %24 ]
  %.151 = phi i32 [ %.05059, %.lr.ph ], [ %.052..054, %24 ]
  %.148 = phi double [ %.04760, %.lr.ph ], [ %..047, %24 ]
  %.1 = phi double [ %.061, %.lr.ph ], [ %.047., %24 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %29
  tail call void @r8vec_zeros(i32 noundef %0, ptr noundef %14)
  %30 = fneg double %.1
  %31 = fmul double %.148, %.148
  %32 = tail call double @llvm.fmuladd.f64(double %.1, double %.1, double %31)
  %sqrt56 = tail call double @llvm.sqrt.f64(double %32)
  %33 = fdiv double %30, %sqrt56
  %34 = sext i32 %.153 to i64
  %35 = getelementptr inbounds double, ptr %14, i64 %34
  store double %33, ptr %35, align 8, !tbaa !9
  %36 = fdiv double %.148, %sqrt56
  %37 = sext i32 %.151 to i64
  %38 = getelementptr inbounds double, ptr %14, i64 %37
  store double %36, ptr %38, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %._crit_edge, %17
  ret ptr %14
}

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_zeros(i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #5

attributes #0 = { nofree 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 #1 = { noreturn 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { cold nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"any pointer", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass