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

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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 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
define dso_local void @printSoln(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #1 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i32 %4, ptr %13, align 4, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !9
  store i32 1, ptr %17, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %34, %8
  %20 = load i32, ptr %17, align 4, !tbaa !9
  %21 = load i32, ptr %13, align 4, !tbaa !9
  %22 = icmp ule i32 %20, %21
  br i1 %22, label %23, label %37

23:                                               ; preds = %19
  %24 = load ptr, ptr %16, align 8, !tbaa !5
  %25 = load i32, ptr %17, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = zext i8 %28 to i32
  %30 = icmp ne i32 %29, 0
  %31 = zext i1 %30 to i32
  %32 = load i32, ptr %18, align 4, !tbaa !9
  %33 = add i32 %32, %31
  store i32 %33, ptr %18, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %23
  %35 = load i32, ptr %17, align 4, !tbaa !9
  %36 = add i32 %35, 1
  store i32 %36, ptr %17, align 4, !tbaa !9
  br label %19, !llvm.loop !12

37:                                               ; preds = %19
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = call i32 @fputs(ptr noundef %38, ptr noundef %39)
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  %43 = call ptr @pparmq(ptr noundef %42)
  %44 = call i32 @fputp(ptr noundef %41, ptr noundef %43)
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = call i32 @fputs(ptr noundef @.str, ptr noundef %45)
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = zext i8 %48 to i32
  %50 = and i32 %49, 1
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %37
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call i32 @putc(i32 noundef 45, ptr noundef %53)
  br label %58

55:                                               ; preds = %37
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = call i32 @putc(i32 noundef 43, ptr noundef %56)
  br label %58

58:                                               ; preds = %55, %52
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = call ptr @pparmq(ptr noundef %60)
  %62 = call i32 @fputp(ptr noundef %59, ptr noundef %61)
  %63 = load i32, ptr %18, align 4, !tbaa !9
  %64 = icmp uge i32 %63, 1
  br i1 %64, label %65, label %68

65:                                               ; preds = %58
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = call i32 @fputs(ptr noundef @.str.1, ptr noundef %66)
  br label %68

68:                                               ; preds = %65, %58
  br label %69

69:                                               ; preds = %91, %68
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i32 1
  store ptr %71, ptr %16, align 8, !tbaa !5
  %72 = load ptr, ptr %16, align 8, !tbaa !5
  %73 = load i8, ptr %72, align 1, !tbaa !11
  %74 = zext i8 %73 to i32
  switch i32 %74, label %80 [
    i32 0, label %88
    i32 1, label %75
  ]

75:                                               ; preds = %69
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load i32, ptr %77, align 4, !tbaa !9
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef @.str.2, i32 noundef %78) #5
  br label %88

80:                                               ; preds = %69
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = load i8, ptr %84, align 1, !tbaa !11
  %86 = zext i8 %85 to i32
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.3, i32 noundef %83, i32 noundef %86) #5
  br label %88

88:                                               ; preds = %80, %75, %69
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds i32, ptr %89, i32 1
  store ptr %90, ptr %12, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %88
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = add i32 %92, -1
  store i32 %93, ptr %13, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %69, label %95, !llvm.loop !14

95:                                               ; preds = %91
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = call i32 @fputs(ptr noundef %96, ptr noundef %97)
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = call i32 @fflush(ptr noundef %99)
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  call void @pdestroy(ptr noundef %101)
  %102 = load ptr, ptr %15, align 8, !tbaa !5
  call void @pdestroy(ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  ret void
}

declare i32 @fputs(ptr noundef, ptr noundef) #2

declare i32 @fputp(ptr noundef, ptr noundef) #2

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

declare i32 @putc(i32 noundef, ptr noundef) #2

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

declare i32 @fflush(ptr noundef) #2

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

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 = { "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 = { 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 #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 = !{!"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}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @printSoln(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, i32 noundef %4, ptr noundef %5, ptr noundef %6, ptr nocapture noundef readonly %7) local_unnamed_addr #0 {
  %.not40 = icmp eq i32 %4, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %8
  %9 = add i32 %4, 1
  %umax = tail call i32 @llvm.umax.i32(i32 %9, i32 2)
  %wide.trip.count = zext i32 %umax to i64
  %10 = add nsw i64 %wide.trip.count, -1
  %min.iters.check = icmp ult i32 %9, 9
  br i1 %min.iters.check, label %.lr.ph.preheader46, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %10, -8
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %17, %vector.body ]
  %vec.phi44 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %18, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %11 = getelementptr inbounds i8, ptr %7, i64 %offset.idx
  %12 = getelementptr inbounds i8, ptr %11, i64 4
  %wide.load = load <4 x i8>, ptr %11, align 1, !tbaa !5
  %wide.load45 = load <4 x i8>, ptr %12, align 1, !tbaa !5
  %13 = icmp ne <4 x i8> %wide.load, zeroinitializer
  %14 = icmp ne <4 x i8> %wide.load45, zeroinitializer
  %15 = zext <4 x i1> %13 to <4 x i32>
  %16 = zext <4 x i1> %14 to <4 x i32>
  %17 = add <4 x i32> %vec.phi, %15
  %18 = add <4 x i32> %vec.phi44, %16
  %index.next = add nuw i64 %index, 8
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %18, %17
  %20 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %10, %n.vec
  br i1 %cmp.n, label %._crit_edge.loopexit, label %.lr.ph.preheader46

.lr.ph.preheader46:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.042.ph = phi i32 [ 0, %.lr.ph.preheader ], [ %20, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader46, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader46 ]
  %.042 = phi i32 [ %25, %.lr.ph ], [ %.042.ph, %.lr.ph.preheader46 ]
  %21 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = icmp ne i8 %22, 0
  %24 = zext i1 %23 to i32
  %25 = add i32 %.042, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %.lr.ph, %middle.block
  %.lcssa = phi i32 [ %20, %middle.block ], [ %25, %.lr.ph ]
  %26 = icmp eq i32 %.lcssa, 0
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %8
  %.0.lcssa = phi i1 [ true, %8 ], [ %26, %._crit_edge.loopexit ]
  %27 = tail call i32 @fputs(ptr noundef %1, ptr noundef %0)
  %28 = tail call ptr @pparmq(ptr noundef %5)
  %29 = tail call i32 @fputp(ptr noundef %0, ptr noundef %28) #5
  %30 = tail call i32 @fputs(ptr noundef nonnull @.str, ptr noundef %0)
  %31 = load i8, ptr %7, align 1, !tbaa !5
  %32 = and i8 %31, 1
  %.not37 = icmp eq i8 %32, 0
  %. = select i1 %.not37, i32 43, i32 45
  %33 = tail call i32 @putc(i32 noundef %., ptr noundef %0)
  %34 = tail call ptr @pparmq(ptr noundef %6)
  %35 = tail call i32 @fputp(ptr noundef %0, ptr noundef %34) #5
  br i1 %.0.lcssa, label %.preheader, label %36

36:                                               ; preds = %._crit_edge
  %37 = tail call i32 @fputs(ptr noundef nonnull @.str.1, ptr noundef %0)
  br label %.preheader

.preheader:                                       ; preds = %36, %._crit_edge
  br label %38

38:                                               ; preds = %.preheader, %48
  %.034 = phi i32 [ %50, %48 ], [ %4, %.preheader ]
  %.033 = phi ptr [ %49, %48 ], [ %3, %.preheader ]
  %.032 = phi ptr [ %39, %48 ], [ %7, %.preheader ]
  %39 = getelementptr inbounds i8, ptr %.032, i64 1
  %40 = load i8, ptr %39, align 1, !tbaa !5
  switch i8 %40, label %44 [
    i8 0, label %48
    i8 1, label %41
  ]

41:                                               ; preds = %38
  %42 = load i32, ptr %.033, align 4, !tbaa !13
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.2, i32 noundef %42) #5
  br label %48

44:                                               ; preds = %38
  %45 = zext i8 %40 to i32
  %46 = load i32, ptr %.033, align 4, !tbaa !13
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.3, i32 noundef %46, i32 noundef %45) #5
  br label %48

48:                                               ; preds = %44, %41, %38
  %49 = getelementptr inbounds i8, ptr %.033, i64 4
  %50 = add i32 %.034, -1
  %.not39 = icmp eq i32 %50, 0
  br i1 %.not39, label %51, label %38, !llvm.loop !15

51:                                               ; preds = %48
  %52 = tail call i32 @fputs(ptr noundef %2, ptr noundef %0)
  %53 = tail call i32 @fflush(ptr noundef %0)
  tail call void @pdestroy(ptr noundef %5)
  tail call void @pdestroy(ptr noundef %6)
  ret void
}

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

declare i32 @fputp(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #4

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 = { "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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !11, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !6, i64 0}
!15 = distinct !{!15, !9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass