; LLVM IR from codemistic/Data-Structures-and-Algorithms :: CPP/Trees/Expression_tree (BST)

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

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

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

; 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
declare dso_local i32 @precedance(i8 noundef signext) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @isAlNum(i8 noundef signext) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @convertToPostFix(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @initCharStack(ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = mul i64 1, %10
  %12 = call noalias ptr @malloc(i64 noundef %11) #5
  store ptr %12, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %13, ptr %8, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %100, %2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %103

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = call i32 @isAlNum(i8 noundef signext %21)
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 %26, ptr %27, align 1, !tbaa !11
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i32 1
  store ptr %29, ptr %7, align 8, !tbaa !5
  br label %100

30:                                               ; preds = %19
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i8, ptr %31, align 1, !tbaa !11
  %33 = sext i8 %32 to i32
  %34 = icmp eq i32 %33, 40
  br i1 %34, label %35, label %38

35:                                               ; preds = %30
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i8, ptr %36, align 1, !tbaa !11
  call void @pushChar(ptr noundef %6, i8 noundef signext %37)
  br label %99

38:                                               ; preds = %30
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp eq i32 %41, 94
  br i1 %42, label %43, label %46

43:                                               ; preds = %38
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load i8, ptr %44, align 1, !tbaa !11
  call void @pushChar(ptr noundef %6, i8 noundef signext %45)
  br label %98

46:                                               ; preds = %38
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 41
  br i1 %50, label %51, label %66

51:                                               ; preds = %46
  br label %52

52:                                               ; preds = %57, %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call signext i8 @peekChar(ptr noundef %53)
  %55 = sext i8 %54 to i32
  %56 = icmp ne i32 %55, 40
  br i1 %56, label %57, label %64

57:                                               ; preds = %52
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call signext i8 @peekChar(ptr noundef %58)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 %59, ptr %60, align 1, !tbaa !11
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %61, i32 1
  store ptr %62, ptr %7, align 8, !tbaa !5
  %63 = call i32 @popChar(ptr noundef %6)
  br label %52, !llvm.loop !12

64:                                               ; preds = %52
  %65 = call i32 @popChar(ptr noundef %6)
  br label %97

66:                                               ; preds = %46
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = call i32 @precedance(i8 noundef signext %68)
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call signext i8 @peekChar(ptr noundef %70)
  %72 = call i32 @precedance(i8 noundef signext %71)
  %73 = icmp sgt i32 %69, %72
  br i1 %73, label %74, label %77

74:                                               ; preds = %66
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = load i8, ptr %75, align 1, !tbaa !11
  call void @pushChar(ptr noundef %6, i8 noundef signext %76)
  br label %96

77:                                               ; preds = %66
  br label %78

78:                                               ; preds = %86, %77
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = load i8, ptr %79, align 1, !tbaa !11
  %81 = call i32 @precedance(i8 noundef signext %80)
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = call signext i8 @peekChar(ptr noundef %82)
  %84 = call i32 @precedance(i8 noundef signext %83)
  %85 = icmp sle i32 %81, %84
  br i1 %85, label %86, label %93

86:                                               ; preds = %78
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = call signext i8 @peekChar(ptr noundef %87)
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 %88, ptr %89, align 1, !tbaa !11
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %90, i32 1
  store ptr %91, ptr %7, align 8, !tbaa !5
  %92 = call i32 @popChar(ptr noundef %6)
  br label %78, !llvm.loop !14

93:                                               ; preds = %78
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = load i8, ptr %94, align 1, !tbaa !11
  call void @pushChar(ptr noundef %6, i8 noundef signext %95)
  br label %96

96:                                               ; preds = %93, %74
  br label %97

97:                                               ; preds = %96, %64
  br label %98

98:                                               ; preds = %97, %43
  br label %99

99:                                               ; preds = %98, %35
  br label %100

100:                                              ; preds = %99, %24
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds i8, ptr %101, i32 1
  store ptr %102, ptr %3, align 8, !tbaa !5
  br label %14, !llvm.loop !15

103:                                              ; preds = %14
  br label %104

104:                                              ; preds = %109, %103
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = call signext i8 @peekChar(ptr noundef %105)
  %107 = sext i8 %106 to i32
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %116

109:                                              ; preds = %104
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = call signext i8 @peekChar(ptr noundef %110)
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 %111, ptr %112, align 1, !tbaa !11
  %113 = load ptr, ptr %7, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i32 1
  store ptr %114, ptr %7, align 8, !tbaa !5
  %115 = call i32 @popChar(ptr noundef %6)
  br label %104, !llvm.loop !16

116:                                              ; preds = %104
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %117, align 1, !tbaa !11
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %118, ptr %7, align 8, !tbaa !5
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret ptr %119
}

declare void @initCharStack(ptr noundef) #3

declare void @pushChar(ptr noundef, i8 noundef signext) #3

declare signext i8 @peekChar(ptr noundef) #3

declare i32 @popChar(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { "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 }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @precedance(i8 noundef signext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @isAlNum(i8 noundef signext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @convertToPostFix(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @initCharStack(ptr noundef nonnull %3) #4
  %4 = sext i32 %1 to i64
  %5 = call noalias ptr @malloc(i64 noundef %4) #5
  %6 = load i8, ptr %0, align 1, !tbaa !5
  %.not40 = icmp eq i8 %6, 0
  br i1 %.not40, label %.preheader, label %.lr.ph44

.preheader:                                       ; preds = %48, %2
  %.025.lcssa = phi ptr [ %5, %2 ], [ %.3, %48 ]
  %7 = load ptr, ptr %3, align 8, !tbaa !8
  %8 = call signext i8 @peekChar(ptr noundef %7) #4
  %.not2746 = icmp eq i8 %8, 0
  br i1 %.not2746, label %._crit_edge49, label %.lr.ph48

.lr.ph44:                                         ; preds = %2, %48
  %9 = phi i8 [ %50, %48 ], [ %6, %2 ]
  %.042 = phi ptr [ %49, %48 ], [ %0, %2 ]
  %.02541 = phi ptr [ %.3, %48 ], [ %5, %2 ]
  %10 = call i32 @isAlNum(i8 noundef signext %9)
  %.not28 = icmp eq i32 %10, 0
  %11 = load i8, ptr %.042, align 1, !tbaa !5
  br i1 %.not28, label %14, label %12

12:                                               ; preds = %.lr.ph44
  store i8 %11, ptr %.02541, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.02541, i64 1
  br label %48

14:                                               ; preds = %.lr.ph44
  switch i8 %11, label %26 [
    i8 40, label %17
    i8 94, label %18
    i8 41, label %.preheader32
  ]

.preheader32:                                     ; preds = %14
  %15 = load ptr, ptr %3, align 8, !tbaa !8
  %16 = call signext i8 @peekChar(ptr noundef %15) #4
  %.not3033 = icmp eq i8 %16, 40
  br i1 %.not3033, label %._crit_edge, label %.lr.ph

17:                                               ; preds = %14
  call void @pushChar(ptr noundef nonnull %3, i8 noundef signext 40) #4
  br label %48

18:                                               ; preds = %14
  call void @pushChar(ptr noundef nonnull %3, i8 noundef signext 94) #4
  br label %48

.lr.ph:                                           ; preds = %.preheader32, %.lr.ph
  %.134 = phi ptr [ %21, %.lr.ph ], [ %.02541, %.preheader32 ]
  %19 = load ptr, ptr %3, align 8, !tbaa !8
  %20 = call signext i8 @peekChar(ptr noundef %19) #4
  store i8 %20, ptr %.134, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.134, i64 1
  %22 = call i32 @popChar(ptr noundef nonnull %3) #4
  %23 = load ptr, ptr %3, align 8, !tbaa !8
  %24 = call signext i8 @peekChar(ptr noundef %23) #4
  %.not30 = icmp eq i8 %24, 40
  br i1 %.not30, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %.preheader32
  %.1.lcssa = phi ptr [ %.02541, %.preheader32 ], [ %21, %.lr.ph ]
  %25 = call i32 @popChar(ptr noundef nonnull %3) #4
  br label %48

26:                                               ; preds = %14
  %27 = call i32 @precedance(i8 noundef signext %11)
  %28 = load ptr, ptr %3, align 8, !tbaa !8
  %29 = call signext i8 @peekChar(ptr noundef %28) #4
  %30 = call i32 @precedance(i8 noundef signext %29)
  %31 = icmp sgt i32 %27, %30
  %32 = load i8, ptr %.042, align 1, !tbaa !5
  br i1 %31, label %37, label %.preheader31

.preheader31:                                     ; preds = %26
  %33 = call i32 @precedance(i8 noundef signext %32)
  %34 = load ptr, ptr %3, align 8, !tbaa !8
  %35 = call signext i8 @peekChar(ptr noundef %34) #4
  %36 = call i32 @precedance(i8 noundef signext %35)
  %.not2935 = icmp sgt i32 %33, %36
  br i1 %.not2935, label %._crit_edge38, label %.lr.ph37

37:                                               ; preds = %26
  call void @pushChar(ptr noundef nonnull %3, i8 noundef signext %32) #4
  br label %48

.lr.ph37:                                         ; preds = %.preheader31, %.lr.ph37
  %.236 = phi ptr [ %40, %.lr.ph37 ], [ %.02541, %.preheader31 ]
  %38 = load ptr, ptr %3, align 8, !tbaa !8
  %39 = call signext i8 @peekChar(ptr noundef %38) #4
  store i8 %39, ptr %.236, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %.236, i64 1
  %41 = call i32 @popChar(ptr noundef nonnull %3) #4
  %42 = load i8, ptr %.042, align 1, !tbaa !5
  %43 = call i32 @precedance(i8 noundef signext %42)
  %44 = load ptr, ptr %3, align 8, !tbaa !8
  %45 = call signext i8 @peekChar(ptr noundef %44) #4
  %46 = call i32 @precedance(i8 noundef signext %45)
  %.not29 = icmp sgt i32 %43, %46
  br i1 %.not29, label %._crit_edge38, label %.lr.ph37, !llvm.loop !12

._crit_edge38:                                    ; preds = %.lr.ph37, %.preheader31
  %.2.lcssa = phi ptr [ %.02541, %.preheader31 ], [ %40, %.lr.ph37 ]
  %47 = load i8, ptr %.042, align 1, !tbaa !5
  call void @pushChar(ptr noundef nonnull %3, i8 noundef signext %47) #4
  br label %48

48:                                               ; preds = %17, %._crit_edge, %._crit_edge38, %37, %18, %12
  %.3 = phi ptr [ %13, %12 ], [ %.02541, %17 ], [ %.02541, %18 ], [ %.1.lcssa, %._crit_edge ], [ %.02541, %37 ], [ %.2.lcssa, %._crit_edge38 ]
  %49 = getelementptr inbounds i8, ptr %.042, i64 1
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %.not = icmp eq i8 %50, 0
  br i1 %.not, label %.preheader, label %.lr.ph44, !llvm.loop !13

.lr.ph48:                                         ; preds = %.preheader, %.lr.ph48
  %.447 = phi ptr [ %53, %.lr.ph48 ], [ %.025.lcssa, %.preheader ]
  %51 = load ptr, ptr %3, align 8, !tbaa !8
  %52 = call signext i8 @peekChar(ptr noundef %51) #4
  store i8 %52, ptr %.447, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %.447, i64 1
  %54 = call i32 @popChar(ptr noundef nonnull %3) #4
  %55 = load ptr, ptr %3, align 8, !tbaa !8
  %56 = call signext i8 @peekChar(ptr noundef %55) #4
  %.not27 = icmp eq i8 %56, 0
  br i1 %.not27, label %._crit_edge49, label %.lr.ph48, !llvm.loop !14

._crit_edge49:                                    ; preds = %.lr.ph48, %.preheader
  %.4.lcssa = phi ptr [ %.025.lcssa, %.preheader ], [ %53, %.lr.ph48 ]
  store i8 0, ptr %.4.lcssa, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret ptr %5
}

declare void @initCharStack(ptr noundef) local_unnamed_addr #3

declare void @pushChar(ptr noundef, i8 noundef signext) local_unnamed_addr #3

declare signext i8 @peekChar(ptr noundef) local_unnamed_addr #3

declare i32 @popChar(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 }
attributes #5 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}


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