; LLVM IR from MinhasKamal/AlgorithmImplementations :: arithmeticExpressions/infixEvaluation (InfixEvaluation)

; 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: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z14stringToDoubleNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double 0.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  store i8 0, ptr %5, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %10

10:                                               ; preds = %53, %1
  %11 = load i32, ptr %7, align 4, !tbaa !13
  %12 = sext i32 %11 to i64
  %13 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %12)
  %14 = load i8, ptr %13, align 1, !tbaa !15
  %15 = sext i8 %14 to i64
  %16 = icmp ne i64 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %56

18:                                               ; preds = %10
  %19 = load i32, ptr %7, align 4, !tbaa !13
  %20 = sext i32 %19 to i64
  %21 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %20)
  %22 = load i8, ptr %21, align 1, !tbaa !15
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 46
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  store i8 1, ptr %5, align 1, !tbaa !11
  br label %52

26:                                               ; preds = %18
  %27 = load i8, ptr %5, align 1, !tbaa !11, !range !16, !noundef !17
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %41

29:                                               ; preds = %26
  %30 = load double, ptr %4, align 8, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !13
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %32)
  %34 = load i8, ptr %33, align 1, !tbaa !15
  %35 = sext i8 %34 to i32
  %36 = sub nsw i32 %35, 48
  %37 = sitofp i32 %36 to double
  %38 = call double @llvm.fmuladd.f64(double %30, double 1.000000e+01, double %37)
  store double %38, ptr %4, align 8, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !13
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !13
  br label %51

41:                                               ; preds = %26
  %42 = load double, ptr %3, align 8, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %44)
  %46 = load i8, ptr %45, align 1, !tbaa !15
  %47 = sext i8 %46 to i32
  %48 = sub nsw i32 %47, 48
  %49 = sitofp i32 %48 to double
  %50 = call double @llvm.fmuladd.f64(double %42, double 1.000000e+01, double %49)
  store double %50, ptr %3, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %41, %29
  br label %52

52:                                               ; preds = %51, %25
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %7, align 4, !tbaa !13
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !13
  br label %10, !llvm.loop !18

56:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %57

57:                                               ; preds = %65, %56
  %58 = load i32, ptr %9, align 4, !tbaa !13
  %59 = load i32, ptr %6, align 4, !tbaa !13
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %68

62:                                               ; preds = %57
  %63 = load i32, ptr %8, align 4, !tbaa !13
  %64 = mul nsw i32 %63, 10
  store i32 %64, ptr %8, align 4, !tbaa !13
  br label %65

65:                                               ; preds = %62
  %66 = load i32, ptr %9, align 4, !tbaa !13
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %9, align 4, !tbaa !13
  br label %57, !llvm.loop !20

68:                                               ; preds = %61
  %69 = load double, ptr %3, align 8, !tbaa !9
  %70 = load double, ptr %4, align 8, !tbaa !9
  %71 = load i32, ptr %8, align 4, !tbaa !13
  %72 = sitofp i32 %71 to double
  %73 = fdiv double %70, %72
  %74 = fadd double %69, %73
  store double %74, ptr %3, align 8, !tbaa !9
  %75 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %75
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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 nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z14stringToDoubleNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 0)
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %.not25 = icmp eq i8 %3, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %23
  %4 = icmp sgt i32 %.1, 0
  br i1 %4, label %.lr.ph35.preheader, label %._crit_edge

.lr.ph35.preheader:                               ; preds = %.preheader
  %min.iters.check = icmp ult i32 %.1, 8
  br i1 %min.iters.check, label %.lr.ph35.preheader43, label %vector.ph

.lr.ph35.preheader43:                             ; preds = %middle.block, %.lr.ph35.preheader
  %.034.ph = phi i32 [ 0, %.lr.ph35.preheader ], [ %n.vec, %middle.block ]
  %.01633.ph = phi i32 [ 1, %.lr.ph35.preheader ], [ %8, %middle.block ]
  br label %.lr.ph35

vector.ph:                                        ; preds = %.lr.ph35.preheader
  %n.vec = and i32 %.1, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %vector.ph ], [ %5, %vector.body ]
  %vec.phi42 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %vector.ph ], [ %6, %vector.body ]
  %5 = mul <4 x i32> %vec.phi, <i32 10, i32 10, i32 10, i32 10>
  %6 = mul <4 x i32> %vec.phi42, <i32 10, i32 10, i32 10, i32 10>
  %index.next = add nuw i32 %index, 8
  %7 = icmp eq i32 %index.next, %n.vec
  br i1 %7, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %bin.rdx = mul <4 x i32> %6, %5
  %8 = tail call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i32 %.1, %n.vec
  br i1 %cmp.n, label %._crit_edge.loopexit, label %.lr.ph35.preheader43

.lr.ph:                                           ; preds = %1, %23
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ 0, %1 ]
  %.01829 = phi i32 [ %.1, %23 ], [ 0, %1 ]
  %.01928 = phi i1 [ %.120, %23 ], [ false, %1 ]
  %.02127 = phi double [ %.122, %23 ], [ 0.000000e+00, %1 ]
  %.02326 = phi double [ %.124, %23 ], [ 0.000000e+00, %1 ]
  %9 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv)
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp eq i8 %10, 46
  br i1 %11, label %23, label %12

12:                                               ; preds = %.lr.ph
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv)
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = sext i8 %14 to i32
  %16 = add nsw i32 %15, -48
  %17 = sitofp i32 %16 to double
  br i1 %.01928, label %18, label %21

18:                                               ; preds = %12
  %19 = tail call double @llvm.fmuladd.f64(double %.02127, double 1.000000e+01, double %17)
  %20 = add nsw i32 %.01829, 1
  br label %23

21:                                               ; preds = %12
  %22 = tail call double @llvm.fmuladd.f64(double %.02326, double 1.000000e+01, double %17)
  br label %23

23:                                               ; preds = %.lr.ph, %21, %18
  %.124 = phi double [ %.02326, %18 ], [ %22, %21 ], [ %.02326, %.lr.ph ]
  %.122 = phi double [ %19, %18 ], [ %.02127, %21 ], [ %.02127, %.lr.ph ]
  %.120 = phi i1 [ true, %18 ], [ false, %21 ], [ true, %.lr.ph ]
  %.1 = phi i32 [ %20, %18 ], [ %.01829, %21 ], [ %.01829, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %indvars.iv.next)
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %.not = icmp eq i8 %25, 0
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %.lr.ph35, %middle.block
  %.lcssa = phi i32 [ %8, %middle.block ], [ %29, %.lr.ph35 ]
  %26 = uitofp nneg i32 %.lcssa to double
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %._crit_edge.loopexit, %.preheader
  %.021.lcssa41 = phi double [ %.122, %.preheader ], [ %.122, %._crit_edge.loopexit ], [ 0.000000e+00, %1 ]
  %.023.lcssa40 = phi double [ %.124, %.preheader ], [ %.124, %._crit_edge.loopexit ], [ 0.000000e+00, %1 ]
  %.016.lcssa = phi double [ 1.000000e+00, %.preheader ], [ %26, %._crit_edge.loopexit ], [ 1.000000e+00, %1 ]
  %27 = fdiv double %.021.lcssa41, %.016.lcssa
  %28 = fadd double %.023.lcssa40, %27
  ret double %28

.lr.ph35:                                         ; preds = %.lr.ph35.preheader43, %.lr.ph35
  %.034 = phi i32 [ %30, %.lr.ph35 ], [ %.034.ph, %.lr.ph35.preheader43 ]
  %.01633 = phi i32 [ %29, %.lr.ph35 ], [ %.01633.ph, %.lr.ph35.preheader43 ]
  %29 = mul nuw nsw i32 %.01633, 10
  %30 = add nuw nsw i32 %.034, 1
  %exitcond.not = icmp eq i32 %30, %.1
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph35, !llvm.loop !13
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.mul.v4i32(<4 x i32>) #2

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9}
!13 = distinct !{!13, !9, !11, !10}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass