; LLVM IR from UtkarshPathrabe/Competitive-Coding :: Model Algorithms/Binary Tree (Identical Trees)

; 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 { i32, ptr, ptr }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newNodei(i32 noundef) #1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %5 = call noundef ptr @_Z7newNodei(i32 noundef 1)
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = call noundef ptr @_Z7newNodei(i32 noundef 2)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.node, ptr %7, i32 0, i32 1
  store ptr %6, ptr %8, align 8, !tbaa !9
  %9 = call noundef ptr @_Z7newNodei(i32 noundef 3)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.node, ptr %10, i32 0, i32 2
  store ptr %9, ptr %11, align 8, !tbaa !12
  %12 = call noundef ptr @_Z7newNodei(i32 noundef 4)
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.node, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.node, ptr %15, i32 0, i32 1
  store ptr %12, ptr %16, align 8, !tbaa !9
  %17 = call noundef ptr @_Z7newNodei(i32 noundef 5)
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.node, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.node, ptr %20, i32 0, i32 2
  store ptr %17, ptr %21, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %22 = call noundef ptr @_Z7newNodei(i32 noundef 1)
  store ptr %22, ptr %3, align 8, !tbaa !5
  %23 = call noundef ptr @_Z7newNodei(i32 noundef 2)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.node, ptr %24, i32 0, i32 1
  store ptr %23, ptr %25, align 8, !tbaa !9
  %26 = call noundef ptr @_Z7newNodei(i32 noundef 3)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 2
  store ptr %26, ptr %28, align 8, !tbaa !12
  %29 = call noundef ptr @_Z7newNodei(i32 noundef 4)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.node, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.node, ptr %32, i32 0, i32 1
  store ptr %29, ptr %33, align 8, !tbaa !9
  %34 = call noundef ptr @_Z7newNodei(i32 noundef 5)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.node, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.node, ptr %37, i32 0, i32 2
  store ptr %34, ptr %38, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %39 = call noundef ptr @_Z7newNodei(i32 noundef 1)
  store ptr %39, ptr %4, align 8, !tbaa !5
  %40 = call noundef ptr @_Z7newNodei(i32 noundef 2)
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.node, ptr %41, i32 0, i32 1
  store ptr %40, ptr %42, align 8, !tbaa !9
  %43 = call noundef ptr @_Z7newNodei(i32 noundef 3)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.node, ptr %44, i32 0, i32 2
  store ptr %43, ptr %45, align 8, !tbaa !12
  %46 = call noundef ptr @_Z7newNodei(i32 noundef 4)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.node, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.node, ptr %49, i32 0, i32 1
  store ptr %46, ptr %50, align 8, !tbaa !9
  %51 = call noundef ptr @_Z7newNodei(i32 noundef 6)
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.node, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.node, ptr %54, i32 0, i32 2
  store ptr %51, ptr %55, align 8, !tbaa !12
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef %56, ptr noundef %57)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %0
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %64

62:                                               ; preds = %0
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %64

64:                                               ; preds = %62, %60
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = call noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef %65, ptr noundef %66)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %64
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %73

71:                                               ; preds = %64
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %73

73:                                               ; preds = %71, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret i32 0
}

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

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { 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 = !{!10, !6, i64 8}
!10 = !{!"_ZTS4node", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!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"

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newNodei(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call noundef ptr @_Z7newNodei(i32 noundef 1)
  %2 = tail call noundef ptr @_Z7newNodei(i32 noundef 2)
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %2, ptr %3, align 8, !tbaa !5
  %4 = tail call noundef ptr @_Z7newNodei(i32 noundef 3)
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %4, ptr %5, align 8, !tbaa !11
  %6 = tail call noundef ptr @_Z7newNodei(i32 noundef 4)
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %6, ptr %8, align 8, !tbaa !5
  %9 = tail call noundef ptr @_Z7newNodei(i32 noundef 5)
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %9, ptr %11, align 8, !tbaa !11
  %12 = tail call noundef ptr @_Z7newNodei(i32 noundef 1)
  %13 = tail call noundef ptr @_Z7newNodei(i32 noundef 2)
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !5
  %15 = tail call noundef ptr @_Z7newNodei(i32 noundef 3)
  %16 = getelementptr inbounds i8, ptr %12, i64 16
  store ptr %15, ptr %16, align 8, !tbaa !11
  %17 = tail call noundef ptr @_Z7newNodei(i32 noundef 4)
  %18 = load ptr, ptr %14, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr %17, ptr %19, align 8, !tbaa !5
  %20 = tail call noundef ptr @_Z7newNodei(i32 noundef 5)
  %21 = load ptr, ptr %14, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store ptr %20, ptr %22, align 8, !tbaa !11
  %23 = tail call noundef ptr @_Z7newNodei(i32 noundef 1)
  %24 = tail call noundef ptr @_Z7newNodei(i32 noundef 2)
  %25 = getelementptr inbounds i8, ptr %23, i64 8
  store ptr %24, ptr %25, align 8, !tbaa !5
  %26 = tail call noundef ptr @_Z7newNodei(i32 noundef 3)
  %27 = getelementptr inbounds i8, ptr %23, i64 16
  store ptr %26, ptr %27, align 8, !tbaa !11
  %28 = tail call noundef ptr @_Z7newNodei(i32 noundef 4)
  %29 = load ptr, ptr %25, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  store ptr %28, ptr %30, align 8, !tbaa !5
  %31 = tail call noundef ptr @_Z7newNodei(i32 noundef 6)
  %32 = load ptr, ptr %25, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  store ptr %31, ptr %33, align 8, !tbaa !11
  %34 = tail call noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef %1, ptr noundef %12)
  %.not = icmp eq i32 %34, 0
  %.str.1..str = select i1 %.not, ptr @.str.1, ptr @.str
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str)
  %36 = tail call noundef i32 @_Z9sameTreesP4nodeS0_(ptr noundef nonnull %1, ptr noundef nonnull %23)
  %.not16 = icmp eq i32 %36, 0
  %.str.3.sink = select i1 %.not16, ptr @.str.3, ptr @.str.2
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
  ret i32 0
}

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

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

!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 8}
!6 = !{!"_ZTS4node", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass