; LLVM IR from artagnon/phoenixfs :: btree (print_leaves)

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

%struct.node = type { ptr, ptr, ptr, i8, i16, ptr }

@order = external dso_local global i32, align 4
@verbose_output = external dso_local global i8, align 1
@.str.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

9:                                                ; preds = %1
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  store i32 1, ptr %5, align 4
  br label %98

11:                                               ; preds = %1
  br label %12

12:                                               ; preds = %18, %11
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.node, ptr %13, i32 0, i32 3
  %15 = load i8, ptr %14, align 8, !tbaa !9, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  %17 = xor i1 %16, true
  br i1 %17, label %18, label %24

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.node, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds ptr, ptr %21, i64 0
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %23, ptr %4, align 8, !tbaa !5
  br label %12, !llvm.loop !16

24:                                               ; preds = %12
  br label %25

25:                                               ; preds = %95, %24
  br label %26

26:                                               ; preds = %25
  store i32 0, ptr %3, align 4, !tbaa !18
  br label %27

27:                                               ; preds = %57, %26
  %28 = load i32, ptr %3, align 4, !tbaa !18
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.node, ptr %29, i32 0, i32 4
  %31 = load i16, ptr %30, align 2, !tbaa !20
  %32 = zext i16 %31 to i32
  %33 = icmp slt i32 %28, %32
  br i1 %33, label %34, label %60

34:                                               ; preds = %27
  %35 = load i8, ptr @verbose_output, align 1, !tbaa !21, !range !13, !noundef !14
  %36 = trunc i8 %35 to i1
  br i1 %36, label %37, label %47

37:                                               ; preds = %34
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.node, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = load i32, ptr %3, align 4, !tbaa !18
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds ptr, ptr %40, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = ptrtoint ptr %44 to i64
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, i64 noundef %45)
  br label %47

47:                                               ; preds = %37, %34
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.node, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !22
  %51 = load i32, ptr %3, align 4, !tbaa !18
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i16, ptr %50, i64 %52
  %54 = load i16, ptr %53, align 2, !tbaa !23
  %55 = zext i16 %54 to i32
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, i32 noundef %55)
  br label %57

57:                                               ; preds = %47
  %58 = load i32, ptr %3, align 4, !tbaa !18
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %3, align 4, !tbaa !18
  br label %27, !llvm.loop !24

60:                                               ; preds = %27
  %61 = load i8, ptr @verbose_output, align 1, !tbaa !21, !range !13, !noundef !14
  %62 = trunc i8 %61 to i1
  br i1 %62, label %63, label %74

63:                                               ; preds = %60
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.node, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = load i32, ptr @order, align 4, !tbaa !18
  %68 = sub nsw i32 %67, 1
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds ptr, ptr %66, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = ptrtoint ptr %71 to i64
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, i64 noundef %72)
  br label %74

74:                                               ; preds = %63, %60
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.node, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load i32, ptr @order, align 4, !tbaa !18
  %79 = sub nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %77, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !5
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %94

84:                                               ; preds = %74
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.node, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !15
  %89 = load i32, ptr @order, align 4, !tbaa !18
  %90 = sub nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %88, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  store ptr %93, ptr %4, align 8, !tbaa !5
  br label %95

94:                                               ; preds = %74
  br label %96

95:                                               ; preds = %84
  br label %25

96:                                               ; preds = %94
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  store i32 0, ptr %5, align 4
  br label %98

98:                                               ; preds = %96, %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %99 = load i32, ptr %5, align 4
  switch i32 %99, label %101 [
    i32 0, label %100
    i32 1, label %100
  ]

100:                                              ; preds = %98, %98
  ret void

101:                                              ; preds = %98
  unreachable
}

attributes #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 = { 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 = { 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, !11, i64 24}
!10 = !{!"node", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 26, !6, i64 32}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!10, !12, i64 26}
!21 = !{!11, !11, i64 0}
!22 = !{!10, !6, i64 8}
!23 = !{!12, !12, i64 0}
!24 = distinct !{!24, !17}


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

@order = external dso_local local_unnamed_addr global i32, align 4
@verbose_output = external dso_local local_unnamed_addr global i8, align 1
@.str.18 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_leaves(ptr noundef readonly %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %.loopexit, label %.preheader15

.preheader15:                                     ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !12, !noundef !13
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %.preheader.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader15, %.lr.ph
  %.016 = phi ptr [ %7, %.lr.ph ], [ %0, %.preheader15 ]
  %6 = load ptr, ptr %.016, align 8, !tbaa !14
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %7, i64 24
  %9 = load i8, ptr %8, align 8, !tbaa !5, !range !12, !noundef !13
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %.preheader.preheader, label %.lr.ph, !llvm.loop !16

.preheader.preheader:                             ; preds = %.lr.ph, %.preheader15
  %.1.ph = phi ptr [ %0, %.preheader15 ], [ %7, %.lr.ph ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %49
  %.1 = phi ptr [ %56, %49 ], [ %.1.ph, %.preheader.preheader ]
  %11 = getelementptr inbounds i8, ptr %.1, i64 26
  %12 = load i16, ptr %11, align 2, !tbaa !18
  %.not19 = icmp eq i16 %12, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph18

.lr.ph18:                                         ; preds = %.preheader
  %13 = getelementptr inbounds i8, ptr %.1, i64 8
  br label %14

14:                                               ; preds = %.lr.ph18, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph18 ], [ %indvars.iv.next, %23 ]
  %15 = load i8, ptr @verbose_output, align 1, !tbaa !19, !range !12, !noundef !13
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %17, label %23

17:                                               ; preds = %14
  %18 = load ptr, ptr %.1, align 8, !tbaa !14
  %19 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = ptrtoint ptr %20 to i64
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, i64 noundef %21)
  br label %23

23:                                               ; preds = %17, %14
  %24 = load ptr, ptr %13, align 8, !tbaa !20
  %25 = getelementptr inbounds i16, ptr %24, i64 %indvars.iv
  %26 = load i16, ptr %25, align 2, !tbaa !21
  %27 = zext i16 %26 to i32
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef %27)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i16, ptr %11, align 2, !tbaa !18
  %30 = zext i16 %29 to i64
  %31 = icmp ult i64 %indvars.iv.next, %30
  br i1 %31, label %14, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %23, %.preheader
  %32 = load i8, ptr @verbose_output, align 1, !tbaa !19, !range !12, !noundef !13
  %33 = trunc nuw i8 %32 to i1
  %.pre21 = load i32, ptr @order, align 4, !tbaa !23
  br i1 %33, label %34, label %42

34:                                               ; preds = %._crit_edge
  %35 = load ptr, ptr %.1, align 8, !tbaa !14
  %36 = sext i32 %.pre21 to i64
  %37 = getelementptr ptr, ptr %35, i64 %36
  %38 = getelementptr i8, ptr %37, i64 -8
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = ptrtoint ptr %39 to i64
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, i64 noundef %40)
  %.pre = load i32, ptr @order, align 4, !tbaa !23
  br label %42

42:                                               ; preds = %34, %._crit_edge
  %43 = phi i32 [ %.pre, %34 ], [ %.pre21, %._crit_edge ]
  %44 = load ptr, ptr %.1, align 8, !tbaa !14
  %45 = sext i32 %43 to i64
  %46 = getelementptr ptr, ptr %44, i64 %45
  %47 = getelementptr i8, ptr %46, i64 -8
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %.not = icmp eq ptr %48, null
  br i1 %.not, label %.loopexit, label %49

49:                                               ; preds = %42
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  %51 = load ptr, ptr %.1, align 8, !tbaa !14
  %52 = load i32, ptr @order, align 4, !tbaa !23
  %53 = sext i32 %52 to i64
  %54 = getelementptr ptr, ptr %51, i64 %53
  %55 = getelementptr i8, ptr %54, i64 -8
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  br label %.preheader

.loopexit:                                        ; preds = %42, %1
  %.str.22.sink = phi ptr [ @.str.18, %1 ], [ @.str.22, %42 ]
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.22.sink)
  ret void
}

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 = { nofree 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" }

!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, !10, i64 24}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 26, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !11, i64 26}
!19 = !{!10, !10, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{!11, !11, i64 0}
!22 = distinct !{!22, !17}
!23 = !{!24, !24, i64 0}
!24 = !{!"int", !8, i64 0}


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