; 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.36 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [43 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @i4_sign(i32 noundef) #4

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

16:                                               ; preds = %3
  store double 1.000000e+00, ptr %11, align 8, !tbaa !5
  %17 = load double, ptr %11, align 8, !tbaa !5
  store double %17, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

18:                                               ; preds = %3
  %19 = load double, ptr %5, align 8, !tbaa !5
  %20 = fcmp oeq double %19, -1.000000e+00
  br i1 %20, label %21, label %29

21:                                               ; preds = %18
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = srem i32 %22, 2
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store double -1.000000e+00, ptr %11, align 8, !tbaa !5
  br label %27

26:                                               ; preds = %21
  store double 1.000000e+00, ptr %11, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %26, %25
  %28 = load double, ptr %11, align 8, !tbaa !5
  store double %28, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

29:                                               ; preds = %18
  %30 = load double, ptr %5, align 8, !tbaa !5
  %31 = fcmp oeq double %30, 0.000000e+00
  br i1 %31, label %32, label %44

32:                                               ; preds = %29
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp sle i32 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %32
  %36 = load ptr, ptr @stderr, align 8, !tbaa !11
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str) #5
  %38 = load ptr, ptr @stderr, align 8, !tbaa !11
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.36) #5
  %40 = load ptr, ptr @stderr, align 8, !tbaa !11
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.37) #5
  call void @exit(i32 noundef 1) #6
  unreachable

42:                                               ; preds = %32
  store double 0.000000e+00, ptr %11, align 8, !tbaa !5
  %43 = load double, ptr %11, align 8, !tbaa !5
  store double %43, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

44:                                               ; preds = %29
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = icmp eq i32 %45, -1
  br i1 %46, label %47, label %55

47:                                               ; preds = %44
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = fdiv double 1.000000e+00, %48
  store double %49, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %7, align 8, !tbaa !11
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %52, ptr %53, align 4, !tbaa !9
  %54 = load double, ptr %11, align 8, !tbaa !5
  store double %54, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

55:                                               ; preds = %44
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %55
  store double 1.000000e+00, ptr %11, align 8, !tbaa !5
  %59 = load double, ptr %11, align 8, !tbaa !5
  store double %59, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

60:                                               ; preds = %55
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %66

63:                                               ; preds = %60
  %64 = load double, ptr %5, align 8, !tbaa !5
  store double %64, ptr %11, align 8, !tbaa !5
  %65 = load double, ptr %11, align 8, !tbaa !5
  store double %65, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = call i32 @llvm.abs.i32(i32 %69, i1 true)
  store i32 %70, ptr %8, align 4, !tbaa !9
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = call i32 @i4_sign(i32 noundef %71)
  store i32 %72, ptr %9, align 4, !tbaa !9
  store double 1.000000e+00, ptr %11, align 8, !tbaa !5
  %73 = load double, ptr %5, align 8, !tbaa !5
  store double %73, ptr %10, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %89, %68
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = icmp slt i32 0, %75
  br i1 %76, label %77, label %99

77:                                               ; preds = %74
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = srem i32 %78, 2
  %80 = icmp eq i32 %79, 1
  br i1 %80, label %81, label %89

81:                                               ; preds = %77
  %82 = load double, ptr %11, align 8, !tbaa !5
  %83 = load double, ptr %10, align 8, !tbaa !5
  %84 = fmul double %82, %83
  store double %84, ptr %11, align 8, !tbaa !5
  %85 = load ptr, ptr %7, align 8, !tbaa !11
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  %88 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %87, ptr %88, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %81, %77
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = sdiv i32 %90, 2
  store i32 %91, ptr %8, align 4, !tbaa !9
  %92 = load double, ptr %10, align 8, !tbaa !5
  %93 = load double, ptr %10, align 8, !tbaa !5
  %94 = fmul double %92, %93
  store double %94, ptr %10, align 8, !tbaa !5
  %95 = load ptr, ptr %7, align 8, !tbaa !11
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  %98 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %97, ptr %98, align 4, !tbaa !9
  br label %74, !llvm.loop !13

99:                                               ; preds = %74
  %100 = load i32, ptr %9, align 4, !tbaa !9
  %101 = icmp eq i32 %100, -1
  br i1 %101, label %102, label %109

102:                                              ; preds = %99
  %103 = load double, ptr %11, align 8, !tbaa !5
  %104 = fdiv double 1.000000e+00, %103
  store double %104, ptr %11, align 8, !tbaa !5
  %105 = load ptr, ptr %7, align 8, !tbaa !11
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  %108 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %107, ptr %108, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %102, %99
  %110 = load double, ptr %11, align 8, !tbaa !5
  store double %110, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %111

111:                                              ; preds = %109, %63, %58, %47, %42, %27, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %112 = load double, ptr %4, align 8
  ret double %112
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"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}
!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.36 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #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: nounwind uwtable
declare dso_local i32 @i4_sign(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local double @r8_power_fast(double noundef %0, i32 noundef %1, ptr nocapture noundef %2) local_unnamed_addr #3 {
  store i32 0, ptr %2, align 4, !tbaa !5
  %4 = fcmp oeq double %0, 1.000000e+00
  br i1 %4, label %41, label %5

5:                                                ; preds = %3
  %6 = fcmp oeq double %0, -1.000000e+00
  br i1 %6, label %7, label %10

7:                                                ; preds = %5
  %8 = and i32 %1, -2147483647
  %9 = icmp eq i32 %8, 1
  %. = select i1 %9, double -1.000000e+00, double 1.000000e+00
  br label %41

10:                                               ; preds = %5
  %11 = fcmp oeq double %0, 0.000000e+00
  br i1 %11, label %12, label %21

12:                                               ; preds = %10
  %13 = icmp slt i32 %1, 1
  br i1 %13, label %14, label %41

14:                                               ; preds = %12
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str) #4
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.36) #4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.37) #4
  tail call void @exit(i32 noundef 1) #5
  unreachable

21:                                               ; preds = %10
  switch i32 %1, label %.lr.ph [
    i32 -1, label %22
    i32 0, label %41
    i32 1, label %24
  ]

22:                                               ; preds = %21
  %23 = fdiv double 1.000000e+00, %0
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %41

24:                                               ; preds = %21
  br label %41

.lr.ph:                                           ; preds = %21
  %25 = tail call i32 @i4_sign(i32 noundef %1)
  %26 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
  %.promoted = load i32, ptr %2, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %.lr.ph, %27
  %28 = phi i32 [ %.promoted, %.lr.ph ], [ %34, %27 ]
  %.147 = phi double [ 1.000000e+00, %.lr.ph ], [ %.2, %27 ]
  %.03846 = phi double [ %0, %.lr.ph ], [ %33, %27 ]
  %.04045 = phi i32 [ %26, %.lr.ph ], [ %32, %27 ]
  %29 = and i32 %.04045, 1
  %.not43 = icmp eq i32 %29, 0
  %30 = fmul double %.03846, %.147
  %31 = add i32 %28, %29
  %.2 = select i1 %.not43, double %.147, double %30
  %32 = lshr i32 %.04045, 1
  %33 = fmul double %.03846, %.03846
  %34 = add nsw i32 %31, 1
  %.not = icmp ult i32 %.04045, 2
  br i1 %.not, label %35, label %27, !llvm.loop !11

35:                                               ; preds = %27
  store i32 %34, ptr %2, align 4, !tbaa !5
  %36 = icmp eq i32 %25, -1
  br i1 %36, label %37, label %41

37:                                               ; preds = %35
  %38 = fdiv double 1.000000e+00, %.2
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %35, %37, %21, %12, %3, %24, %22, %7
  %.039 = phi double [ %., %7 ], [ %23, %22 ], [ %0, %24 ], [ 1.000000e+00, %3 ], [ 0.000000e+00, %12 ], [ 1.000000e+00, %21 ], [ %38, %37 ], [ %.2, %35 ]
  ret double %.039
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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