; LLVM IR from wuzhouhui/leetcode :: 101symmetric_tree (isSymmetric)

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

@maxsz = external hidden global i32, align 4
@left1st = external hidden global ptr, align 8
@p = external hidden global i32, align 4
@right1st = external hidden global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @isSymmetric(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  br i1 %5, label %7, label %6

6:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  br label %50

7:                                                ; preds = %1
  store i32 16, ptr @maxsz, align 4, !tbaa !9
  %8 = load i32, ptr @maxsz, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = mul i64 %9, 4
  %11 = call noalias ptr @malloc(i64 noundef %10) #5
  store ptr %11, ptr @left1st, align 8, !tbaa !5
  store i32 0, ptr @p, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  call void @left_inorder(ptr noundef %12)
  %13 = load i32, ptr @maxsz, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = mul i64 %14, 4
  %16 = call noalias ptr @malloc(i64 noundef %15) #5
  store ptr %16, ptr @right1st, align 8, !tbaa !5
  store i32 0, ptr @p, align 4, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  call void @right_inorder(ptr noundef %17)
  %18 = load ptr, ptr @left1st, align 8, !tbaa !5
  %19 = load ptr, ptr @right1st, align 8, !tbaa !5
  %20 = load i32, ptr @p, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = mul i64 %21, 4
  %23 = call i32 @memcmp(ptr noundef %18, ptr noundef %19, i64 noundef %22) #6
  store i32 %23, ptr @maxsz, align 4, !tbaa !9
  %24 = load i32, ptr @maxsz, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %43, label %26

26:                                               ; preds = %7
  %27 = load ptr, ptr @left1st, align 8, !tbaa !5
  %28 = load i32, ptr @maxsz, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = mul i64 %29, 4
  call void @llvm.memset.p0.i64(ptr align 4 %27, i8 0, i64 %30, i1 false)
  %31 = load ptr, ptr @right1st, align 8, !tbaa !5
  %32 = load i32, ptr @maxsz, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = mul i64 %33, 4
  call void @llvm.memset.p0.i64(ptr align 4 %31, i8 0, i64 %34, i1 false)
  store i32 0, ptr @p, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  call void @left_preorder(ptr noundef %35)
  store i32 0, ptr @p, align 4, !tbaa !9
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  call void @right_preorder(ptr noundef %36)
  %37 = load ptr, ptr @left1st, align 8, !tbaa !5
  %38 = load ptr, ptr @right1st, align 8, !tbaa !5
  %39 = load i32, ptr @p, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = mul i64 %40, 4
  %42 = call i32 @memcmp(ptr noundef %37, ptr noundef %38, i64 noundef %41) #6
  store i32 %42, ptr @maxsz, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %26, %7
  %44 = load ptr, ptr @left1st, align 8, !tbaa !5
  call void @free(ptr noundef %44) #7
  %45 = load ptr, ptr @right1st, align 8, !tbaa !5
  call void @free(ptr noundef %45) #7
  %46 = load i32, ptr @maxsz, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  %48 = xor i1 %47, true
  %49 = zext i1 %48 to i32
  store i32 %49, ptr %2, align 4
  br label %50

50:                                               ; preds = %43, %6
  %51 = load i32, ptr %2, align 4
  ret i32 %51
}

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

; Function Attrs: nounwind uwtable
declare hidden void @left_inorder(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @right_inorder(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @left_preorder(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @right_preorder(ptr noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

attributes #0 = { 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 willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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

@maxsz = external hidden local_unnamed_addr global i32, align 4
@left1st = external hidden local_unnamed_addr global ptr, align 8
@p = external hidden local_unnamed_addr global i32, align 4
@right1st = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @isSymmetric(ptr noundef %0) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %26, label %2

2:                                                ; preds = %1
  store i32 16, ptr @maxsz, align 4, !tbaa !5
  %3 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #4
  store ptr %3, ptr @left1st, align 8, !tbaa !9
  store i32 0, ptr @p, align 4, !tbaa !5
  tail call void @left_inorder(ptr noundef nonnull %0)
  %4 = load i32, ptr @maxsz, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = shl nsw i64 %5, 2
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #4
  store ptr %7, ptr @right1st, align 8, !tbaa !9
  store i32 0, ptr @p, align 4, !tbaa !5
  tail call void @right_inorder(ptr noundef nonnull %0)
  %8 = load ptr, ptr @left1st, align 8, !tbaa !9
  %9 = load ptr, ptr @right1st, align 8, !tbaa !9
  %10 = load i32, ptr @p, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = shl nsw i64 %11, 2
  %13 = tail call i32 @memcmp(ptr noundef %8, ptr noundef %9, i64 noundef %12) #5
  store i32 %13, ptr @maxsz, align 4, !tbaa !5
  %.not7 = icmp eq i32 %13, 0
  br i1 %.not7, label %14, label %21

14:                                               ; preds = %2
  store i32 0, ptr @p, align 4, !tbaa !5
  tail call void @left_preorder(ptr noundef nonnull %0)
  store i32 0, ptr @p, align 4, !tbaa !5
  tail call void @right_preorder(ptr noundef nonnull %0)
  %15 = load ptr, ptr @left1st, align 8, !tbaa !9
  %16 = load ptr, ptr @right1st, align 8, !tbaa !9
  %17 = load i32, ptr @p, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = shl nsw i64 %18, 2
  %20 = tail call i32 @memcmp(ptr noundef %15, ptr noundef %16, i64 noundef %19) #5
  store i32 %20, ptr @maxsz, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %14, %2
  %22 = phi ptr [ %15, %14 ], [ %8, %2 ]
  tail call void @free(ptr noundef %22) #6
  %23 = load ptr, ptr @right1st, align 8, !tbaa !9
  tail call void @free(ptr noundef %23) #6
  %24 = load i32, ptr @maxsz, align 4, !tbaa !5
  %.not8 = icmp eq i32 %24, 0
  %25 = zext i1 %.not8 to i32
  br label %26

26:                                               ; preds = %1, %21
  %.0 = phi i32 [ %25, %21 ], [ 1, %1 ]
  ret i32 %.0
}

; 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: nounwind uwtable
declare hidden void @left_inorder(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @right_inorder(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @memcmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @left_preorder(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @right_preorder(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { 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 = { 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #4 = { nounwind allocsize(0) }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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