; 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.124 = 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 @r8mat_uniform_ab(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, ptr noundef %4, ptr noundef %5) #4 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !11
  store ptr %5, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 2147483647, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %17 = load ptr, ptr %11, align 8, !tbaa !11
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %27

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

27:                                               ; preds = %6
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %81, %27
  %29 = load i32, ptr %15, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %84

32:                                               ; preds = %28
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %77, %32
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %80

37:                                               ; preds = %33
  %38 = load ptr, ptr %11, align 8, !tbaa !11
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sdiv i32 %39, 127773
  store i32 %40, ptr %16, align 4, !tbaa !5
  %41 = load ptr, ptr %11, align 8, !tbaa !11
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = load i32, ptr %16, align 4, !tbaa !5
  %44 = mul nsw i32 %43, 127773
  %45 = sub nsw i32 %42, %44
  %46 = mul nsw i32 16807, %45
  %47 = load i32, ptr %16, align 4, !tbaa !5
  %48 = mul nsw i32 %47, 2836
  %49 = sub nsw i32 %46, %48
  %50 = load ptr, ptr %11, align 8, !tbaa !11
  store i32 %49, ptr %50, align 4, !tbaa !5
  %51 = load ptr, ptr %11, align 8, !tbaa !11
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp slt i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %37
  %55 = load ptr, ptr %11, align 8, !tbaa !11
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = add nsw i32 %56, 2147483647
  %58 = load ptr, ptr %11, align 8, !tbaa !11
  store i32 %57, ptr %58, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %54, %37
  %60 = load double, ptr %9, align 8, !tbaa !9
  %61 = load double, ptr %10, align 8, !tbaa !9
  %62 = load double, ptr %9, align 8, !tbaa !9
  %63 = fsub double %61, %62
  %64 = load ptr, ptr %11, align 8, !tbaa !11
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sitofp i32 %65 to double
  %67 = fmul double %63, %66
  %68 = call double @llvm.fmuladd.f64(double %67, double 0x3E000000001C5F68, double %60)
  %69 = load ptr, ptr %12, align 8, !tbaa !11
  %70 = load i32, ptr %13, align 4, !tbaa !5
  %71 = load i32, ptr %15, align 4, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = mul nsw i32 %71, %72
  %74 = add nsw i32 %70, %73
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds double, ptr %69, i64 %75
  store double %68, ptr %76, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %59
  %78 = load i32, ptr %13, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %13, align 4, !tbaa !5
  br label %33, !llvm.loop !13

80:                                               ; preds = %33
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %15, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %15, align 4, !tbaa !5
  br label %28, !llvm.loop !15

84:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #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"}
!15 = distinct !{!15, !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.7 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.124 = 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 @r8mat_uniform_ab(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #3 {
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %24, label %.preheader26

.preheader26:                                     ; preds = %6
  %9 = icmp sgt i32 %1, 0
  br i1 %9, label %.preheader.lr.ph, label %._crit_edge30

.preheader.lr.ph:                                 ; preds = %.preheader26
  %10 = icmp sgt i32 %0, 0
  %11 = fsub double %3, %2
  br i1 %10, label %.preheader.lr.ph.split.us, label %._crit_edge30

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  %12 = zext nneg i32 %0 to i64
  %wide.trip.count36 = zext nneg i32 %1 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph.split.us
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %._crit_edge.us ], [ 0, %.preheader.lr.ph.split.us ]
  %spec.select.lcssa.us31 = phi i32 [ %spec.select.us, %._crit_edge.us ], [ %7, %.preheader.lr.ph.split.us ]
  %13 = mul nuw nsw i64 %indvars.iv33, %12
  %invariant.gep = getelementptr inbounds double, ptr %5, i64 %13
  br label %14

14:                                               ; preds = %.preheader.us, %14
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %14 ]
  %spec.select28.us = phi i32 [ %spec.select.lcssa.us31, %.preheader.us ], [ %spec.select.us, %14 ]
  %15 = sdiv i32 %spec.select28.us, 127773
  %.neg.us = mul nsw i32 %15, -127773
  %16 = add i32 %.neg.us, %spec.select28.us
  %17 = mul nsw i32 %16, 16807
  %.neg25.us = mul nsw i32 %15, -2836
  %18 = add i32 %17, %.neg25.us
  %19 = icmp slt i32 %18, 0
  %20 = add nsw i32 %18, 2147483647
  %spec.select.us = select i1 %19, i32 %20, i32 %18
  %21 = sitofp i32 %spec.select.us to double
  %22 = fmul double %11, %21
  %23 = tail call double @llvm.fmuladd.f64(double %22, double 0x3E000000001C5F68, double %2)
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv
  store double %23, ptr %gep, align 8, !tbaa !9
  %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.us, label %14, !llvm.loop !11

._crit_edge.us:                                   ; preds = %14
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next34, %wide.trip.count36
  br i1 %exitcond37.not, label %._crit_edge30.split.us, label %.preheader.us, !llvm.loop !13

._crit_edge30.split.us:                           ; preds = %._crit_edge.us
  store i32 %spec.select.us, ptr %4, align 4, !tbaa !5
  br label %._crit_edge30

24:                                               ; preds = %6
  %25 = load ptr, ptr @stderr, align 8, !tbaa !14
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str) #4
  %27 = load ptr, ptr @stderr, align 8, !tbaa !14
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.124) #4
  %29 = load ptr, ptr @stderr, align 8, !tbaa !14
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.7) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

._crit_edge30:                                    ; preds = %.preheader.lr.ph, %._crit_edge30.split.us, %.preheader26
  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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}


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