; LLVM IR from daanx/mimalloc-bench :: bench/cfrac (cfrac)

; 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"

@debug = external dso_local global i32, align 4
@pone = external global ptr, align 8
@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local float @pfKnuthEx28(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !9
  %8 = call ptr @pparmq(ptr noundef %7)
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %49

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !9
  %13 = call i32 @podd(ptr noundef %12)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %31, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = call ptr @phalf(ptr noundef %16)
  %18 = call ptr @psetq(ptr noundef %6, ptr noundef %17)
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = call i32 @podd(ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %29, label %22

22:                                               ; preds = %15
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = call float @pfKnuthEx28(i32 noundef 2, ptr noundef %23)
  %25 = fpext float %24 to double
  %26 = fdiv double %25, 2.000000e+00
  %27 = fadd double 0x3FE5555555555555, %26
  %28 = fptrunc double %27 to float
  store float %28, ptr %5, align 4, !tbaa !11
  br label %30

29:                                               ; preds = %15
  store float 0x3FD5555560000000, ptr %5, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %29, %22
  br label %48

31:                                               ; preds = %11
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = call ptr @phalf(ptr noundef %32)
  %34 = call ptr @psetq(ptr noundef %6, ptr noundef %33)
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = call i32 @podd(ptr noundef %35)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %31
  store float 0x3FD5555560000000, ptr %5, align 4, !tbaa !11
  br label %47

39:                                               ; preds = %31
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call ptr @phalf(ptr noundef %40)
  %42 = call i32 @podd(ptr noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  store float 0x3FE5555560000000, ptr %5, align 4, !tbaa !11
  br label %46

45:                                               ; preds = %39
  store float 0x3FF5555560000000, ptr %5, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %45, %44
  br label %47

47:                                               ; preds = %46, %38
  br label %48

48:                                               ; preds = %47, %30
  br label %80

49:                                               ; preds = %2
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = call ptr @utop(i32 noundef %50)
  %52 = call ptr @psetq(ptr noundef %6, ptr noundef %51)
  %53 = load ptr, ptr %4, align 8, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = load ptr, ptr @pone, align 8, !tbaa !9
  %56 = call ptr @psub(ptr noundef %54, ptr noundef %55)
  %57 = call ptr @phalf(ptr noundef %56)
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = call ptr @ppowmod(ptr noundef %53, ptr noundef %57, ptr noundef %58)
  %60 = load ptr, ptr @pone, align 8, !tbaa !9
  %61 = call i32 @pcmp(ptr noundef %59, ptr noundef %60)
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %78

63:                                               ; preds = %49
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = add i32 %64, %65
  %67 = uitofp i32 %66 to float
  %68 = fpext float %67 to double
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = uitofp i32 %69 to float
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = uitofp i32 %71 to float
  %73 = fmul float %70, %72
  %74 = fpext float %73 to double
  %75 = fsub double %74, 1.000000e+00
  %76 = fdiv double %68, %75
  %77 = fptrunc double %76 to float
  store float %77, ptr %5, align 4, !tbaa !11
  br label %79

78:                                               ; preds = %49
  store float 0.000000e+00, ptr %5, align 4, !tbaa !11
  br label %79

79:                                               ; preds = %78, %63
  br label %80

80:                                               ; preds = %79, %48
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  call void @pdestroy(ptr noundef %81)
  %82 = load ptr, ptr %4, align 8, !tbaa !9
  call void @pdestroy(ptr noundef %82)
  %83 = load i32, ptr @debug, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 1
  br i1 %84, label %85, label %93

85:                                               ; preds = %80
  %86 = load ptr, ptr @stdout, align 8, !tbaa !9
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef @.str, i32 noundef %87) #5
  %89 = load ptr, ptr @stdout, align 8, !tbaa !9
  %90 = load float, ptr %5, align 4, !tbaa !11
  %91 = fpext float %90 to double
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.1, double noundef %91) #5
  br label %93

93:                                               ; preds = %85, %80
  %94 = load float, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret float %94
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @pparmq(ptr noundef) #2

declare i32 @podd(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @psetq(ptr noundef, ptr noundef) #2

declare ptr @phalf(ptr noundef) #3

declare ptr @utop(i32 noundef) #3

declare i32 @pcmp(ptr noundef, ptr noundef) #3

declare ptr @ppowmod(ptr noundef, ptr noundef, ptr noundef) #3

declare ptr @psub(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pdestroy(ptr noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { "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 "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 }

!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 = !{!"float", !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"

@debug = external dso_local local_unnamed_addr global i32, align 4
@pone = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local float @pfKnuthEx28(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store ptr null, ptr %3, align 8, !tbaa !5
  %4 = tail call ptr @pparmq(ptr noundef %1)
  %5 = icmp eq i32 %0, 2
  br i1 %5, label %6, label %25

6:                                                ; preds = %2
  %7 = tail call i32 @podd(ptr noundef %1) #5
  %.not = icmp eq i32 %7, 0
  %8 = tail call ptr @phalf(ptr noundef %1) #5
  %9 = call ptr @psetq(ptr noundef nonnull %3, ptr noundef %8)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @podd(ptr noundef %10) #5
  %.not15 = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %20

12:                                               ; preds = %6
  br i1 %.not15, label %13, label %47

13:                                               ; preds = %12
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call float @pfKnuthEx28(i32 noundef 2, ptr noundef %14)
  %16 = fpext float %15 to double
  %17 = fmul double %16, 5.000000e-01
  %18 = fadd double %17, 0x3FE5555555555555
  %19 = fptrunc double %18 to float
  br label %47

20:                                               ; preds = %6
  br i1 %.not15, label %21, label %47

21:                                               ; preds = %20
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call ptr @phalf(ptr noundef %22) #5
  %24 = call i32 @podd(ptr noundef %23) #5
  %.not17 = icmp eq i32 %24, 0
  %. = select i1 %.not17, float 0x3FF5555560000000, float 0x3FE5555560000000
  br label %47

25:                                               ; preds = %2
  %26 = tail call ptr @utop(i32 noundef %0) #5
  %27 = call ptr @psetq(ptr noundef nonnull %3, ptr noundef %26)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr @pone, align 8, !tbaa !5
  %30 = call ptr @psub(ptr noundef %28, ptr noundef %29) #5
  %31 = call ptr @phalf(ptr noundef %30) #5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call ptr @ppowmod(ptr noundef %1, ptr noundef %31, ptr noundef %32) #5
  %34 = load ptr, ptr @pone, align 8, !tbaa !5
  %35 = call i32 @pcmp(ptr noundef %33, ptr noundef %34) #5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %47

37:                                               ; preds = %25
  %38 = shl i32 %0, 1
  %39 = uitofp i32 %38 to float
  %40 = fpext float %39 to double
  %41 = uitofp i32 %0 to float
  %42 = fmul float %41, %41
  %43 = fpext float %42 to double
  %44 = fadd double %43, -1.000000e+00
  %45 = fdiv double %40, %44
  %46 = fptrunc double %45 to float
  br label %47

47:                                               ; preds = %25, %21, %20, %12, %37, %13
  %.0 = phi float [ %19, %13 ], [ %46, %37 ], [ 0x3FD5555560000000, %12 ], [ 0x3FD5555560000000, %20 ], [ %., %21 ], [ 0.000000e+00, %25 ]
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pdestroy(ptr noundef %48)
  call void @pdestroy(ptr noundef %1)
  %49 = load i32, ptr @debug, align 4, !tbaa !9
  %50 = icmp sgt i32 %49, 1
  br i1 %50, label %51, label %57

51:                                               ; preds = %47
  %52 = load ptr, ptr @stdout, align 8, !tbaa !5
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str, i32 noundef %0) #5
  %54 = load ptr, ptr @stdout, align 8, !tbaa !5
  %55 = fpext float %.0 to double
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef nonnull @.str.1, double noundef %55) #5
  br label %57

57:                                               ; preds = %51, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret float %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @pparmq(ptr noundef) local_unnamed_addr #2

declare i32 @podd(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @psetq(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @phalf(ptr noundef) local_unnamed_addr #3

declare ptr @utop(i32 noundef) local_unnamed_addr #3

declare i32 @pcmp(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @ppowmod(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @psub(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pdestroy(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { "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 = { 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 #5 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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