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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z9operationddc(double noundef %0, double noundef %1, i8 noundef signext %2) #1 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i8, align 1
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !5
  store i8 %2, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  %9 = load i8, ptr %6, align 1, !tbaa !9
  %10 = sext i8 %9 to i32
  %11 = icmp eq i32 %10, 43
  br i1 %11, label %12, label %16

12:                                               ; preds = %3
  %13 = load double, ptr %4, align 8, !tbaa !5
  %14 = load double, ptr %5, align 8, !tbaa !5
  %15 = fadd double %13, %14
  store double %15, ptr %7, align 8, !tbaa !5
  br label %63

16:                                               ; preds = %3
  %17 = load i8, ptr %6, align 1, !tbaa !9
  %18 = sext i8 %17 to i32
  %19 = icmp eq i32 %18, 45
  br i1 %19, label %20, label %24

20:                                               ; preds = %16
  %21 = load double, ptr %4, align 8, !tbaa !5
  %22 = load double, ptr %5, align 8, !tbaa !5
  %23 = fsub double %21, %22
  store double %23, ptr %7, align 8, !tbaa !5
  br label %62

24:                                               ; preds = %16
  %25 = load i8, ptr %6, align 1, !tbaa !9
  %26 = sext i8 %25 to i32
  %27 = icmp eq i32 %26, 42
  br i1 %27, label %28, label %32

28:                                               ; preds = %24
  %29 = load double, ptr %4, align 8, !tbaa !5
  %30 = load double, ptr %5, align 8, !tbaa !5
  %31 = fmul double %29, %30
  store double %31, ptr %7, align 8, !tbaa !5
  br label %61

32:                                               ; preds = %24
  %33 = load i8, ptr %6, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 47
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = load double, ptr %4, align 8, !tbaa !5
  %38 = load double, ptr %5, align 8, !tbaa !5
  %39 = fdiv double %37, %38
  store double %39, ptr %7, align 8, !tbaa !5
  br label %60

40:                                               ; preds = %32
  %41 = load i8, ptr %6, align 1, !tbaa !9
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 94
  br i1 %43, label %44, label %59

44:                                               ; preds = %40
  store double 1.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !10
  br label %45

45:                                               ; preds = %55, %44
  %46 = load i32, ptr %8, align 4, !tbaa !10
  %47 = sitofp i32 %46 to double
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = fcmp olt double %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %58

51:                                               ; preds = %45
  %52 = load double, ptr %7, align 8, !tbaa !5
  %53 = load double, ptr %4, align 8, !tbaa !5
  %54 = fmul double %52, %53
  store double %54, ptr %7, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %51
  %56 = load i32, ptr %8, align 4, !tbaa !10
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !10
  br label %45, !llvm.loop !12

58:                                               ; preds = %50
  br label %59

59:                                               ; preds = %58, %40
  br label %60

60:                                               ; preds = %59, %36
  br label %61

61:                                               ; preds = %60, %28
  br label %62

62:                                               ; preds = %61, %20
  br label %63

63:                                               ; preds = %62, %12
  %64 = load double, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret double %64
}

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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef double @_Z9operationddc(double noundef %0, double noundef %1, i8 noundef signext %2) local_unnamed_addr #0 {
  switch i8 %2, label %.loopexit [
    i8 43, label %5
    i8 45, label %7
    i8 42, label %9
    i8 47, label %11
    i8 94, label %.preheader
  ]

.preheader:                                       ; preds = %3
  %4 = fcmp ogt double %1, 0.000000e+00
  br i1 %4, label %.lr.ph, label %.loopexit

5:                                                ; preds = %3
  %6 = fadd double %0, %1
  br label %.loopexit

7:                                                ; preds = %3
  %8 = fsub double %0, %1
  br label %.loopexit

9:                                                ; preds = %3
  %10 = fmul double %0, %1
  br label %.loopexit

11:                                               ; preds = %3
  %12 = fdiv double %0, %1
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.021 = phi i32 [ %14, %.lr.ph ], [ 0, %.preheader ]
  %.01820 = phi double [ %13, %.lr.ph ], [ 1.000000e+00, %.preheader ]
  %13 = fmul double %.01820, %0
  %14 = add nuw nsw i32 %.021, 1
  %15 = uitofp nneg i32 %14 to double
  %16 = fcmp olt double %15, %1
  br i1 %16, label %.lr.ph, label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %3, %7, %11, %9, %5
  %.1 = phi double [ %6, %5 ], [ %8, %7 ], [ %10, %9 ], [ %12, %11 ], [ 0.000000e+00, %3 ], [ 1.000000e+00, %.preheader ], [ %13, %.lr.ph ]
  ret double %.1
}

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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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