; LLVM IR from JessonYue/LeetCodeLearning :: BaseDataStructure/tree/leveltraversal.ll (Z12CreateBiTreePP7BiTNode)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z12CreateBiTreePP7BiTNode(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = call noalias ptr @malloc(i64 noundef 24) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %3, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.BiTNode, ptr %6, i32 0, i32 0
  store i32 1, ptr %7, align 8, !tbaa !9
  %8 = call noalias ptr @malloc(i64 noundef 24) #2
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.BiTNode, ptr %10, i32 0, i32 1
  store ptr %8, ptr %11, align 8, !tbaa !12
  %12 = call noalias ptr @malloc(i64 noundef 24) #2
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.BiTNode, ptr %14, i32 0, i32 2
  store ptr %12, ptr %15, align 8, !tbaa !13
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.BiTNode, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds %struct.BiTNode, ptr %19, i32 0, i32 0
  store i32 2, ptr %20, align 8, !tbaa !9
  %21 = call noalias ptr @malloc(i64 noundef 24) #2
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.BiTNode, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds %struct.BiTNode, ptr %25, i32 0, i32 1
  store ptr %21, ptr %26, align 8, !tbaa !12
  %27 = call noalias ptr @malloc(i64 noundef 24) #2
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.BiTNode, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = getelementptr inbounds %struct.BiTNode, ptr %31, i32 0, i32 2
  store ptr %27, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.BiTNode, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = getelementptr inbounds %struct.BiTNode, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.BiTNode, ptr %38, i32 0, i32 0
  store i32 5, ptr %39, align 8, !tbaa !9
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.BiTNode, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.BiTNode, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = getelementptr inbounds %struct.BiTNode, ptr %45, i32 0, i32 1
  store ptr null, ptr %46, align 8, !tbaa !12
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.BiTNode, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !12
  %51 = getelementptr inbounds %struct.BiTNode, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !13
  %53 = getelementptr inbounds %struct.BiTNode, ptr %52, i32 0, i32 2
  store ptr null, ptr %53, align 8, !tbaa !13
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.BiTNode, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = getelementptr inbounds %struct.BiTNode, ptr %57, i32 0, i32 0
  store i32 3, ptr %58, align 8, !tbaa !9
  %59 = call noalias ptr @malloc(i64 noundef 24) #2
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.BiTNode, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  %64 = getelementptr inbounds %struct.BiTNode, ptr %63, i32 0, i32 1
  store ptr %59, ptr %64, align 8, !tbaa !12
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.BiTNode, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %69 = getelementptr inbounds %struct.BiTNode, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !12
  %71 = getelementptr inbounds %struct.BiTNode, ptr %70, i32 0, i32 0
  store i32 6, ptr %71, align 8, !tbaa !9
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.BiTNode, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = getelementptr inbounds %struct.BiTNode, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !12
  %78 = getelementptr inbounds %struct.BiTNode, ptr %77, i32 0, i32 1
  store ptr null, ptr %78, align 8, !tbaa !12
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.BiTNode, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  %83 = getelementptr inbounds %struct.BiTNode, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !12
  %85 = getelementptr inbounds %struct.BiTNode, ptr %84, i32 0, i32 2
  store ptr null, ptr %85, align 8, !tbaa !13
  %86 = call noalias ptr @malloc(i64 noundef 24) #2
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = load ptr, ptr %87, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.BiTNode, ptr %88, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = getelementptr inbounds %struct.BiTNode, ptr %90, i32 0, i32 2
  store ptr %86, ptr %91, align 8, !tbaa !13
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.BiTNode, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !13
  %96 = getelementptr inbounds %struct.BiTNode, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !13
  %98 = getelementptr inbounds %struct.BiTNode, ptr %97, i32 0, i32 0
  store i32 7, ptr %98, align 8, !tbaa !9
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.BiTNode, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !13
  %103 = getelementptr inbounds %struct.BiTNode, ptr %102, i32 0, i32 2
  %104 = load ptr, ptr %103, align 8, !tbaa !13
  %105 = getelementptr inbounds %struct.BiTNode, ptr %104, i32 0, i32 1
  store ptr null, ptr %105, align 8, !tbaa !12
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  %107 = load ptr, ptr %106, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.BiTNode, ptr %107, i32 0, i32 2
  %109 = load ptr, ptr %108, align 8, !tbaa !13
  %110 = getelementptr inbounds %struct.BiTNode, ptr %109, i32 0, i32 2
  %111 = load ptr, ptr %110, align 8, !tbaa !13
  %112 = getelementptr inbounds %struct.BiTNode, ptr %111, i32 0, i32 2
  store ptr null, ptr %112, align 8, !tbaa !13
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = load ptr, ptr %113, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.BiTNode, ptr %114, i32 0, i32 1
  %116 = load ptr, ptr %115, align 8, !tbaa !12
  %117 = getelementptr inbounds %struct.BiTNode, ptr %116, i32 0, i32 1
  %118 = load ptr, ptr %117, align 8, !tbaa !12
  %119 = getelementptr inbounds %struct.BiTNode, ptr %118, i32 0, i32 0
  store i32 4, ptr %119, align 8, !tbaa !9
  %120 = load ptr, ptr %2, align 8, !tbaa !5
  %121 = load ptr, ptr %120, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.BiTNode, ptr %121, i32 0, i32 1
  %123 = load ptr, ptr %122, align 8, !tbaa !12
  %124 = getelementptr inbounds %struct.BiTNode, ptr %123, i32 0, i32 1
  %125 = load ptr, ptr %124, align 8, !tbaa !12
  %126 = getelementptr inbounds %struct.BiTNode, ptr %125, i32 0, i32 1
  store ptr null, ptr %126, align 8, !tbaa !12
  %127 = load ptr, ptr %2, align 8, !tbaa !5
  %128 = load ptr, ptr %127, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.BiTNode, ptr %128, i32 0, i32 1
  %130 = load ptr, ptr %129, align 8, !tbaa !12
  %131 = getelementptr inbounds %struct.BiTNode, ptr %130, i32 0, i32 1
  %132 = load ptr, ptr %131, align 8, !tbaa !12
  %133 = getelementptr inbounds %struct.BiTNode, ptr %132, i32 0, i32 2
  store ptr null, ptr %133, align 8, !tbaa !13
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

attributes #0 = { 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 #1 = { nounwind allocsize(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 = { nounwind allocsize(0) }

!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 = !{!10, !11, i64 0}
!10 = !{!"_ZTS7BiTNode", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}


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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, inaccessiblemem: readwrite) uwtable
define dso_local void @_Z12CreateBiTreePP7BiTNode(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  store ptr %2, ptr %0, align 8, !tbaa !5
  store i32 1, ptr %2, align 8, !tbaa !9
  %3 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %3, ptr %4, align 8, !tbaa !12
  %5 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %5, ptr %6, align 8, !tbaa !13
  store i32 2, ptr %3, align 8, !tbaa !9
  %7 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %7, ptr %8, align 8, !tbaa !12
  %9 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %9, ptr %10, align 8, !tbaa !13
  store i32 5, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %9, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %11, i8 0, i64 16, i1 false)
  store i32 3, ptr %5, align 8, !tbaa !9
  %12 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %13 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %12, ptr %13, align 8, !tbaa !12
  store i32 6, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  %15 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  %16 = getelementptr inbounds i8, ptr %5, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %14, i8 0, i64 16, i1 false)
  store ptr %15, ptr %16, align 8, !tbaa !13
  store i32 7, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %15, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  store i32 4, ptr %7, align 8, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %7, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %18, i8 0, i64 16, i1 false)
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, inaccessiblemem: readwrite) 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(0) }

!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 = !{!10, !11, i64 0}
!10 = !{!"_ZTS7BiTNode", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}


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