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

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

@_ZZ14sin_chart_initvE2d1 = external hidden global float, align 4
@_ZL10chart_init = external hidden global i8, align 1
@_ZL9sin_chart = external hidden global [361 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z14sin_chart_initv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = load i8, ptr @_ZL10chart_init, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc i8 %3 to i1
  br i1 %4, label %24, label %5

5:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %1, align 4, !tbaa !11
  store float 0.000000e+00, ptr %2, align 4, !tbaa !13
  br label %6

6:                                                ; preds = %20, %5
  %7 = load i32, ptr %1, align 4, !tbaa !11
  %8 = icmp slt i32 %7, 361
  br i1 %8, label %9, label %23

9:                                                ; preds = %6
  %10 = load i32, ptr %1, align 4, !tbaa !11
  %11 = sitofp i32 %10 to float
  %12 = load float, ptr @_ZZ14sin_chart_initvE2d1, align 4, !tbaa !13
  %13 = fmul float %11, %12
  store float %13, ptr %2, align 4, !tbaa !13
  %14 = load float, ptr %2, align 4, !tbaa !13
  %15 = call noundef float @_ZSt3sinf(float noundef %14)
  %16 = fpext float %15 to double
  %17 = load i32, ptr %1, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %18
  store double %16, ptr %19, align 8, !tbaa !15
  br label %20

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

23:                                               ; preds = %6
  store i8 1, ptr @_ZL10chart_init, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %24

24:                                               ; preds = %23, %0
  %25 = load i8, ptr @_ZL10chart_init, align 1, !tbaa !5, !range !9, !noundef !10
  %26 = trunc i8 %25 to i1
  ret i1 %26
}

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

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

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

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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

@_ZZ14sin_chart_initvE2d1 = external hidden local_unnamed_addr global float, align 4
@_ZL10chart_init = external hidden local_unnamed_addr global i8, align 1
@_ZL9sin_chart = external hidden local_unnamed_addr global [361 x double], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z14sin_chart_initv() local_unnamed_addr #0 {
  %1 = load i8, ptr @_ZL10chart_init, align 1, !tbaa !5, !range !9, !noundef !10
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %11, label %.preheader

.preheader:                                       ; preds = %0, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %0 ]
  %3 = trunc nuw nsw i64 %indvars.iv to i32
  %4 = uitofp nneg i32 %3 to float
  %5 = load float, ptr @_ZZ14sin_chart_initvE2d1, align 4, !tbaa !11
  %6 = fmul float %5, %4
  %7 = tail call noundef float @_ZSt3sinf(float noundef %6)
  %8 = fpext float %7 to double
  %9 = getelementptr inbounds [361 x double], ptr @_ZL9sin_chart, i64 0, i64 %indvars.iv
  store double %8, ptr %9, align 8, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 361
  br i1 %exitcond.not, label %10, label %.preheader, !llvm.loop !15

10:                                               ; preds = %.preheader
  store i8 1, ptr @_ZL10chart_init, align 1, !tbaa !5
  br label %11

11:                                               ; preds = %10, %0
  %12 = phi i8 [ 1, %10 ], [ %1, %0 ]
  %13 = trunc nuw i8 %12 to i1
  ret i1 %13
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass