; LLVM IR from google/rune :: benchmarks (binary_trees2)

; 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 [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 4, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 10, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 1
  br i1 %18, label %19, label %24

19:                                               ; preds = %2
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %20, i64 1
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call i32 @atoi(ptr noundef %22) #8
  store i32 %23, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %19, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = add i32 %25, 1
  store i32 %26, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %27)
  store ptr %28, ptr %9, align 8, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %29, i32 noundef %31)
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  %34 = icmp eq ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %24
  call void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %33) #7
  call void @_ZdlPvm(ptr noundef %33, i64 noundef 16) #9
  br label %36

36:                                               ; preds = %35, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %37)
  store ptr %38, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = shl i32 1, %39
  store i32 %40, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %41 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %41, ptr %12, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %75, %36
  %43 = load i32, ptr %12, align 4, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = icmp ult i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %78

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %65, %47
  %49 = load i32, ptr %15, align 4, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = add i32 %50, 1
  %52 = icmp ult i32 %49, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %48
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %68

54:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %55 = load i32, ptr %12, align 4, !tbaa !5
  %56 = call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %55)
  store ptr %56, ptr %16, align 8, !tbaa !9
  %57 = load ptr, ptr %16, align 8, !tbaa !9
  %58 = call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %57)
  %59 = load i32, ptr %14, align 4, !tbaa !5
  %60 = add i32 %59, %58
  store i32 %60, ptr %14, align 4, !tbaa !5
  %61 = load ptr, ptr %16, align 8, !tbaa !9
  %62 = icmp eq ptr %61, null
  br i1 %62, label %64, label %63

63:                                               ; preds = %54
  call void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %61) #7
  call void @_ZdlPvm(ptr noundef %61, i64 noundef 16) #9
  br label %64

64:                                               ; preds = %63, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %15, align 4, !tbaa !5
  %67 = add i32 %66, 1
  store i32 %67, ptr %15, align 4, !tbaa !5
  br label %48, !llvm.loop !11

68:                                               ; preds = %53
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = load i32, ptr %12, align 4, !tbaa !5
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %69, i32 noundef %70, i32 noundef %71)
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = lshr i32 %73, 2
  store i32 %74, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %75

75:                                               ; preds = %68
  %76 = load i32, ptr %12, align 4, !tbaa !5
  %77 = add i32 %76, 2
  store i32 %77, ptr %12, align 4, !tbaa !5
  br label %42, !llvm.loop !13

78:                                               ; preds = %46
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %80)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %79, i32 noundef %81)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %83 = load i32, ptr %3, align 4
  ret i32 %83
}

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

; Function Attrs: inlinehint mustprogress nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4Node8makeTreeEj(i32 noundef) #3 align 2

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #5 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

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

attributes #0 = { mustprogress norecurse 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 mustprogress nounwind willreturn memory(read) 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 = { mustprogress 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 = { "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 = { mustprogress 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 #6 = { nobuiltin 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call i32 @atoi(ptr nocapture noundef %6) #6
  br label %8

8:                                                ; preds = %4, %2
  %.029 = phi i32 [ %7, %4 ], [ 10, %2 ]
  %9 = add i32 %.029, 1
  %10 = tail call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %9)
  %11 = tail call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %9, i32 noundef %11)
  tail call void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #7
  tail call void @_ZdlPvm(ptr noundef %10, i64 noundef 16) #8
  %13 = tail call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %.029)
  %14 = icmp ugt i32 %9, 4
  br i1 %14, label %.preheader.preheader, label %._crit_edge34

.preheader.preheader:                             ; preds = %8
  %15 = shl nuw i32 1, %.029
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %.02733 = phi i32 [ %22, %._crit_edge ], [ 4, %.preheader.preheader ]
  %.02832 = phi i32 [ %21, %._crit_edge ], [ %15, %.preheader.preheader ]
  %16 = add i32 %.02832, -1
  %17 = icmp ult i32 %16, -2
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge34:                                    ; preds = %._crit_edge, %8
  %18 = tail call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.029, i32 noundef %18)
  ret i32 0

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.026.lcssa = phi i32 [ 0, %.preheader ], [ %26, %.lr.ph ]
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.02832, i32 noundef %.02733, i32 noundef %.026.lcssa)
  %21 = lshr i32 %.02832, 2
  %22 = add i32 %.02733, 2
  %23 = icmp ult i32 %22, %9
  br i1 %23, label %.preheader, label %._crit_edge34, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.031 = phi i32 [ %27, %.lr.ph ], [ 1, %.preheader ]
  %.02630 = phi i32 [ %26, %.lr.ph ], [ 0, %.preheader ]
  %24 = tail call noundef ptr @_ZN4Node8makeTreeEj(i32 noundef %.02733)
  %25 = tail call noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  %26 = add i32 %25, %.02630
  tail call void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %24) #7
  tail call void @_ZdlPvm(ptr noundef %24, i64 noundef 16) #8
  %27 = add nuw i32 %.031, 1
  %exitcond.not = icmp eq i32 %.031, %.02832
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN4Node8makeTreeEj(i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4Node5checkEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4NodeD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { mustprogress norecurse 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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 = { mustprogress 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 = { 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 #4 = { mustprogress 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 = { nobuiltin 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 #6 = { nounwind willreturn memory(read) }
attributes #7 = { nounwind }
attributes #8 = { builtin 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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