; 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_sl_ref = external hidden unnamed_addr constant [128 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_sl_ref(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store i64 %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  %17 = load i64, ptr %10, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !5
  %19 = lshr i64 %18, 2
  %20 = icmp ult i64 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %6
  br label %23

22:                                               ; preds = %6
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 43, ptr noundef @__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_sl_ref) #3
  unreachable

23:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %24 = load ptr, ptr %12, align 8, !tbaa !9
  %25 = load i64, ptr %10, align 8, !tbaa !5
  %26 = shl i64 %25, 2
  %27 = getelementptr inbounds double, ptr %24, i64 %26
  store ptr %27, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %28 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %28, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %29 = load i64, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !5
  %31 = sub i64 %29, %30
  store i64 %31, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store i64 0, ptr %16, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %88, %23
  %33 = load i64, ptr %16, align 8, !tbaa !5
  %34 = load i64, ptr %9, align 8, !tbaa !5
  %35 = icmp ult i64 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %91

37:                                               ; preds = %32
  %38 = load ptr, ptr %13, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %38, i64 0
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %14, align 8, !tbaa !9
  %42 = getelementptr inbounds double, ptr %41, i64 0
  store double %40, ptr %42, align 8, !tbaa !11
  %43 = load ptr, ptr %13, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %43, i64 1
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %14, align 8, !tbaa !9
  %47 = getelementptr inbounds double, ptr %46, i64 1
  store double %45, ptr %47, align 8, !tbaa !11
  %48 = load ptr, ptr %13, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %48, i64 2
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %14, align 8, !tbaa !9
  %52 = getelementptr inbounds double, ptr %51, i64 2
  store double %50, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %13, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %53, i64 3
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = load ptr, ptr %14, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %56, i64 3
  store double %55, ptr %57, align 8, !tbaa !11
  %58 = load ptr, ptr %14, align 8, !tbaa !9
  %59 = getelementptr inbounds double, ptr %58, i64 4
  store ptr %59, ptr %14, align 8, !tbaa !9
  %60 = load i64, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %13, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 %60
  store ptr %62, ptr %13, align 8, !tbaa !9
  %63 = load ptr, ptr %13, align 8, !tbaa !9
  %64 = getelementptr inbounds double, ptr %63, i64 0
  %65 = load double, ptr %64, align 8, !tbaa !11
  %66 = load ptr, ptr %14, align 8, !tbaa !9
  %67 = getelementptr inbounds double, ptr %66, i64 0
  store double %65, ptr %67, align 8, !tbaa !11
  %68 = load ptr, ptr %13, align 8, !tbaa !9
  %69 = getelementptr inbounds double, ptr %68, i64 1
  %70 = load double, ptr %69, align 8, !tbaa !11
  %71 = load ptr, ptr %14, align 8, !tbaa !9
  %72 = getelementptr inbounds double, ptr %71, i64 1
  store double %70, ptr %72, align 8, !tbaa !11
  %73 = load ptr, ptr %13, align 8, !tbaa !9
  %74 = getelementptr inbounds double, ptr %73, i64 2
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = load ptr, ptr %14, align 8, !tbaa !9
  %77 = getelementptr inbounds double, ptr %76, i64 2
  store double %75, ptr %77, align 8, !tbaa !11
  %78 = load ptr, ptr %13, align 8, !tbaa !9
  %79 = getelementptr inbounds double, ptr %78, i64 3
  %80 = load double, ptr %79, align 8, !tbaa !11
  %81 = load ptr, ptr %14, align 8, !tbaa !9
  %82 = getelementptr inbounds double, ptr %81, i64 3
  store double %80, ptr %82, align 8, !tbaa !11
  %83 = load ptr, ptr %14, align 8, !tbaa !9
  %84 = getelementptr inbounds double, ptr %83, i64 4
  store ptr %84, ptr %14, align 8, !tbaa !9
  %85 = load i64, ptr %15, align 8, !tbaa !5
  %86 = load ptr, ptr %13, align 8, !tbaa !9
  %87 = getelementptr inbounds double, ptr %86, i64 %85
  store ptr %87, ptr %13, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %37
  %89 = load i64, ptr %16, align 8, !tbaa !5
  %90 = add i64 %89, 1
  store i64 %90, ptr %16, align 8, !tbaa !5
  br label %32, !llvm.loop !13

91:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #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_sl_ref = external hidden unnamed_addr constant [128 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_sl_ref(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef readonly %5) local_unnamed_addr #1 {
  %7 = lshr i64 %0, 2
  %8 = icmp ugt i64 %7, %3
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 43, ptr noundef nonnull @__PRETTY_FUNCTION__.reim4_extract_1blk_from_contiguous_reim_sl_ref) #2
  unreachable

10:                                               ; preds = %6
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

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

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.036 = phi i64 [ %36, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.03135 = phi ptr [ %35, %.lr.ph ], [ %11, %.lr.ph.preheader ]
  %.03234 = phi ptr [ %34, %.lr.ph ], [ %4, %.lr.ph.preheader ]
  %12 = load double, ptr %.03135, align 8, !tbaa !5
  store double %12, ptr %.03234, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.03135, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.03234, i64 8
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.03135, i64 16
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %.03234, i64 16
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.03135, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.03234, i64 24
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.03234, i64 32
  %23 = getelementptr inbounds double, ptr %.03135, 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 %.03234, 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 %.03234, 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 %.03234, i64 56
  store double %32, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.03234, i64 64
  %35 = getelementptr inbounds double, ptr %.03135, i64 %1
  %36 = add nuw i64 %.036, 1
  %exitcond.not = icmp eq i64 %36, %2
  br i1 %exitcond.not, 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,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass