; 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.45 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [30 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 uwtable
declare dso_local i32 @i4_max(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @i4_min(i32 noundef, i32 noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @r8_nint(double noundef) #1

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

15:                                               ; preds = %4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !11
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str) #5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !11
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.45) #5
  %20 = load ptr, ptr @stderr, align 8, !tbaa !11
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.46, i32 noundef %21) #5
  %23 = load ptr, ptr @stderr, align 8, !tbaa !11
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.47) #5
  call void @exit(i32 noundef 1) #6
  unreachable

25:                                               ; preds = %4
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load double, ptr %7, align 8, !tbaa !5
  %30 = load double, ptr %8, align 8, !tbaa !5
  %31 = fadd double %29, %30
  %32 = fmul double 5.000000e-01, %31
  store double %32, ptr %11, align 8, !tbaa !5
  %33 = load double, ptr %11, align 8, !tbaa !5
  store double %33, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %72

34:                                               ; preds = %25
  %35 = load double, ptr %8, align 8, !tbaa !5
  %36 = load double, ptr %7, align 8, !tbaa !5
  %37 = fcmp oeq double %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = load double, ptr %8, align 8, !tbaa !5
  store double %39, ptr %11, align 8, !tbaa !5
  %40 = load double, ptr %11, align 8, !tbaa !5
  store double %40, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %72

41:                                               ; preds = %34
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = sitofp i32 %42 to double
  %44 = load double, ptr %8, align 8, !tbaa !5
  %45 = load double, ptr %6, align 8, !tbaa !5
  %46 = fsub double %44, %45
  %47 = fmul double %43, %46
  %48 = load double, ptr %8, align 8, !tbaa !5
  %49 = load double, ptr %7, align 8, !tbaa !5
  %50 = fsub double %48, %49
  %51 = fdiv double %47, %50
  %52 = call i32 @r8_nint(double noundef %51)
  store i32 %52, ptr %10, align 4, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = call i32 @i4_max(i32 noundef %53, i32 noundef 0)
  store i32 %54, ptr %10, align 4, !tbaa !9
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = call i32 @i4_min(i32 noundef %55, i32 noundef %56)
  store i32 %57, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = sitofp i32 %58 to double
  %60 = load double, ptr %7, align 8, !tbaa !5
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = sub nsw i32 %61, %62
  %64 = sitofp i32 %63 to double
  %65 = load double, ptr %8, align 8, !tbaa !5
  %66 = fmul double %64, %65
  %67 = call double @llvm.fmuladd.f64(double %59, double %60, double %66)
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = sitofp i32 %68 to double
  %70 = fdiv double %67, %69
  store double %70, ptr %11, align 8, !tbaa !5
  %71 = load double, ptr %11, align 8, !tbaa !5
  store double %71, ptr %5, align 8
  store i32 1, ptr %12, align 4
  br label %72

72:                                               ; preds = %41, %38, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %73 = load double, ptr %5, align 8
  ret double %73
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; 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.45 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @i4_max(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @i4_min(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @r8_nint(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @r8_to_r8_discrete(double noundef %0, double noundef %1, double noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp slt i32 %3, 1
  br i1 %5, label %6, label %15

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

15:                                               ; preds = %4
  %16 = icmp eq i32 %3, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %15
  %18 = fadd double %1, %2
  %19 = fmul double %18, 5.000000e-01
  br label %37

20:                                               ; preds = %15
  %21 = fcmp oeq double %2, %1
  br i1 %21, label %37, label %22

22:                                               ; preds = %20
  %23 = uitofp nneg i32 %3 to double
  %24 = fsub double %2, %0
  %25 = fmul double %24, %23
  %26 = fsub double %2, %1
  %27 = fdiv double %25, %26
  %28 = tail call i32 @r8_nint(double noundef %27)
  %29 = tail call i32 @i4_max(i32 noundef %28, i32 noundef 0)
  %30 = tail call i32 @i4_min(i32 noundef %29, i32 noundef %3)
  %31 = sitofp i32 %30 to double
  %32 = sub nsw i32 %3, %30
  %33 = sitofp i32 %32 to double
  %34 = fmul double %33, %2
  %35 = tail call double @llvm.fmuladd.f64(double %31, double %1, double %34)
  %36 = fdiv double %35, %23
  br label %37

37:                                               ; preds = %20, %22, %17
  %.0 = phi double [ %19, %17 ], [ %36, %22 ], [ %2, %20 ]
  ret double %.0
}

attributes #0 = { 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 #1 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass