; LLVM IR from kobalicek/simdtests :: trigo/trigo_ref.ll (Z18trigo_vsin_precisePdPKdm)

; 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.lol::real" = type { [16 x i32], i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18trigo_vsin_precisePdPKdm(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca %"class.lol::real", align 4
  %10 = alloca %"class.lol::real", align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %53, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i64, ptr %7, align 8, !tbaa !9
  %15 = getelementptr inbounds double, ptr %13, i64 %14
  %16 = load double, ptr %15, align 8, !tbaa !11
  store double %16, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 68, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 68, ptr %10) #3
  %17 = load double, ptr %8, align 8, !tbaa !11
  call void @_ZN3lol4realC1Ed(ptr noundef nonnull align 4 dereferenceable(68) %10, double noundef %17)
  call void @_ZN3lol3sinERKNS_4realE(ptr dead_on_unwind writable sret(%"class.lol::real") align 4 %9, ptr noundef nonnull align 4 dereferenceable(68) %10)
  %18 = call noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68) %9)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = getelementptr inbounds double, ptr %19, i64 %20
  store double %18, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 68, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 68, ptr %9) #3
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = add i64 %22, 1
  store i64 %23, ptr %7, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp uge i64 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %12
  store i32 1, ptr %11, align 4
  br label %51

27:                                               ; preds = %12
  br label %28

28:                                               ; preds = %49, %27
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !11
  %33 = load double, ptr %8, align 8, !tbaa !11
  %34 = fcmp oeq double %32, %33
  br i1 %34, label %35, label %50

35:                                               ; preds = %28
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = sub i64 %37, 1
  %39 = getelementptr inbounds double, ptr %36, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = getelementptr inbounds double, ptr %41, i64 %42
  store double %40, ptr %43, align 8, !tbaa !11
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %7, align 8, !tbaa !9
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = icmp uge i64 %45, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %35
  store i32 1, ptr %11, align 4
  br label %51

49:                                               ; preds = %35
  br label %28, !llvm.loop !13

50:                                               ; preds = %28
  store i32 0, ptr %11, align 4
  br label %51

51:                                               ; preds = %50, %48, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %52 = load i32, ptr %11, align 4
  switch i32 %52, label %54 [
    i32 0, label %53
  ]

53:                                               ; preds = %51
  br label %12, !llvm.loop !15

54:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

declare void @_ZN3lol3sinERKNS_4realE(ptr dead_on_unwind writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68)) #2

declare void @_ZN3lol4realC1Ed(ptr noundef nonnull align 4 dereferenceable(68), double noundef) unnamed_addr #2

declare noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68)) #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 = { "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 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"class.lol::real" = type { [16 x i32], i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18trigo_vsin_precisePdPKdm(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %"class.lol::real", align 4
  %5 = alloca %"class.lol::real", align 4
  %6 = load double, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %5) #3
  call void @_ZN3lol4realC1Ed(ptr noundef nonnull align 4 dereferenceable(68) %5, double noundef %6)
  call void @_ZN3lol3sinERKNS_4realE(ptr dead_on_unwind nonnull writable sret(%"class.lol::real") align 4 %4, ptr noundef nonnull align 4 dereferenceable(68) %5)
  %7 = call noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68) %4)
  store double %7, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %4) #3
  %.not27 = icmp ugt i64 %2, 1
  br i1 %.not27, label %.preheader, label %.loopexit24

.loopexit:                                        ; preds = %13
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %5) #3
  call void @_ZN3lol4realC1Ed(ptr noundef nonnull align 4 dereferenceable(68) %5, double noundef %15)
  call void @_ZN3lol3sinERKNS_4realE(ptr dead_on_unwind nonnull writable sret(%"class.lol::real") align 4 %4, ptr noundef nonnull align 4 dereferenceable(68) %5)
  %8 = call noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68) %4)
  %9 = getelementptr inbounds double, ptr %0, i64 %.1
  store double %8, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %4) #3
  %10 = add nuw i64 %.1, 1
  %.not = icmp ult i64 %10, %2
  br i1 %.not, label %.preheader, label %.loopexit24, !llvm.loop !9

.preheader:                                       ; preds = %3, %.loopexit
  %11 = phi i64 [ %10, %.loopexit ], [ 1, %3 ]
  %12 = phi double [ %15, %.loopexit ], [ %6, %3 ]
  br label %13

13:                                               ; preds = %.preheader, %17
  %.1 = phi i64 [ %21, %17 ], [ %11, %.preheader ]
  %14 = getelementptr inbounds double, ptr %1, i64 %.1
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fcmp oeq double %15, %12
  br i1 %16, label %17, label %.loopexit

17:                                               ; preds = %13
  %18 = getelementptr double, ptr %0, i64 %.1
  %19 = getelementptr i8, ptr %18, i64 -8
  %20 = load double, ptr %19, align 8, !tbaa !5
  store double %20, ptr %18, align 8, !tbaa !5
  %21 = add i64 %.1, 1
  %.not21 = icmp ult i64 %21, %2
  br i1 %.not21, label %13, label %.loopexit24, !llvm.loop !11

.loopexit24:                                      ; preds = %.loopexit, %17, %3
  ret void
}

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

declare void @_ZN3lol3sinERKNS_4realE(ptr dead_on_unwind writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68)) local_unnamed_addr #2

declare void @_ZN3lol4realC1Ed(ptr noundef nonnull align 4 dereferenceable(68), double noundef) unnamed_addr #2

declare noundef double @_ZNK3lol4realcvdEv(ptr noundef nonnull align 4 dereferenceable(68)) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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