; LLVM IR from Ayon-SSP/The-SDE-Prep :: 1]_Data Structures/3]_Stack (Postfixvevaluation)

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

@__const.main.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1

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

; 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 ptr @push(ptr noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @pop(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca [11 x i8], align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store ptr null, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 11, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 @__const.main.str, i64 11, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %79, %0
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 0
  %11 = call i64 @strlen(ptr noundef %10) #6
  %12 = sub i64 %11, 1
  %13 = icmp ule i64 %9, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %82

15:                                               ; preds = %7
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = icmp sle i32 %20, 57
  br i1 %21, label %22, label %38

22:                                               ; preds = %15
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = sext i8 %26 to i32
  %28 = icmp sge i32 %27, 48
  br i1 %28, label %29, label %38

29:                                               ; preds = %22
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  %36 = sub nsw i32 %35, 48
  %37 = call ptr @push(ptr noundef %30, i32 noundef %36)
  store ptr %37, ptr %2, align 8, !tbaa !5
  br label %78

38:                                               ; preds = %22, %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = call i32 @Top(ptr noundef %39)
  store i32 %40, ptr %5, align 4, !tbaa !9
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = call ptr @pop(ptr noundef %41)
  store ptr %42, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = call i32 @Top(ptr noundef %43)
  store i32 %44, ptr %6, align 4, !tbaa !9
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = call ptr @pop(ptr noundef %45)
  store ptr %46, ptr %2, align 8, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [11 x i8], ptr %3, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = sext i8 %50 to i32
  switch i32 %51, label %76 [
    i32 43, label %52
    i32 45, label %58
    i32 42, label %64
    i32 47, label %70
  ]

52:                                               ; preds = %38
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = add nsw i32 %54, %55
  %57 = call ptr @push(ptr noundef %53, i32 noundef %56)
  store ptr %57, ptr %2, align 8, !tbaa !5
  br label %77

58:                                               ; preds = %38
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = sub nsw i32 %60, %61
  %63 = call ptr @push(ptr noundef %59, i32 noundef %62)
  store ptr %63, ptr %2, align 8, !tbaa !5
  br label %77

64:                                               ; preds = %38
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = mul nsw i32 %66, %67
  %69 = call ptr @push(ptr noundef %65, i32 noundef %68)
  store ptr %69, ptr %2, align 8, !tbaa !5
  br label %77

70:                                               ; preds = %38
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = sdiv i32 %72, %73
  %75 = call ptr @push(ptr noundef %71, i32 noundef %74)
  store ptr %75, ptr %2, align 8, !tbaa !5
  br label %77

76:                                               ; preds = %38
  br label %77

77:                                               ; preds = %76, %70, %64, %58, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %78

78:                                               ; preds = %77, %29
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %4, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !12

82:                                               ; preds = %14
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = call i32 @Top(ptr noundef %83)
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %84)
  call void @llvm.lifetime.end.p0(i64 11, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { 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/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"}


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

@__const.main.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @pop(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @Top(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @__const.main.str) #3
  br label %5

2:                                                ; preds = %29
  %3 = tail call i32 @Top(ptr noundef %.2)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %3)
  ret i32 0

5:                                                ; preds = %0, %29
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %29 ]
  %.027 = phi ptr [ null, %0 ], [ %.2, %29 ]
  %6 = getelementptr inbounds [11 x i8], ptr @__const.main.str, i64 0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = add i8 %7, -48
  %or.cond = icmp ult i8 %8, 10
  br i1 %or.cond, label %9, label %12

9:                                                ; preds = %5
  %10 = zext nneg i8 %8 to i32
  %11 = tail call ptr @push(ptr noundef %.027, i32 noundef %10)
  br label %29

12:                                               ; preds = %5
  %13 = tail call i32 @Top(ptr noundef %.027)
  %14 = tail call ptr @pop(ptr noundef %.027)
  %15 = tail call i32 @Top(ptr noundef %14)
  %16 = tail call ptr @pop(ptr noundef %14)
  switch i8 %7, label %29 [
    i8 43, label %17
    i8 45, label %20
    i8 42, label %23
    i8 47, label %26
  ]

17:                                               ; preds = %12
  %18 = add nsw i32 %15, %13
  %19 = tail call ptr @push(ptr noundef %16, i32 noundef %18)
  br label %29

20:                                               ; preds = %12
  %21 = sub nsw i32 %15, %13
  %22 = tail call ptr @push(ptr noundef %16, i32 noundef %21)
  br label %29

23:                                               ; preds = %12
  %24 = mul nsw i32 %15, %13
  %25 = tail call ptr @push(ptr noundef %16, i32 noundef %24)
  br label %29

26:                                               ; preds = %12
  %27 = sdiv i32 %15, %13
  %28 = tail call ptr @push(ptr noundef %16, i32 noundef %27)
  br label %29

29:                                               ; preds = %17, %20, %23, %26, %12, %9
  %.2 = phi ptr [ %11, %9 ], [ %16, %12 ], [ %28, %26 ], [ %25, %23 ], [ %22, %20 ], [ %19, %17 ]
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %1
  br i1 %exitcond, label %2, label %5, !llvm.loop !8
}

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass