; LLVM IR from tfhe/spqlios-arithmetic :: spqlios/reim4 (reim4_arithmetic_ref)

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

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_ref = external hidden unnamed_addr constant [115 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; 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: nounwind uwtable
define dso_local void @reim4_extract_1blk_from_contiguous_reim_ref(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  %14 = load i64, ptr %8, align 8, !tbaa !5
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = lshr i64 %15, 2
  %17 = icmp ult i64 %14, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %5
  br label %20

19:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 27, ptr noundef @__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_ref) #3
  unreachable

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  %22 = load i64, ptr %8, align 8, !tbaa !5
  %23 = shl i64 %22, 2
  %24 = getelementptr inbounds double, ptr %21, i64 %23
  store ptr %24, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %25, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %58, %20
  %27 = load i64, ptr %13, align 8, !tbaa !5
  %28 = load i64, ptr %7, align 8, !tbaa !5
  %29 = mul i64 %28, 2
  %30 = icmp ult i64 %27, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %61

32:                                               ; preds = %26
  %33 = load ptr, ptr %11, align 8, !tbaa !9
  %34 = getelementptr inbounds double, ptr %33, i64 0
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = load ptr, ptr %12, align 8, !tbaa !9
  %37 = getelementptr inbounds double, ptr %36, i64 0
  store double %35, ptr %37, align 8, !tbaa !11
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %38, i64 1
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %12, align 8, !tbaa !9
  %42 = getelementptr inbounds double, ptr %41, i64 1
  store double %40, ptr %42, align 8, !tbaa !11
  %43 = load ptr, ptr %11, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %43, i64 2
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %12, align 8, !tbaa !9
  %47 = getelementptr inbounds double, ptr %46, i64 2
  store double %45, ptr %47, align 8, !tbaa !11
  %48 = load ptr, ptr %11, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %48, i64 3
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  %52 = getelementptr inbounds double, ptr %51, i64 3
  store double %50, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %12, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %53, i64 4
  store ptr %54, ptr %12, align 8, !tbaa !9
  %55 = load i64, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %56, i64 %55
  store ptr %57, ptr %11, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %32
  %59 = load i64, ptr %13, align 8, !tbaa !5
  %60 = add i64 %59, 1
  store i64 %60, ptr %13, align 8, !tbaa !5
  br label %26, !llvm.loop !13

61:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

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

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [94 x i8], align 1
@__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_ref = external hidden unnamed_addr constant [115 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @reim4_extract_1blk_from_contiguous_reim_ref(i64 noundef %0, i64 noundef %1, i64 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef readonly %4) local_unnamed_addr #1 {
  %6 = lshr i64 %0, 2
  %7 = icmp ugt i64 %6, %2
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 27, ptr noundef nonnull @__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_ref) #2
  unreachable

9:                                                ; preds = %5
  %10 = shl i64 %1, 1
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9
  %.idx = shl i64 %2, 5
  %11 = getelementptr inbounds i8, ptr %4, i64 %.idx
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %9
  ret void

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader
  %.023 = phi i64 [ 0, %.lr.ph.preheader ], [ %36, %.lr.ph ]
  %.01822 = phi ptr [ %3, %.lr.ph.preheader ], [ %34, %.lr.ph ]
  %.01921 = phi ptr [ %11, %.lr.ph.preheader ], [ %35, %.lr.ph ]
  %12 = load double, ptr %.01921, align 8, !tbaa !5
  store double %12, ptr %.01822, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.01921, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.01822, i64 8
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.01921, i64 16
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %.01822, i64 16
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.01921, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.01822, i64 24
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.01822, i64 32
  %23 = getelementptr inbounds double, ptr %.01921, i64 %0
  %24 = load double, ptr %23, align 8, !tbaa !5
  store double %24, ptr %22, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %23, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.01822, i64 40
  store double %26, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %23, i64 16
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01822, i64 48
  store double %29, ptr %30, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %23, i64 24
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.01822, i64 56
  store double %32, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.01822, i64 64
  %35 = getelementptr inbounds double, ptr %23, i64 %0
  %36 = add nuw i64 %.023, 2
  %exitcond.not.1 = icmp eq i64 %36, %10
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

attributes #0 = { noreturn 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 #1 = { 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 #2 = { noreturn 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass