; LLVM IR from mausimus/rtdoom :: rtdoom/MathCache.ll (ZN6rtdoom9MathCacheC2Ev)

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

%"class.rtdoom::MathCache" = type { %"struct.std::array", %"struct.std::array", %"struct.std::array", %"struct.std::array" }
%"struct.std::array" = type { [16385 x float] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6rtdoom9MathCacheC2Ev(ptr noundef nonnull align 4 dereferenceable(262160) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 1
  %7 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 2
  %8 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %48, %1
  %10 = load i64, ptr %3, align 8, !tbaa !9
  %11 = icmp ule i64 %10, 16384
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %51

13:                                               ; preds = %9
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = uitofp i64 %14 to float
  %16 = fmul float %15, 0x3FE921FB60000000
  %17 = fdiv float %16, 1.638400e+04
  %18 = call float @tanf(float noundef %17) #3
  %19 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 0
  %20 = load i64, ptr %3, align 8, !tbaa !9
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %19, i64 noundef %20) #3
  store float %18, ptr %21, align 4, !tbaa !11
  %22 = load i64, ptr %3, align 8, !tbaa !9
  %23 = uitofp i64 %22 to float
  %24 = fmul float %23, 0x3FE921FB60000000
  %25 = fdiv float %24, 1.638400e+04
  %26 = call float @atanf(float noundef %25) #3
  %27 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 1
  %28 = load i64, ptr %3, align 8, !tbaa !9
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %27, i64 noundef %28) #3
  store float %26, ptr %29, align 4, !tbaa !11
  %30 = load i64, ptr %3, align 8, !tbaa !9
  %31 = uitofp i64 %30 to float
  %32 = fmul float %31, 2.000000e+00
  %33 = fmul float %32, 0x400921FB60000000
  %34 = fdiv float %33, 1.638400e+04
  %35 = call float @cosf(float noundef %34) #3
  %36 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 2
  %37 = load i64, ptr %3, align 8, !tbaa !9
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %36, i64 noundef %37) #3
  store float %35, ptr %38, align 4, !tbaa !11
  %39 = load i64, ptr %3, align 8, !tbaa !9
  %40 = uitofp i64 %39 to float
  %41 = fmul float %40, 2.000000e+00
  %42 = fmul float %41, 0x400921FB60000000
  %43 = fdiv float %42, 1.638400e+04
  %44 = call float @sinf(float noundef %43) #3
  %45 = getelementptr inbounds %"class.rtdoom::MathCache", ptr %4, i32 0, i32 3
  %46 = load i64, ptr %3, align 8, !tbaa !9
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %45, i64 noundef %46) #3
  store float %44, ptr %47, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %13
  %49 = load i64, ptr %3, align 8, !tbaa !9
  %50 = add i64 %49, 1
  store i64 %50, ptr %3, align 8, !tbaa !9
  br label %9, !llvm.loop !13

51:                                               ; preds = %12
  ret void
}

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

; Function Attrs: nounwind
declare float @tanf(float noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540), i64 noundef) #0 align 2

; Function Attrs: nounwind
declare float @atanf(float noundef) #2

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

; Function Attrs: nounwind
declare float @sinf(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 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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nounwind uwtable
define dso_local void @_ZN6rtdoom9MathCacheC2Ev(ptr noundef nonnull align 4 dereferenceable(262160) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 65540
  %3 = getelementptr inbounds i8, ptr %0, i64 131080
  %4 = getelementptr inbounds i8, ptr %0, i64 196620
  br label %6

5:                                                ; preds = %6
  ret void

6:                                                ; preds = %1, %6
  %.010 = phi i64 [ 0, %1 ], [ %21, %6 ]
  %7 = uitofp nneg i64 %.010 to float
  %8 = fmul float %7, 0x3FE921FB60000000
  %9 = fmul float %8, 0x3F10000000000000
  %10 = tail call float @tanf(float noundef %9) #2
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %0, i64 noundef %.010) #2
  store float %10, ptr %11, align 4, !tbaa !5
  %12 = tail call float @atanf(float noundef %9) #2
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %2, i64 noundef %.010) #2
  store float %12, ptr %13, align 4, !tbaa !5
  %14 = fmul float %7, 2.000000e+00
  %15 = fmul float %14, 0x400921FB60000000
  %16 = fmul float %15, 0x3F10000000000000
  %17 = tail call float @cosf(float noundef %16) #2
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %3, i64 noundef %.010) #2
  store float %17, ptr %18, align 4, !tbaa !5
  %19 = tail call float @sinf(float noundef %16) #2
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540) %4, i64 noundef %.010) #2
  store float %19, ptr %20, align 4, !tbaa !5
  %21 = add nuw nsw i64 %.010, 1
  %exitcond.not = icmp eq i64 %21, 16385
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !9
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @tanf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm16385EEixEm(ptr noundef nonnull align 4 dereferenceable(65540), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @atanf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(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 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass