; LLVM IR from quarkslab/crypto-condor :: crypto_condor/primitives/_testu01/testu01 (fftc)

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

; Function Attrs: nounwind uwtable
define dso_local void @rsrfft(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %13, i32 -1
  store ptr %14, ptr %3, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = shl i32 1, %15
  store i32 %16, ptr %5, align 4, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i32, ptr %4, align 4, !tbaa !9
  call void @rbitrev(ptr noundef %17, i32 noundef %18)
  store i32 1, ptr %6, align 4, !tbaa !9
  store i32 4, ptr %7, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %66, %2
  %20 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %20, ptr %8, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %56, %19
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %25, label %60

25:                                               ; preds = %21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  store double %30, ptr %12, align 8, !tbaa !11
  %31 = load double, ptr %12, align 8, !tbaa !11
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %32, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = fadd double %31, %37
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  store double %38, ptr %42, align 8, !tbaa !11
  %43 = load double, ptr %12, align 8, !tbaa !11
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %44, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = fsub double %43, %49
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %51, i64 %54
  store double %50, ptr %55, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %25
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = add nsw i32 %58, %57
  store i32 %59, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !13

60:                                               ; preds = %21
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = mul nsw i32 2, %61
  %63 = sub nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !9
  %64 = load i32, ptr %7, align 4, !tbaa !9
  %65 = mul nsw i32 4, %64
  store i32 %65, ptr %7, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %60
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %5, align 4, !tbaa !9
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %19, label %70, !llvm.loop !15

70:                                               ; preds = %66
  store i32 2, ptr %9, align 4, !tbaa !9
  store i32 2, ptr %11, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %99, %70
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %75, label %102

75:                                               ; preds = %71
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = mul nsw i32 %76, 2
  store i32 %77, ptr %9, align 4, !tbaa !9
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = sdiv i32 %78, 4
  store i32 %79, ptr %10, align 4, !tbaa !9
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds double, ptr %83, i64 0
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds double, ptr %85, i64 %87
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = mul nsw i32 2, %90
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds double, ptr %89, i64 %92
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = mul nsw i32 3, %95
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds double, ptr %94, i64 %97
  call void @rstage(i32 noundef %80, i32 noundef %81, i32 noundef %82, ptr noundef %84, ptr noundef %88, ptr noundef %93, ptr noundef %98)
  br label %99

99:                                               ; preds = %75
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %11, align 4, !tbaa !9
  br label %71, !llvm.loop !16

102:                                              ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  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 uwtable
declare dso_local void @rbitrev(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @rstage(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

attributes #0 = { 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 }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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}
!16 = distinct !{!16, !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"

; Function Attrs: nounwind uwtable
define dso_local void @rsrfft(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 -8
  %4 = shl nuw i32 1, %1
  tail call void @rbitrev(ptr noundef nonnull %3, i32 noundef %1)
  %5 = sext i32 %4 to i64
  br label %6

6:                                                ; preds = %._crit_edge, %2
  %.042 = phi i32 [ 4, %2 ], [ %17, %._crit_edge ]
  %.039 = phi i32 [ 1, %2 ], [ %16, %._crit_edge ]
  %.not47 = icmp sgt i32 %.039, %4
  br i1 %.not47, label %._crit_edge, label %.lr.ph.lver.check

.lr.ph.lver.check:                                ; preds = %6
  %7 = sext i32 %.042 to i64
  %8 = sext i32 %.039 to i64
  br label %.lr.ph.lver.orig

.lr.ph.lver.orig:                                 ; preds = %.lr.ph.lver.orig, %.lr.ph.lver.check
  %indvars.iv.lver.orig = phi i64 [ %8, %.lr.ph.lver.check ], [ %indvars.iv.next.lver.orig, %.lr.ph.lver.orig ]
  %9 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.lver.orig
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = getelementptr i8, ptr %9, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fadd double %10, %12
  store double %13, ptr %9, align 8, !tbaa !5
  %14 = fsub double %10, %12
  store double %14, ptr %11, align 8, !tbaa !5
  %indvars.iv.next.lver.orig = add nsw i64 %indvars.iv.lver.orig, %7
  %.not.lver.orig = icmp sgt i64 %indvars.iv.next.lver.orig, %5
  br i1 %.not.lver.orig, label %._crit_edge, label %.lr.ph.lver.orig, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph.lver.orig, %6
  %15 = shl nuw nsw i32 %.042, 1
  %16 = add nsw i32 %15, -1
  %17 = shl nsw i32 %.042, 2
  %.not45 = icmp sgt i32 %15, %4
  br i1 %.not45, label %.preheader, label %6, !llvm.loop !11

.preheader:                                       ; preds = %._crit_edge
  %.not4649 = icmp slt i32 %1, 2
  br i1 %.not4649, label %._crit_edge53, label %.lr.ph52

.lr.ph52:                                         ; preds = %.preheader, %.lr.ph52
  %.051 = phi i32 [ %27, %.lr.ph52 ], [ 2, %.preheader ]
  %.04050 = phi i32 [ %18, %.lr.ph52 ], [ 2, %.preheader ]
  %18 = shl nsw i32 %.04050, 1
  %19 = ashr exact i32 %.04050, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds double, ptr %3, i64 %20
  %22 = sext i32 %.04050 to i64
  %23 = getelementptr inbounds double, ptr %3, i64 %22
  %24 = mul nsw i32 %19, 3
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %3, i64 %25
  tail call void @rstage(i32 noundef %4, i32 noundef %18, i32 noundef %19, ptr noundef nonnull %3, ptr noundef nonnull %21, ptr noundef nonnull %23, ptr noundef nonnull %26)
  %27 = add nuw i32 %.051, 1
  %exitcond.not = icmp eq i32 %.051, %1
  br i1 %exitcond.not, label %._crit_edge53, label %.lr.ph52, !llvm.loop !12

._crit_edge53:                                    ; preds = %.lr.ph52, %.preheader
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @rbitrev(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @rstage(i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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