; LLVM IR from Py-Contributors/AlgorithmsAndDataStructure :: C++/Data Structure/Stacks/evalPostfixStack.ll (Z15evaluatePostfixPc)

; 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: mustprogress uwtable
declare dso_local noundef ptr @_Z11createStackj(i32 noundef) #0

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4pushP5Stacki(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z15evaluatePostfixPc(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i64 @strlen(ptr noundef %10) #5
  %12 = trunc i64 %11 to i32
  %13 = call noundef ptr @_Z11createStackj(i32 noundef %12)
  store ptr %13, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %1
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %105, %17
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %25, label %108

25:                                               ; preds = %18
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 32
  br i1 %32, label %33, label %34

33:                                               ; preds = %25
  br label %105

34:                                               ; preds = %25
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %35, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = call i32 @isdigit(i32 noundef %40) #5
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %71

43:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %53, %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = sext i8 %49 to i32
  %51 = call i32 @isdigit(i32 noundef %50) #5
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %66

53:                                               ; preds = %44
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = mul nsw i32 %54, 10
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i32
  %62 = sub nsw i32 %61, 48
  %63 = add nsw i32 %55, %62
  store i32 %63, ptr %7, align 4, !tbaa !9
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !9
  br label %44, !llvm.loop !12

66:                                               ; preds = %44
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr %5, align 4, !tbaa !9
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !9
  call void @_Z4pushP5Stacki(ptr noundef %69, i32 noundef %70)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %103

71:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = call noundef i32 @_Z3popP5Stack(ptr noundef %72)
  store i32 %73, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call noundef i32 @_Z3popP5Stack(ptr noundef %74)
  store i32 %75, ptr %9, align 4, !tbaa !9
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %76, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !11
  %81 = sext i8 %80 to i32
  switch i32 %81, label %102 [
    i32 43, label %82
    i32 45, label %87
    i32 42, label %92
    i32 47, label %97
  ]

82:                                               ; preds = %71
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = load i32, ptr %9, align 4, !tbaa !9
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = add nsw i32 %84, %85
  call void @_Z4pushP5Stacki(ptr noundef %83, i32 noundef %86)
  br label %102

87:                                               ; preds = %71
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load i32, ptr %9, align 4, !tbaa !9
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = sub nsw i32 %89, %90
  call void @_Z4pushP5Stacki(ptr noundef %88, i32 noundef %91)
  br label %102

92:                                               ; preds = %71
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = load i32, ptr %8, align 4, !tbaa !9
  %96 = mul nsw i32 %94, %95
  call void @_Z4pushP5Stacki(ptr noundef %93, i32 noundef %96)
  br label %102

97:                                               ; preds = %71
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = sdiv i32 %99, %100
  call void @_Z4pushP5Stacki(ptr noundef %98, i32 noundef %101)
  br label %102

102:                                              ; preds = %97, %92, %87, %82, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %103

103:                                              ; preds = %102, %66
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104, %33
  %106 = load i32, ptr %5, align 4, !tbaa !9
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %5, align 4, !tbaa !9
  br label %18, !llvm.loop !14

108:                                              ; preds = %18
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = call noundef i32 @_Z3popP5Stack(ptr noundef %109)
  store i32 %110, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %111

111:                                              ; preds = %108, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %112 = load i32, ptr %2, align 4
  ret i32 %112
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isdigit(i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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, !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}


; 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 uwtable
declare dso_local noundef ptr @_Z11createStackj(i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z15evaluatePostfixPc(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #3
  %3 = trunc i64 %2 to i32
  %4 = tail call noundef ptr @_Z11createStackj(i32 noundef %3)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %33, label %.preheader43

.preheader43:                                     ; preds = %1, %29
  %.035 = phi i32 [ %30, %29 ], [ 0, %1 ]
  %5 = sext i32 %.035 to i64
  %6 = getelementptr inbounds i8, ptr %0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !5
  switch i8 %7, label %8 [
    i8 0, label %31
    i8 32, label %29
  ]

8:                                                ; preds = %.preheader43
  %9 = sext i8 %7 to i32
  %isdigittmp = add nsw i32 %9, -48
  %isdigit = icmp ult i32 %isdigittmp, 10
  br i1 %isdigit, label %.lr.ph, label %17

.lr.ph:                                           ; preds = %8, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %5, %8 ]
  %isdigittmp4148 = phi i32 [ %isdigittmp41, %.lr.ph ], [ %isdigittmp, %8 ]
  %.03646 = phi i32 [ %11, %.lr.ph ], [ 0, %8 ]
  %10 = mul nsw i32 %.03646, 10
  %11 = add nsw i32 %isdigittmp4148, %10
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %12 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = sext i8 %13 to i32
  %isdigittmp41 = add nsw i32 %14, -48
  %isdigit42 = icmp ult i32 %isdigittmp41, 10
  br i1 %isdigit42, label %.lr.ph, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph
  %15 = trunc nsw i64 %indvars.iv.next to i32
  %16 = add nsw i32 %15, -1
  br label %.sink.split

17:                                               ; preds = %8
  %18 = tail call noundef i32 @_Z3popP5Stack(ptr noundef nonnull %4)
  %19 = tail call noundef i32 @_Z3popP5Stack(ptr noundef nonnull %4)
  %20 = load i8, ptr %6, align 1, !tbaa !5
  switch i8 %20, label %29 [
    i8 43, label %21
    i8 45, label %23
    i8 42, label %25
    i8 47, label %27
  ]

21:                                               ; preds = %17
  %22 = add nsw i32 %19, %18
  br label %.sink.split

23:                                               ; preds = %17
  %24 = sub nsw i32 %19, %18
  br label %.sink.split

25:                                               ; preds = %17
  %26 = mul nsw i32 %19, %18
  br label %.sink.split

27:                                               ; preds = %17
  %28 = sdiv i32 %19, %18
  br label %.sink.split

.sink.split:                                      ; preds = %._crit_edge, %27, %25, %23, %21
  %.sink = phi i32 [ %22, %21 ], [ %24, %23 ], [ %26, %25 ], [ %28, %27 ], [ %11, %._crit_edge ]
  %.2.ph = phi i32 [ %.035, %21 ], [ %.035, %23 ], [ %.035, %25 ], [ %.035, %27 ], [ %16, %._crit_edge ]
  tail call void @_Z4pushP5Stacki(ptr noundef nonnull %4, i32 noundef %.sink)
  br label %29

29:                                               ; preds = %.sink.split, %17, %.preheader43
  %.2 = phi i32 [ %.035, %.preheader43 ], [ %.035, %17 ], [ %.2.ph, %.sink.split ]
  %30 = add nsw i32 %.2, 1
  br label %.preheader43, !llvm.loop !10

31:                                               ; preds = %.preheader43
  %32 = tail call noundef i32 @_Z3popP5Stack(ptr noundef nonnull %4)
  br label %33

33:                                               ; preds = %1, %31
  %.0 = phi i32 [ %32, %31 ], [ -1, %1 ]
  ret i32 %.0
}

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

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 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 = { nounwind willreturn memory(read) }

!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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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