; LLVM IR from Dev-XYS/Algorithms :: Fast-Fourier-Transform(Iterative) (main)

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

%struct.complex = type { double, double }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@N = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [262144 x %struct.complex], align 16
@b = external dso_local global [262144 x %struct.complex], align 16
@res_a = external dso_local global [262144 x %struct.complex], align 16
@res_b = external dso_local global [262144 x %struct.complex], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4log2i(i32 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dftP7complexS0_i(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZN7complexmlERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.complex, align 8
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %22

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [262144 x %struct.complex], ptr @a, i64 0, i64 %15
  %17 = getelementptr inbounds %struct.complex, ptr %16, i32 0, i32 0
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %17)
  br label %19

19:                                               ; preds = %13
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !9

22:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %34, %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %37

28:                                               ; preds = %23
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [262144 x %struct.complex], ptr @b, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.complex, ptr %31, i32 0, i32 0
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %32)
  br label %34

34:                                               ; preds = %28
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %23, !llvm.loop !11

37:                                               ; preds = %27
  %38 = load i32, ptr @m, align 4, !tbaa !5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %40 = add nsw i32 %38, %39
  %41 = call noundef i32 @_Z4log2i(i32 noundef %40)
  store i32 %41, ptr @k, align 4, !tbaa !5
  %42 = load i32, ptr @k, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  %44 = shl i32 1, %43
  store i32 %44, ptr @N, align 4, !tbaa !5
  call void @_Z3dftP7complexS0_i(ptr noundef @a, ptr noundef @res_a, i32 noundef 1)
  call void @_Z3dftP7complexS0_i(ptr noundef @b, ptr noundef @res_b, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %65, %37
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = load i32, ptr @N, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %68

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [262144 x %struct.complex], ptr @res_a, i64 0, i64 %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [262144 x %struct.complex], ptr @res_b, i64 0, i64 %55
  %57 = call { double, double } @_ZN7complexmlERKS_(ptr noundef nonnull align 8 dereferenceable(16) %53, ptr noundef nonnull align 8 dereferenceable(16) %56)
  %58 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  %59 = extractvalue { double, double } %57, 0
  store double %59, ptr %58, align 8
  %60 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  %61 = extractvalue { double, double } %57, 1
  store double %61, ptr %60, align 8
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [262144 x %struct.complex], ptr @a, i64 0, i64 %63
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %64, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  br label %65

65:                                               ; preds = %50
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %4, align 4, !tbaa !5
  br label %45, !llvm.loop !15

68:                                               ; preds = %49
  call void @_Z3dftP7complexS0_i(ptr noundef @a, ptr noundef @res_a, i32 noundef -1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %88, %68
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = load i32, ptr @m, align 4, !tbaa !5
  %73 = add nsw i32 %71, %72
  %74 = icmp sle i32 %70, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %91

76:                                               ; preds = %69
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [262144 x %struct.complex], ptr @res_a, i64 0, i64 %78
  %80 = getelementptr inbounds %struct.complex, ptr %79, i32 0, i32 0
  %81 = load double, ptr %80, align 16, !tbaa !16
  %82 = load i32, ptr @N, align 4, !tbaa !5
  %83 = sitofp i32 %82 to double
  %84 = fdiv double %81, %83
  %85 = fadd double %84, 5.000000e-01
  %86 = fptosi double %85 to i32
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %86)
  br label %88

88:                                               ; preds = %76
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %6, align 4, !tbaa !5
  br label %69, !llvm.loop !18

91:                                               ; preds = %75
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #5

declare i32 @printf(ptr noundef, ...) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress norecurse 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 #5 = { "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 #6 = { 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 = !{!"int", !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}
!12 = !{i64 0, i64 8, !13, i64 8, i64 8, !13}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !10}
!16 = !{!17, !14, i64 0}
!17 = !{!"_ZTS7complex", !14, i64 0, !14, i64 8}
!18 = distinct !{!18, !10}


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

%struct.complex = type { double, double }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@N = external dso_local local_unnamed_addr global i32, align 4
@k = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [262144 x %struct.complex], align 16
@b = external dso_local global [262144 x %struct.complex], align 16
@res_a = external dso_local global [262144 x %struct.complex], align 16
@res_b = external dso_local global [262144 x %struct.complex], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4log2i(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dftP7complexS0_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local { double, double } @_ZN7complexmlERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %.not20 = icmp slt i32 %2, 0
  br i1 %.not20, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %0
  %3 = phi i32 [ %2, %0 ], [ %7, %.lr.ph ]
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %.not1822 = icmp slt i32 %4, 0
  br i1 %.not1822, label %._crit_edge, label %.lr.ph24

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %5 = getelementptr inbounds [262144 x %struct.complex], ptr @a, i64 0, i64 %indvars.iv
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %.not.not = icmp slt i64 %indvars.iv, %8
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph24
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %9 = phi i32 [ %3, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %.lcssa = phi i32 [ %4, %.preheader ], [ %18, %._crit_edge.loopexit ]
  %10 = add nsw i32 %9, %.lcssa
  %11 = tail call noundef i32 @_Z4log2i(i32 noundef %10)
  store i32 %11, ptr @k, align 4, !tbaa !5
  %12 = add nsw i32 %11, 1
  %13 = shl nuw i32 1, %12
  store i32 %13, ptr @N, align 4, !tbaa !5
  tail call void @_Z3dftP7complexS0_i(ptr noundef nonnull @a, ptr noundef nonnull @res_a, i32 noundef 1)
  tail call void @_Z3dftP7complexS0_i(ptr noundef nonnull @b, ptr noundef nonnull @res_b, i32 noundef 1)
  %14 = load i32, ptr @N, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph27, label %._crit_edge28

.lr.ph24:                                         ; preds = %.preheader, %.lr.ph24
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %.lr.ph24 ], [ 0, %.preheader ]
  %16 = getelementptr inbounds [262144 x %struct.complex], ptr @b, i64 0, i64 %indvars.iv36
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %16)
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %18 = load i32, ptr @m, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not18.not = icmp slt i64 %indvars.iv36, %19
  br i1 %.not18.not, label %.lr.ph24, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge28:                                    ; preds = %.lr.ph27, %._crit_edge
  tail call void @_Z3dftP7complexS0_i(ptr noundef nonnull @a, ptr noundef nonnull @res_a, i32 noundef -1)
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = load i32, ptr @m, align 4, !tbaa !5
  %22 = add nsw i32 %21, %20
  %.not1929 = icmp slt i32 %22, 0
  br i1 %.not1929, label %._crit_edge33, label %.lr.ph32

.lr.ph27:                                         ; preds = %._crit_edge, %.lr.ph27
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %.lr.ph27 ], [ 0, %._crit_edge ]
  %23 = getelementptr inbounds [262144 x %struct.complex], ptr @res_a, i64 0, i64 %indvars.iv39
  %24 = getelementptr inbounds [262144 x %struct.complex], ptr @res_b, i64 0, i64 %indvars.iv39
  %25 = tail call { double, double } @_ZN7complexmlERKS_(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(16) %24)
  %26 = extractvalue { double, double } %25, 0
  %27 = extractvalue { double, double } %25, 1
  %28 = getelementptr inbounds [262144 x %struct.complex], ptr @a, i64 0, i64 %indvars.iv39
  store double %26, ptr %28, align 16, !tbaa !12
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %28, i64 8
  store double %27, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !12
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %29 = load i32, ptr @N, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next40, %30
  br i1 %31, label %.lr.ph27, label %._crit_edge28, !llvm.loop !14

._crit_edge33:                                    ; preds = %.lr.ph32, %._crit_edge28
  ret i32 0

.lr.ph32:                                         ; preds = %._crit_edge28, %.lr.ph32
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph32 ], [ 0, %._crit_edge28 ]
  %32 = getelementptr inbounds [262144 x %struct.complex], ptr @res_a, i64 0, i64 %indvars.iv42
  %33 = load double, ptr %32, align 16, !tbaa !15
  %34 = load i32, ptr @N, align 4, !tbaa !5
  %35 = sitofp i32 %34 to double
  %36 = fdiv double %33, %35
  %37 = fadd double %36, 5.000000e-01
  %38 = fptosi double %37 to i32
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %38)
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = load i32, ptr @m, align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  %43 = sext i32 %42 to i64
  %.not19.not = icmp slt i64 %indvars.iv42, %43
  br i1 %.not19.not, label %.lr.ph32, label %._crit_edge33, !llvm.loop !17
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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 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 = { mustprogress norecurse 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 = { nofree 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" }

!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 = !{!"int", !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}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = !{!16, !13, i64 0}
!16 = !{!"_ZTS7complex", !13, i64 0, !13, i64 8}
!17 = distinct !{!17, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass