; 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.27 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [10 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: nounwind
declare double @sqrt(double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @r8_agm(double noundef %0, double noundef %1) #3 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1000, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %15 = load double, ptr %4, align 8, !tbaa !5
  %16 = fcmp olt double %15, 0.000000e+00
  br i1 %16, label %17, label %24

17:                                               ; preds = %2
  %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.27) #5
  %22 = load ptr, ptr @stderr, align 8, !tbaa !11
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.28) #5
  call void @exit(i32 noundef 1) #6
  unreachable

24:                                               ; preds = %2
  %25 = load double, ptr %5, align 8, !tbaa !5
  %26 = fcmp olt double %25, 0.000000e+00
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = load ptr, ptr @stderr, align 8, !tbaa !11
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str) #5
  %30 = load ptr, ptr @stderr, align 8, !tbaa !11
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.27) #5
  %32 = load ptr, ptr @stderr, align 8, !tbaa !11
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.29) #5
  call void @exit(i32 noundef 1) #6
  unreachable

34:                                               ; preds = %24
  %35 = load double, ptr %4, align 8, !tbaa !5
  %36 = fcmp oeq double %35, 0.000000e+00
  br i1 %36, label %40, label %37

37:                                               ; preds = %34
  %38 = load double, ptr %5, align 8, !tbaa !5
  %39 = fcmp oeq double %38, 0.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %37, %34
  store double 0.000000e+00, ptr %13, align 8, !tbaa !5
  %41 = load double, ptr %13, align 8, !tbaa !5
  store double %41, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %87

42:                                               ; preds = %37
  %43 = load double, ptr %4, align 8, !tbaa !5
  %44 = load double, ptr %5, align 8, !tbaa !5
  %45 = fcmp oeq double %43, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %42
  %47 = load double, ptr %4, align 8, !tbaa !5
  store double %47, ptr %13, align 8, !tbaa !5
  %48 = load double, ptr %13, align 8, !tbaa !5
  store double %48, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %87

49:                                               ; preds = %42
  %50 = load double, ptr %4, align 8, !tbaa !5
  store double %50, ptr %6, align 8, !tbaa !5
  %51 = load double, ptr %5, align 8, !tbaa !5
  store double %51, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !9
  %52 = call double @r8_epsilon()
  %53 = fmul double 1.000000e+02, %52
  store double %53, ptr %12, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %81, %49
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %10, align 4, !tbaa !9
  %57 = load double, ptr %6, align 8, !tbaa !5
  %58 = load double, ptr %8, align 8, !tbaa !5
  %59 = fadd double %57, %58
  %60 = fdiv double %59, 2.000000e+00
  store double %60, ptr %7, align 8, !tbaa !5
  %61 = load double, ptr %6, align 8, !tbaa !5
  %62 = load double, ptr %8, align 8, !tbaa !5
  %63 = fmul double %61, %62
  %64 = call double @sqrt(double noundef %63) #5
  store double %64, ptr %9, align 8, !tbaa !5
  %65 = load double, ptr %7, align 8, !tbaa !5
  %66 = load double, ptr %9, align 8, !tbaa !5
  %67 = fsub double %65, %66
  %68 = call double @llvm.fabs.f64(double %67)
  %69 = load double, ptr %12, align 8, !tbaa !5
  %70 = load double, ptr %7, align 8, !tbaa !5
  %71 = load double, ptr %9, align 8, !tbaa !5
  %72 = fadd double %70, %71
  %73 = fmul double %69, %72
  %74 = fcmp ole double %68, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %54
  br label %84

76:                                               ; preds = %54
  %77 = load i32, ptr %11, align 4, !tbaa !9
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = icmp slt i32 %77, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %76
  br label %84

81:                                               ; preds = %76
  %82 = load double, ptr %7, align 8, !tbaa !5
  store double %82, ptr %6, align 8, !tbaa !5
  %83 = load double, ptr %9, align 8, !tbaa !5
  store double %83, ptr %8, align 8, !tbaa !5
  br label %54

84:                                               ; preds = %80, %75
  %85 = load double, ptr %7, align 8, !tbaa !5
  store double %85, ptr %13, align 8, !tbaa !5
  %86 = load double, ptr %13, align 8, !tbaa !5
  store double %86, ptr %3, align 8
  store i32 1, ptr %14, align 4
  br label %87

87:                                               ; preds = %84, %46, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %88 = load double, ptr %3, align 8
  ret double %88
}

; Function Attrs: nounwind uwtable
declare dso_local double @r8_epsilon() #3

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

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 = { 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 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.27 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [10 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 nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local double @r8_agm(double noundef %0, double noundef %1) local_unnamed_addr #3 {
  %3 = fcmp olt double %0, 0.000000e+00
  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) #5
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.27) #5
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.28) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

11:                                               ; preds = %2
  %12 = fcmp olt double %1, 0.000000e+00
  br i1 %12, label %13, label %20

13:                                               ; preds = %11
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str) #5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.27) #5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.29) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

20:                                               ; preds = %11
  %21 = fcmp oeq double %0, 0.000000e+00
  %22 = fcmp oeq double %1, 0.000000e+00
  %or.cond = or i1 %21, %22
  br i1 %or.cond, label %.loopexit, label %23

23:                                               ; preds = %20
  %24 = fcmp oeq double %0, %1
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %23
  %26 = tail call double @r8_epsilon()
  %27 = fmul double %26, 1.000000e+02
  br label %28

28:                                               ; preds = %28, %25
  %.030 = phi double [ %1, %25 ], [ %33, %28 ]
  %.029 = phi i32 [ 0, %25 ], [ %29, %28 ]
  %.028 = phi double [ %0, %25 ], [ %31, %28 ]
  %29 = add nuw nsw i32 %.029, 1
  %30 = fadd double %.030, %.028
  %31 = fmul double %30, 5.000000e-01
  %32 = fmul double %.030, %.028
  %33 = tail call double @sqrt(double noundef %32) #7
  %34 = fsub double %31, %33
  %35 = tail call double @llvm.fabs.f64(double %34)
  %36 = fadd double %33, %31
  %37 = fmul double %27, %36
  %38 = fcmp ole double %35, %37
  %39 = icmp ugt i32 %.029, 999
  %or.cond34 = select i1 %38, i1 true, i1 %39
  br i1 %or.cond34, label %.loopexit, label %28

.loopexit:                                        ; preds = %28, %23, %20
  %.0 = phi double [ 0.000000e+00, %20 ], [ %0, %23 ], [ %31, %28 ]
  ret double %.0
}

; Function Attrs: nounwind uwtable
declare dso_local double @r8_epsilon() local_unnamed_addr #3

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

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 nofree nounwind willreturn memory(write) "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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { cold nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass