; LLVM IR from ryanlayer/giggle :: src (leaf)

; 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.leaf_data = type { i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr }

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

15:                                               ; preds = %31, %1
  %16 = load i32, ptr %3, align 4, !tbaa !14
  %17 = zext i32 %16 to i64
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.leaf_data, ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = icmp ult i64 %17, %20
  br i1 %21, label %22, label %34

22:                                               ; preds = %15
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.leaf_data, ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load i32, ptr %3, align 4, !tbaa !14
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds i64, ptr %25, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !17
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %29)
  br label %31

31:                                               ; preds = %22
  %32 = load i32, ptr %3, align 4, !tbaa !14
  %33 = add i32 %32, 1
  store i32 %33, ptr %3, align 4, !tbaa !14
  br label %15, !llvm.loop !18

34:                                               ; preds = %15
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %37

37:                                               ; preds = %53, %34
  %38 = load i32, ptr %3, align 4, !tbaa !14
  %39 = zext i32 %38 to i64
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.leaf_data, ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !12
  %43 = icmp ult i64 %39, %42
  br i1 %43, label %44, label %56

44:                                               ; preds = %37
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.leaf_data, ptr %45, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  %48 = load i32, ptr %3, align 4, !tbaa !14
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i64, ptr %47, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !17
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %51)
  br label %53

53:                                               ; preds = %44
  %54 = load i32, ptr %3, align 4, !tbaa !14
  %55 = add i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !14
  br label %37, !llvm.loop !21

56:                                               ; preds = %37
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %59

59:                                               ; preds = %75, %56
  %60 = load i32, ptr %3, align 4, !tbaa !14
  %61 = zext i32 %60 to i64
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.leaf_data, ptr %62, i32 0, i32 2
  %64 = load i64, ptr %63, align 8, !tbaa !13
  %65 = icmp ult i64 %61, %64
  br i1 %65, label %66, label %78

66:                                               ; preds = %59
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.leaf_data, ptr %67, i32 0, i32 7
  %69 = load ptr, ptr %68, align 8, !tbaa !22
  %70 = load i32, ptr %3, align 4, !tbaa !14
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds i64, ptr %69, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !17
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %73)
  br label %75

75:                                               ; preds = %66
  %76 = load i32, ptr %3, align 4, !tbaa !14
  %77 = add i32 %76, 1
  store i32 %77, ptr %3, align 4, !tbaa !14
  br label %59, !llvm.loop !23

78:                                               ; preds = %59
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %81

81:                                               ; preds = %94, %78
  %82 = load i32, ptr %3, align 4, !tbaa !14
  %83 = load i32, ptr @ORDER, align 4, !tbaa !14
  %84 = icmp ult i32 %82, %83
  br i1 %84, label %85, label %97

85:                                               ; preds = %81
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.leaf_data, ptr %86, i32 0, i32 3
  %88 = load ptr, ptr %87, align 8, !tbaa !24
  %89 = load i32, ptr %3, align 4, !tbaa !14
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds i32, ptr %88, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !14
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %92)
  br label %94

94:                                               ; preds = %85
  %95 = load i32, ptr %3, align 4, !tbaa !14
  %96 = add i32 %95, 1
  store i32 %96, ptr %3, align 4, !tbaa !14
  br label %81, !llvm.loop !25

97:                                               ; preds = %81
  %98 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %100

100:                                              ; preds = %113, %97
  %101 = load i32, ptr %3, align 4, !tbaa !14
  %102 = load i32, ptr @ORDER, align 4, !tbaa !14
  %103 = icmp ult i32 %101, %102
  br i1 %103, label %104, label %116

104:                                              ; preds = %100
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.leaf_data, ptr %105, i32 0, i32 4
  %107 = load ptr, ptr %106, align 8, !tbaa !26
  %108 = load i32, ptr %3, align 4, !tbaa !14
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds i32, ptr %107, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !14
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %111)
  br label %113

113:                                              ; preds = %104
  %114 = load i32, ptr %3, align 4, !tbaa !14
  %115 = add i32 %114, 1
  store i32 %115, ptr %3, align 4, !tbaa !14
  br label %100, !llvm.loop !27

116:                                              ; preds = %100
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

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

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 = { 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 0}
!10 = !{!"leaf_data", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !6, i64 40}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !6, i64 48}
!21 = distinct !{!21, !19}
!22 = !{!10, !6, i64 56}
!23 = distinct !{!23, !19}
!24 = !{!10, !6, i64 24}
!25 = distinct !{!25, !19}
!26 = !{!10, !6, i64 32}
!27 = distinct !{!27, !19}


; 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
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @leaf_data_print(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %2, i64 noundef %4, i64 noundef %6)
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %9 = load i64, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %12 = phi i64 [ 0, %.lr.ph ], [ %18, %11 ]
  %.028 = phi i32 [ 0, %.lr.ph ], [ %17, %11 ]
  %13 = load ptr, ptr %10, align 8, !tbaa !13
  %14 = getelementptr inbounds i64, ptr %13, i64 %12
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %15)
  %17 = add i32 %.028, 1
  %18 = zext i32 %17 to i64
  %19 = load i64, ptr %0, align 8, !tbaa !5
  %20 = icmp ugt i64 %19, %18
  br i1 %20, label %11, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %11, %1
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %23 = load i64, ptr %3, align 8, !tbaa !11
  %.not45 = icmp eq i64 %23, 0
  br i1 %.not45, label %._crit_edge32, label %.lr.ph31

.lr.ph31:                                         ; preds = %._crit_edge
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  br label %25

25:                                               ; preds = %.lr.ph31, %25
  %26 = phi i64 [ 0, %.lr.ph31 ], [ %32, %25 ]
  %.129 = phi i32 [ 0, %.lr.ph31 ], [ %31, %25 ]
  %27 = load ptr, ptr %24, align 8, !tbaa !17
  %28 = getelementptr inbounds i64, ptr %27, i64 %26
  %29 = load i64, ptr %28, align 8, !tbaa !14
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %29)
  %31 = add i32 %.129, 1
  %32 = zext i32 %31 to i64
  %33 = load i64, ptr %3, align 8, !tbaa !11
  %34 = icmp ugt i64 %33, %32
  br i1 %34, label %25, label %._crit_edge32, !llvm.loop !18

._crit_edge32:                                    ; preds = %25, %._crit_edge
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %37 = load i64, ptr %5, align 8, !tbaa !12
  %.not46 = icmp eq i64 %37, 0
  br i1 %.not46, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %._crit_edge32
  %38 = getelementptr inbounds i8, ptr %0, i64 56
  br label %39

39:                                               ; preds = %.lr.ph35, %39
  %40 = phi i64 [ 0, %.lr.ph35 ], [ %46, %39 ]
  %.233 = phi i32 [ 0, %.lr.ph35 ], [ %45, %39 ]
  %41 = load ptr, ptr %38, align 8, !tbaa !19
  %42 = getelementptr inbounds i64, ptr %41, i64 %40
  %43 = load i64, ptr %42, align 8, !tbaa !14
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %43)
  %45 = add i32 %.233, 1
  %46 = zext i32 %45 to i64
  %47 = load i64, ptr %5, align 8, !tbaa !12
  %48 = icmp ugt i64 %47, %46
  br i1 %48, label %39, label %._crit_edge36, !llvm.loop !20

._crit_edge36:                                    ; preds = %39, %._crit_edge32
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %51 = load i32, ptr @ORDER, align 4, !tbaa !21
  %.not47 = icmp eq i32 %51, 0
  br i1 %.not47, label %._crit_edge40, label %.lr.ph39

.lr.ph39:                                         ; preds = %._crit_edge36
  %52 = getelementptr inbounds i8, ptr %0, i64 24
  br label %53

53:                                               ; preds = %.lr.ph39, %53
  %indvars.iv = phi i64 [ 0, %.lr.ph39 ], [ %indvars.iv.next, %53 ]
  %54 = load ptr, ptr %52, align 8, !tbaa !23
  %55 = getelementptr inbounds i32, ptr %54, i64 %indvars.iv
  %56 = load i32, ptr %55, align 4, !tbaa !21
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %56)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = load i32, ptr @ORDER, align 4, !tbaa !21
  %59 = zext i32 %58 to i64
  %60 = icmp ult i64 %indvars.iv.next, %59
  br i1 %60, label %53, label %._crit_edge40, !llvm.loop !24

._crit_edge40:                                    ; preds = %53, %._crit_edge36
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %63 = load i32, ptr @ORDER, align 4, !tbaa !21
  %.not48 = icmp eq i32 %63, 0
  br i1 %.not48, label %._crit_edge44, label %.lr.ph43

.lr.ph43:                                         ; preds = %._crit_edge40
  %64 = getelementptr inbounds i8, ptr %0, i64 32
  br label %65

65:                                               ; preds = %.lr.ph43, %65
  %indvars.iv50 = phi i64 [ 0, %.lr.ph43 ], [ %indvars.iv.next51, %65 ]
  %66 = load ptr, ptr %64, align 8, !tbaa !25
  %67 = getelementptr inbounds i32, ptr %66, i64 %indvars.iv50
  %68 = load i32, ptr %67, align 4, !tbaa !21
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %68)
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %70 = load i32, ptr @ORDER, align 4, !tbaa !21
  %71 = zext i32 %70 to i64
  %72 = icmp ult i64 %indvars.iv.next51, %71
  br i1 %72, label %65, label %._crit_edge44, !llvm.loop !26

._crit_edge44:                                    ; preds = %65, %._crit_edge40
  %73 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  ret void
}

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

attributes #0 = { 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" }
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" }

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


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