; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/4609（FFT）.ll (Z4initv)

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

@len = external dso_local global i32, align 4
@a = external dso_local global [500005 x i32], align 16
@F = external dso_local global [500005 x %struct.Complex], align 16
@num = external dso_local global [500005 x i64], align 16
@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #0 align 2

; 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
define dso_local void @_Z4initv() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.Complex, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.Complex, align 8
  call void @llvm.memset.p0.i64(ptr align 16 @num, i8 0, i64 4000040, i1 false)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %8

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

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

13:                                               ; preds = %8
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [500005 x i32], ptr @a, i64 0, i64 %15
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %16)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [500005 x i32], ptr @a, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [500005 x i64], ptr @num, i64 0, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = add nsw i64 %24, 1
  store i64 %25, ptr %23, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %13
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %1, align 4, !tbaa !5
  br label %8, !llvm.loop !11

29:                                               ; preds = %12
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i32, ptr @a, i64 %31
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @a, ptr noundef %32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = sub nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [500005 x i32], ptr @a, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !5
  store i32 1, ptr @len, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %44, %29
  %40 = load i32, ptr @len, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = mul nsw i32 %41, 2
  %43 = icmp slt i32 %40, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %39
  %45 = load i32, ptr @len, align 4, !tbaa !5
  %46 = shl i32 %45, 1
  store i32 %46, ptr @len, align 4, !tbaa !5
  br label %39, !llvm.loop !13

47:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %62, %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %65

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #7
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [500005 x i64], ptr @num, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = sitofp i64 %57 to double
  call void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %4, double noundef %58, double noundef 0.000000e+00)
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [500005 x %struct.Complex], ptr @F, i64 0, i64 %60
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %61, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #7
  br label %62

62:                                               ; preds = %53
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !5
  br label %48, !llvm.loop !17

65:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %66 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %66, ptr %5, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %76, %65
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr @len, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %79

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #7
  call void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %6, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [500005 x %struct.Complex], ptr @F, i64 0, i64 %74
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %75, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #7
  br label %76

76:                                               ; preds = %72
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %5, align 4, !tbaa !5
  br label %67, !llvm.loop !18

79:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #6

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{i64 0, i64 8, !15, i64 8, i64 8, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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

@len = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local global [500005 x i32], align 16
@F = external dso_local local_unnamed_addr global [500005 x %struct.Complex], align 16
@num = external dso_local local_unnamed_addr global [500005 x i64], align 16
@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress 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
define dso_local void @_Z4initv() local_unnamed_addr #3 {
  %1 = alloca %struct.Complex, align 8
  %2 = alloca %struct.Complex, align 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000040) @num, i8 0, i64 4000040, i1 false)
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre35 = sext i32 %4 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre35, %.._crit_edge_crit_edge ], [ %22, %.lr.ph ]
  %6 = getelementptr inbounds i32, ptr @a, i64 %.pre-phi
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull %6)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [500005 x i32], ptr @a, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = add nsw i32 %11, 1
  %13 = shl nsw i32 %12, 1
  br label %24

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %14 = getelementptr inbounds [500005 x i32], ptr @a, i64 0, i64 %indvars.iv
  %15 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %16 = load i32, ptr %14, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [500005 x i64], ptr @num, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = add nsw i64 %19, 1
  store i64 %20, ptr %18, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !11

24:                                               ; preds = %24, %._crit_edge
  %storemerge = phi i32 [ 1, %._crit_edge ], [ %26, %24 ]
  %25 = icmp slt i32 %storemerge, %13
  %26 = shl i32 %storemerge, 1
  br i1 %25, label %24, label %.preheader19, !llvm.loop !13

.preheader19:                                     ; preds = %24
  store i32 %storemerge, ptr @len, align 4, !tbaa !5
  %.not21 = icmp slt i32 %11, 0
  br i1 %.not21, label %.preheader, label %.lr.ph23.preheader

.lr.ph23.preheader:                               ; preds = %.preheader19
  %wide.trip.count = zext nneg i32 %12 to i64
  br label %.lr.ph23

.preheader.loopexit:                              ; preds = %.lr.ph23
  %.pre = load i32, ptr @len, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.preheader19
  %27 = phi i32 [ %.pre, %.preheader.loopexit ], [ %storemerge, %.preheader19 ]
  %28 = icmp slt i32 %12, %27
  br i1 %28, label %.lr.ph25.preheader, label %._crit_edge26

.lr.ph25.preheader:                               ; preds = %.preheader
  %29 = sext i32 %11 to i64
  %30 = add nsw i64 %29, 1
  br label %.lr.ph25

.lr.ph23:                                         ; preds = %.lr.ph23.preheader, %.lr.ph23
  %indvars.iv29 = phi i64 [ 0, %.lr.ph23.preheader ], [ %indvars.iv.next30, %.lr.ph23 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #7
  %31 = getelementptr inbounds [500005 x i64], ptr @num, i64 0, i64 %indvars.iv29
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = sitofp i64 %32 to double
  call void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef %33, double noundef 0.000000e+00)
  %34 = getelementptr inbounds [500005 x %struct.Complex], ptr @F, i64 0, i64 %indvars.iv29
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #7
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count
  br i1 %exitcond.not, label %.preheader.loopexit, label %.lr.ph23, !llvm.loop !17

._crit_edge26:                                    ; preds = %.lr.ph25, %.preheader
  ret void

.lr.ph25:                                         ; preds = %.lr.ph25.preheader, %.lr.ph25
  %indvars.iv32 = phi i64 [ %30, %.lr.ph25.preheader ], [ %indvars.iv.next33, %.lr.ph25 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @_ZN7ComplexC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %2, double noundef 0.000000e+00, double noundef 0.000000e+00)
  %35 = getelementptr inbounds [500005 x %struct.Complex], ptr @F, i64 0, i64 %indvars.iv32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %35, ptr noundef nonnull align 8 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  %indvars.iv.next33 = add nsw i64 %indvars.iv32, 1
  %36 = load i32, ptr @len, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next33, %37
  br i1 %38, label %.lr.ph25, label %._crit_edge26, !llvm.loop !18
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #6

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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" }
attributes #6 = { inlinehint 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 #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{i64 0, i64 8, !15, i64 8, i64 8, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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