; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Week 1/rpn/rpn.ll (Z7cmpPreccc)

; 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 nounwind uwtable
define dso_local noundef i32 @_Z7cmpPreccc(i8 noundef signext %0, i8 noundef signext %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i8 %0, ptr %3, align 1, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %7 = load i8, ptr %3, align 1, !tbaa !5
  %8 = sext i8 %7 to i32
  switch i32 %8, label %14 [
    i32 43, label %9
    i32 45, label %10
    i32 47, label %11
    i32 42, label %12
    i32 94, label %13
  ]

9:                                                ; preds = %2
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %14

10:                                               ; preds = %2
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %14

11:                                               ; preds = %2
  store i32 5, ptr %5, align 4, !tbaa !8
  br label %14

12:                                               ; preds = %2
  store i32 5, ptr %5, align 4, !tbaa !8
  br label %14

13:                                               ; preds = %2
  store i32 10, ptr %5, align 4, !tbaa !8
  br label %14

14:                                               ; preds = %13, %12, %11, %10, %9, %2
  %15 = load i8, ptr %4, align 1, !tbaa !5
  %16 = sext i8 %15 to i32
  switch i32 %16, label %22 [
    i32 43, label %17
    i32 45, label %18
    i32 47, label %19
    i32 42, label %20
    i32 94, label %21
  ]

17:                                               ; preds = %14
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %22

18:                                               ; preds = %14
  store i32 0, ptr %6, align 4, !tbaa !8
  br label %22

19:                                               ; preds = %14
  store i32 5, ptr %6, align 4, !tbaa !8
  br label %22

20:                                               ; preds = %14
  store i32 5, ptr %6, align 4, !tbaa !8
  br label %22

21:                                               ; preds = %14
  store i32 10, ptr %6, align 4, !tbaa !8
  br label %22

22:                                               ; preds = %21, %20, %19, %18, %17, %14
  %23 = load i32, ptr %5, align 4, !tbaa !8
  %24 = load i32, ptr %6, align 4, !tbaa !8
  %25 = sub nsw i32 %23, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %25
}

; 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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @_Z7cmpPreccc(i8 noundef signext %0, i8 noundef signext %1) local_unnamed_addr #0 {
  switch i8 %0, label %6 [
    i8 94, label %5
    i8 42, label %4
    i8 47, label %3
  ]

3:                                                ; preds = %2
  br label %6

4:                                                ; preds = %2
  br label %6

5:                                                ; preds = %2
  br label %6

6:                                                ; preds = %5, %4, %3, %2
  %.04 = phi i32 [ 10, %5 ], [ 5, %4 ], [ 5, %3 ], [ 0, %2 ]
  switch i8 %1, label %10 [
    i8 94, label %9
    i8 42, label %8
    i8 47, label %7
  ]

7:                                                ; preds = %6
  br label %10

8:                                                ; preds = %6
  br label %10

9:                                                ; preds = %6
  br label %10

10:                                               ; preds = %9, %8, %7, %6
  %.0.neg = phi i32 [ -10, %9 ], [ -5, %8 ], [ -5, %7 ], [ 0, %6 ]
  %11 = add nsw i32 %.0.neg, %.04
  ret i32 %11
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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" }

!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)"}


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