; 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.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.214 = external hidden unnamed_addr constant [33 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_uniform_ab(i32 noundef %0, double noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 2147483647, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %14 = load ptr, ptr %9, align 8, !tbaa !11
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %24

17:                                               ; preds = %5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !11
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str) #5
  %20 = load ptr, ptr @stderr, align 8, !tbaa !11
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.214) #5
  %22 = load ptr, ptr @stderr, align 8, !tbaa !11
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.7) #5
  call void @exit(i32 noundef 1) #6
  unreachable

24:                                               ; preds = %5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %65, %24
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %68

29:                                               ; preds = %25
  %30 = load ptr, ptr %9, align 8, !tbaa !11
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sdiv i32 %31, 127773
  store i32 %32, ptr %13, align 4, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !11
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr %13, align 4, !tbaa !5
  %36 = mul nsw i32 %35, 127773
  %37 = sub nsw i32 %34, %36
  %38 = mul nsw i32 16807, %37
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = mul nsw i32 %39, 2836
  %41 = sub nsw i32 %38, %40
  %42 = load ptr, ptr %9, align 8, !tbaa !11
  store i32 %41, ptr %42, align 4, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %51

46:                                               ; preds = %29
  %47 = load ptr, ptr %9, align 8, !tbaa !11
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %48, 2147483647
  %50 = load ptr, ptr %9, align 8, !tbaa !11
  store i32 %49, ptr %50, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %46, %29
  %52 = load double, ptr %7, align 8, !tbaa !9
  %53 = load double, ptr %8, align 8, !tbaa !9
  %54 = load double, ptr %7, align 8, !tbaa !9
  %55 = fsub double %53, %54
  %56 = load ptr, ptr %9, align 8, !tbaa !11
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = sitofp i32 %57 to double
  %59 = fmul double %55, %58
  %60 = call double @llvm.fmuladd.f64(double %59, double 0x3E000000001C5F68, double %52)
  %61 = load ptr, ptr %10, align 8, !tbaa !11
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  store double %60, ptr %64, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %51
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %11, align 4, !tbaa !5
  br label %25, !llvm.loop !13

68:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #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 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.214 = external hidden unnamed_addr constant [33 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_uniform_ab(i32 noundef %0, double noundef %1, double noundef %2, ptr nocapture noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #3 {
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %10, label %.preheader

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

.lr.ph:                                           ; preds = %.preheader
  %9 = fsub double %2, %1
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %17

10:                                               ; preds = %5
  %11 = load ptr, ptr @stderr, align 8, !tbaa !9
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str) #4
  %13 = load ptr, ptr @stderr, align 8, !tbaa !9
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.214) #4
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.7) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

17:                                               ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %spec.select20 = phi i32 [ %6, %.lr.ph ], [ %spec.select, %17 ]
  %18 = sdiv i32 %spec.select20, 127773
  %.neg = mul nsw i32 %18, -127773
  %19 = add i32 %.neg, %spec.select20
  %20 = mul nsw i32 %19, 16807
  %.neg18 = mul nsw i32 %18, -2836
  %21 = add i32 %20, %.neg18
  %22 = icmp slt i32 %21, 0
  %23 = add nsw i32 %21, 2147483647
  %spec.select = select i1 %22, i32 %23, i32 %21
  %24 = sitofp i32 %spec.select to double
  %25 = fmul double %9, %24
  %26 = tail call double @llvm.fmuladd.f64(double %25, double 0x3E000000001C5F68, double %1)
  %27 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  store double %26, ptr %27, align 8, !tbaa !11
  %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 %17, !llvm.loop !13

._crit_edge:                                      ; preds = %17
  store i32 %spec.select, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %._crit_edge, %.preheader
  ret void
}

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 = { cold nounwind }
attributes #5 = { 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass