; LLVM IR from HANDS-FREE/OpenRE :: 2_Package/math/base_math_trigonometric.ll (Z5t_sinf)

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

@_ZL9sin_chart = external hidden global [361 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_Z5t_sinf(float noundef %0) #0 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  %7 = load float, ptr %3, align 4, !tbaa !5
  %8 = fcmp ole float 0.000000e+00, %7
  br i1 %8, label %9, label %52

9:                                                ; preds = %1
  %10 = load float, ptr %3, align 4, !tbaa !5
  %11 = fcmp ole float %10, 0x3FF921FB60000000
  br i1 %11, label %12, label %52

12:                                               ; preds = %9
  %13 = load float, ptr %3, align 4, !tbaa !5
  %14 = fmul float %13, 0x404CA5DC20000000
  store float %14, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %15 = load float, ptr %3, align 4, !tbaa !5
  %16 = fmul float %15, 4.000000e+00
  %17 = call noundef float @_ZSt5floorf(float noundef %16)
  %18 = fmul float %17, 2.500000e-01
  store float %18, ptr %4, align 4, !tbaa !5
  %19 = load float, ptr %3, align 4, !tbaa !5
  %20 = load float, ptr %4, align 4, !tbaa !5
  %21 = fsub float %19, %20
  store float %21, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = fmul float %22, 4.000000e+00
  %24 = fptosi float %23 to i32
  store i32 %24, ptr %6, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fptrunc double %28 to float
  store float %29, ptr %4, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp slt i32 %30, 360
  br i1 %31, label %32, label %47

32:                                               ; preds = %12
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !11
  %42 = fsub double %37, %41
  %43 = load float, ptr %5, align 4, !tbaa !5
  %44 = fpext float %43 to double
  %45 = fmul double %42, %44
  %46 = fptrunc double %45 to float
  store float %46, ptr %5, align 4, !tbaa !5
  br label %48

47:                                               ; preds = %12
  store float 0.000000e+00, ptr %5, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %47, %32
  %49 = load float, ptr %4, align 4, !tbaa !5
  %50 = load float, ptr %5, align 4, !tbaa !5
  %51 = fadd float %49, %50
  store float %51, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %65

52:                                               ; preds = %9, %1
  %53 = load float, ptr %3, align 4, !tbaa !5
  %54 = fcmp ogt float %53, 0x3FF921FB60000000
  br i1 %54, label %55, label %59

55:                                               ; preds = %52
  %56 = load float, ptr %3, align 4, !tbaa !5
  %57 = fsub float 0x400921FB60000000, %56
  %58 = call noundef float @_Z5t_sinf(float noundef %57)
  store float %58, ptr %2, align 4
  br label %65

59:                                               ; preds = %52
  %60 = load float, ptr %3, align 4, !tbaa !5
  %61 = fmul float %60, -1.000000e+00
  store float %61, ptr %3, align 4, !tbaa !5
  %62 = load float, ptr %3, align 4, !tbaa !5
  %63 = call noundef float @_Z5t_sinf(float noundef %62)
  %64 = fneg float %63
  store float %64, ptr %2, align 4
  br label %65

65:                                               ; preds = %59, %55, %48
  %66 = load float, ptr %2, align 4
  ret float %66
}

; 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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(float noundef) #2

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

@_ZL9sin_chart = external hidden local_unnamed_addr global [361 x double], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z5t_sinf(float noundef %0) local_unnamed_addr #0 {
  %2 = fcmp oge float %0, 0.000000e+00
  %3 = fcmp ole float %0, 0x3FF921FB60000000
  %or.cond23 = and i1 %2, %3
  br i1 %or.cond23, label %tailrecurse._crit_edge, label %.lr.ph

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %1
  %.tr.lcssa = phi float [ %0, %1 ], [ %27, %tailrecurse ]
  %4 = fmul float %.tr.lcssa, 0x404CA5DC20000000
  %5 = fmul float %4, 4.000000e+00
  %6 = tail call noundef float @_ZSt5floorf(float noundef %5)
  %7 = fmul float %6, 2.500000e-01
  %8 = fmul float %7, 4.000000e+00
  %9 = fptosi float %8 to i32
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %10
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fptrunc double %12 to float
  %14 = icmp slt i32 %9, 360
  br i1 %14, label %15, label %common.ret

15:                                               ; preds = %tailrecurse._crit_edge
  %16 = fsub float %4, %7
  %17 = add nsw i32 %9, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fsub double %20, %12
  %22 = fpext float %16 to double
  %23 = fmul double %21, %22
  %24 = fptrunc double %23 to float
  br label %common.ret

common.ret:                                       ; preds = %tailrecurse._crit_edge, %15
  %.019 = phi float [ %24, %15 ], [ 0.000000e+00, %tailrecurse._crit_edge ]
  %25 = fadd float %.019, %13
  br label %common.ret30

.lr.ph:                                           ; preds = %1, %tailrecurse
  %.tr24 = phi float [ %27, %tailrecurse ], [ %0, %1 ]
  %26 = fcmp ogt float %.tr24, 0x3FF921FB60000000
  br i1 %26, label %tailrecurse, label %30

tailrecurse:                                      ; preds = %.lr.ph
  %27 = fsub float 0x400921FB60000000, %.tr24
  %28 = fcmp oge float %27, 0.000000e+00
  %29 = fcmp ole float %27, 0x3FF921FB60000000
  %or.cond = and i1 %28, %29
  br i1 %or.cond, label %tailrecurse._crit_edge, label %.lr.ph

common.ret30:                                     ; preds = %30, %common.ret
  %common.ret30.op = phi float [ %25, %common.ret ], [ %33, %30 ]
  ret float %common.ret30.op

30:                                               ; preds = %.lr.ph
  %31 = fneg float %.tr24
  %32 = tail call noundef float @_Z5t_sinf(float noundef %31)
  %33 = fneg float %32
  br label %common.ret30
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(float noundef) local_unnamed_addr #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 = { inlinehint 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" }

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


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