; LLVM IR from AllAlgorithms/c :: algorithms/math (e_square_x_program)

; 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: nounwind uwtable
define dso_local float @exponential(i32 noundef %0, float noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store float 1.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = sub nsw i32 %7, 1
  store i32 %8, ptr %6, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %21, %2
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %24

13:                                               ; preds = %9
  %14 = load float, ptr %4, align 4, !tbaa !9
  %15 = load float, ptr %5, align 4, !tbaa !9
  %16 = fmul float %14, %15
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = sitofp i32 %17 to float
  %19 = fdiv float %16, %18
  %20 = fadd float 1.000000e+00, %19
  store float %20, ptr %5, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %13
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %6, align 4, !tbaa !5
  br label %9, !llvm.loop !11

24:                                               ; preds = %12
  %25 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret float %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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local float @exponential(i32 noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %4 = add nuw i32 %0, 3
  %5 = add nsw i32 %0, -2
  %xtraiter = and i32 %4, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.0.in8.prol = phi i32 [ %.0.prol, %.lr.ph.prol ], [ %0, %.lr.ph.preheader ]
  %.067.prol = phi float [ %9, %.lr.ph.prol ], [ 1.000000e+00, %.lr.ph.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %.0.prol = add nsw i32 %.0.in8.prol, -1
  %6 = fmul float %.067.prol, %1
  %7 = uitofp nneg i32 %.0.prol to float
  %8 = fdiv float %6, %7
  %9 = fadd float %8, 1.000000e+00
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !5

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.0.in8.unr = phi i32 [ %0, %.lr.ph.preheader ], [ %.0.prol, %.lr.ph.prol ]
  %.067.unr = phi float [ 1.000000e+00, %.lr.ph.preheader ], [ %9, %.lr.ph.prol ]
  %.lcssa.unr = phi float [ poison, %.lr.ph.preheader ], [ %9, %.lr.ph.prol ]
  %10 = icmp ult i32 %5, 3
  br i1 %10, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %2
  %.06.lcssa = phi float [ 1.000000e+00, %2 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %26, %.lr.ph ]
  ret float %.06.lcssa

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.0.in8 = phi i32 [ %.0.3, %.lr.ph ], [ %.0.in8.unr, %.lr.ph.prol.loopexit ]
  %.067 = phi float [ %26, %.lr.ph ], [ %.067.unr, %.lr.ph.prol.loopexit ]
  %.0 = add nsw i32 %.0.in8, -1
  %11 = fmul float %.067, %1
  %12 = uitofp nneg i32 %.0 to float
  %13 = fdiv float %11, %12
  %14 = fadd float %13, 1.000000e+00
  %.0.1 = add nsw i32 %.0.in8, -2
  %15 = fmul float %14, %1
  %16 = uitofp nneg i32 %.0.1 to float
  %17 = fdiv float %15, %16
  %18 = fadd float %17, 1.000000e+00
  %.0.2 = add nsw i32 %.0.in8, -3
  %19 = fmul float %18, %1
  %20 = uitofp nneg i32 %.0.2 to float
  %21 = fdiv float %19, %20
  %22 = fadd float %21, 1.000000e+00
  %.0.3 = add nsw i32 %.0.in8, -4
  %23 = fmul float %22, %1
  %24 = uitofp nneg i32 %.0.3 to float
  %25 = fdiv float %23, %24
  %26 = fadd float %25, 1.000000e+00
  %27 = icmp ugt i32 %.0.2, 2
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !7
}

attributes #0 = { nofree norecurse nosync nounwind 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.unroll.disable"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.mustprogress"}


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