; 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.162 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [26 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 uwtable
define dso_local void @r8vec_bin(i32 noundef %0, ptr noundef %1, i32 noundef %2, double noundef %3, double noundef %4, ptr noundef %5, ptr noundef %6) #4 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !5
  store double %3, ptr %11, align 8, !tbaa !11
  store double %4, ptr %12, align 8, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %18 = load double, ptr %12, align 8, !tbaa !11
  %19 = load double, ptr %11, align 8, !tbaa !11
  %20 = fcmp oeq double %18, %19
  br i1 %20, label %21, label %29

21:                                               ; preds = %7
  %22 = load ptr, ptr @stderr, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str) #5
  %24 = load ptr, ptr @stderr, align 8, !tbaa !9
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.162) #5
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = load double, ptr %12, align 8, !tbaa !11
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.163, double noundef %27) #5
  call void @exit(i32 noundef 1) #6
  unreachable

29:                                               ; preds = %7
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %40, %29
  %31 = load i32, ptr %15, align 4, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = icmp sle i32 %31, %33
  br i1 %34, label %35, label %43

35:                                               ; preds = %30
  %36 = load ptr, ptr %13, align 8, !tbaa !9
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  store i32 0, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %15, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %15, align 4, !tbaa !5
  br label %30, !llvm.loop !13

43:                                               ; preds = %30
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %88, %43
  %45 = load i32, ptr %15, align 4, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %91

48:                                               ; preds = %44
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = load i32, ptr %15, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds double, ptr %49, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !11
  %54 = load double, ptr %11, align 8, !tbaa !11
  %55 = fsub double %53, %54
  %56 = load double, ptr %12, align 8, !tbaa !11
  %57 = load double, ptr %11, align 8, !tbaa !11
  %58 = fsub double %56, %57
  %59 = fdiv double %55, %58
  store double %59, ptr %17, align 8, !tbaa !11
  %60 = load double, ptr %17, align 8, !tbaa !11
  %61 = fcmp olt double %60, 0.000000e+00
  br i1 %61, label %62, label %63

62:                                               ; preds = %48
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %77

63:                                               ; preds = %48
  %64 = load double, ptr %17, align 8, !tbaa !11
  %65 = fcmp ole double 1.000000e+00, %64
  br i1 %65, label %66, label %69

66:                                               ; preds = %63
  %67 = load i32, ptr %10, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %16, align 4, !tbaa !5
  br label %76

69:                                               ; preds = %63
  %70 = load i32, ptr %10, align 4, !tbaa !5
  %71 = sitofp i32 %70 to double
  %72 = load double, ptr %17, align 8, !tbaa !11
  %73 = fmul double %71, %72
  %74 = fptosi double %73 to i32
  %75 = add nsw i32 1, %74
  store i32 %75, ptr %16, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %69, %66
  br label %77

77:                                               ; preds = %76, %62
  %78 = load ptr, ptr %13, align 8, !tbaa !9
  %79 = load i32, ptr %16, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr %78, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  %84 = load ptr, ptr %13, align 8, !tbaa !9
  %85 = load i32, ptr %16, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i32, ptr %84, i64 %86
  store i32 %83, ptr %87, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %77
  %89 = load i32, ptr %15, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %15, align 4, !tbaa !5
  br label %44, !llvm.loop !15

91:                                               ; preds = %44
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %114, %91
  %93 = load i32, ptr %15, align 4, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = icmp sle i32 %93, %94
  br i1 %95, label %96, label %117

96:                                               ; preds = %92
  %97 = load i32, ptr %10, align 4, !tbaa !5
  %98 = load i32, ptr %15, align 4, !tbaa !5
  %99 = sub nsw i32 %97, %98
  %100 = sitofp i32 %99 to double
  %101 = load double, ptr %11, align 8, !tbaa !11
  %102 = load i32, ptr %15, align 4, !tbaa !5
  %103 = sitofp i32 %102 to double
  %104 = load double, ptr %12, align 8, !tbaa !11
  %105 = fmul double %103, %104
  %106 = call double @llvm.fmuladd.f64(double %100, double %101, double %105)
  %107 = load i32, ptr %10, align 4, !tbaa !5
  %108 = sitofp i32 %107 to double
  %109 = fdiv double %106, %108
  %110 = load ptr, ptr %14, align 8, !tbaa !9
  %111 = load i32, ptr %15, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds double, ptr %110, i64 %112
  store double %109, ptr %113, align 8, !tbaa !11
  br label %114

114:                                              ; preds = %96
  %115 = load i32, ptr %15, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %15, align 4, !tbaa !5
  br label %92, !llvm.loop !16

117:                                              ; preds = %92
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  ret void
}

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 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 = { noreturn 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 = !{!"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"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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.162 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.163 = external hidden unnamed_addr constant [26 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: nounwind uwtable
define dso_local void @r8vec_bin(i32 noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, double noundef %3, double noundef %4, ptr nocapture noundef %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #3 {
  %8 = fcmp oeq double %4, %3
  br i1 %8, label %13, label %.preheader44

.preheader44:                                     ; preds = %7
  %9 = add i32 %2, 1
  %.not45 = icmp slt i32 %2, -1
  br i1 %.not45, label %.preheader43, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader44
  %10 = add i32 %2, 2
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 %12, i1 false), !tbaa !5
  br label %.preheader43

13:                                               ; preds = %7
  %14 = load ptr, ptr @stderr, align 8, !tbaa !9
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str) #6
  %16 = load ptr, ptr @stderr, align 8, !tbaa !9
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.162) #6
  %18 = load ptr, ptr @stderr, align 8, !tbaa !9
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.163, double noundef %4) #6
  tail call void @exit(i32 noundef 1) #7
  unreachable

.preheader43:                                     ; preds = %.lr.ph.preheader, %.preheader44
  %20 = icmp sgt i32 %0, 0
  br i1 %20, label %.lr.ph48, label %.preheader

.lr.ph48:                                         ; preds = %.preheader43
  %21 = fsub double %4, %3
  %22 = sitofp i32 %2 to double
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %32

.preheader:                                       ; preds = %44, %.preheader43
  %.not4249 = icmp slt i32 %2, 0
  br i1 %.not4249, label %._crit_edge, label %.lr.ph51

.lr.ph51:                                         ; preds = %.preheader
  %23 = uitofp nneg i32 %2 to double
  %wide.trip.count57 = zext i32 %9 to i64
  %min.iters.check = icmp ult i32 %9, 2
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph51
  %indvars.iv54.ph = phi i64 [ 0, %.lr.ph51 ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph51
  %n.vec = and i64 %wide.trip.count57, 4294967294
  %broadcast.splatinsert = insertelement <2 x i32> poison, i32 %2, i64 0
  %broadcast.splat = shufflevector <2 x i32> %broadcast.splatinsert, <2 x i32> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert61 = insertelement <2 x double> poison, double %4, i64 0
  %broadcast.splat62 = shufflevector <2 x double> %broadcast.splatinsert61, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert63 = insertelement <2 x double> poison, double %3, i64 0
  %broadcast.splat64 = shufflevector <2 x double> %broadcast.splatinsert63, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert65 = insertelement <2 x double> poison, double %23, i64 0
  %broadcast.splat66 = shufflevector <2 x double> %broadcast.splatinsert65, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i32> [ <i32 0, i32 1>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %vec.ind59 = phi <2 x i32> [ <i32 0, i32 1>, %vector.ph ], [ %vec.ind.next60, %vector.body ]
  %24 = sub <2 x i32> %broadcast.splat, %vec.ind
  %25 = sitofp <2 x i32> %24 to <2 x double>
  %26 = uitofp <2 x i32> %vec.ind59 to <2 x double>
  %27 = fmul <2 x double> %broadcast.splat62, %26
  %28 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %broadcast.splat64, <2 x double> %27)
  %29 = fdiv <2 x double> %28, %broadcast.splat66
  %30 = getelementptr inbounds double, ptr %6, i64 %index
  store <2 x double> %29, ptr %30, align 8, !tbaa !11
  %index.next = add nuw i64 %index, 2
  %vec.ind.next = add <2 x i32> %vec.ind, <i32 2, i32 2>
  %vec.ind.next60 = add <2 x i32> %vec.ind59, <i32 2, i32 2>
  %31 = icmp eq i64 %index.next, %n.vec
  br i1 %31, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count57
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

32:                                               ; preds = %.lr.ph48, %44
  %indvars.iv = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next, %44 ]
  %33 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = fsub double %34, %3
  %36 = fdiv double %35, %21
  %37 = fcmp olt double %36, 0.000000e+00
  br i1 %37, label %44, label %38

38:                                               ; preds = %32
  %39 = fcmp ult double %36, 1.000000e+00
  br i1 %39, label %40, label %44

40:                                               ; preds = %38
  %41 = fmul double %36, %22
  %42 = fptosi double %41 to i32
  %43 = add nsw i32 %42, 1
  br label %44

44:                                               ; preds = %38, %32, %40
  %.035 = phi i32 [ %43, %40 ], [ 0, %32 ], [ %9, %38 ]
  %45 = sext i32 %.035 to i64
  %46 = getelementptr inbounds i32, ptr %5, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %46, 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 %.preheader, label %32, !llvm.loop !17

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %scalar.ph ], [ %indvars.iv54.ph, %scalar.ph.preheader ]
  %49 = trunc i64 %indvars.iv54 to i32
  %50 = sub i32 %2, %49
  %51 = sitofp i32 %50 to double
  %52 = trunc nuw nsw i64 %indvars.iv54 to i32
  %53 = uitofp nneg i32 %52 to double
  %54 = fmul double %53, %4
  %55 = tail call double @llvm.fmuladd.f64(double %51, double %3, double %54)
  %56 = fdiv double %55, %23
  %57 = getelementptr inbounds double, ptr %6, i64 %indvars.iv54
  store double %56, ptr %57, align 8, !tbaa !11
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge, label %scalar.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %.preheader
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x 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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { cold nounwind }
attributes #7 = { noreturn 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 = !{!"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, !15, !16}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14, !16, !15}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass