; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1402(FFT模板题).ll (Z3gaov)

; 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
@res = external dso_local global [500005 x i32], align 16
@va = external dso_local global [500005 x %struct.Complex], align 16
@vb = external dso_local global [500005 x %struct.Complex], align 16
@.str = external hidden unnamed_addr constant [1 x i8], align 1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3gaov() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = load i32, ptr @len, align 4, !tbaa !5
  call void @_Z4ConvP7ComplexS0_i(ptr noundef @va, ptr noundef @vb, i32 noundef %7)
  call void @llvm.memset.p0.i64(ptr align 16 @res, i8 0, i64 2000020, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %24, %0
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = load i32, ptr @len, 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) #5
  br label %27

13:                                               ; preds = %8
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %15
  %17 = getelementptr inbounds %struct.Complex, ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 16, !tbaa !9
  %19 = fadd double %18, 5.000000e-01
  %20 = fptosi double %19 to i32
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %22
  store i32 %20, ptr %23, align 4, !tbaa !5
  br label %24

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

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

28:                                               ; preds = %50, %27
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr @len, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %53

33:                                               ; preds = %28
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sdiv i32 %37, 10
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = add nsw i32 %43, %38
  store i32 %44, ptr %42, align 4, !tbaa !5
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = srem i32 %48, 10
  store i32 %49, ptr %47, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %33
  %51 = load i32, ptr %2, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %2, align 4, !tbaa !5
  br label %28, !llvm.loop !14

53:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %54 = load i32, ptr @len, align 4, !tbaa !5
  %55 = sub nsw i32 %54, 1
  store i32 %55, ptr %4, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %69, %53
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = icmp sge i32 %57, 0
  br i1 %58, label %60, label %59

59:                                               ; preds = %56
  store i32 8, ptr %5, align 4
  br label %72

60:                                               ; preds = %56
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %60
  %67 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %67, ptr %3, align 4, !tbaa !5
  store i32 8, ptr %5, align 4
  br label %72

68:                                               ; preds = %60
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %4, align 4, !tbaa !5
  br label %56, !llvm.loop !15

72:                                               ; preds = %66, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %73

73:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %74 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %74, ptr %6, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %86, %73
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = icmp sge i32 %76, 0
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %89

79:                                               ; preds = %75
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 48, %83
  %85 = call i32 @putchar(i32 noundef %84)
  br label %86

86:                                               ; preds = %79
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr %6, align 4, !tbaa !5
  br label %75, !llvm.loop !16

89:                                               ; preds = %78
  %90 = call i32 @puts(ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #3

declare i32 @puts(ptr noundef) #4

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


; 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
@res = external dso_local local_unnamed_addr global [500005 x i32], align 16
@va = external dso_local global [500005 x %struct.Complex], align 16
@vb = external dso_local global [500005 x %struct.Complex], align 16
@.str = external hidden unnamed_addr constant [1 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3gaov() local_unnamed_addr #0 {
  %1 = load i32, ptr @len, align 4, !tbaa !5
  tail call void @_Z4ConvP7ComplexS0_i(ptr noundef nonnull @va, ptr noundef nonnull @vb, i32 noundef %1)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2000020) @res, i8 0, i64 2000020, i1 false)
  %2 = load i32, ptr @len, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph.preheader, label %.preheader22..preheader_crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %2 to i64
  %min.iters.check = icmp ult i32 %2, 5
  br i1 %min.iters.check, label %.lr.ph.preheader41, label %vector.ph

.lr.ph.preheader41:                               ; preds = %vector.body, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %vector.body ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.mod.vf = and i64 %wide.trip.count, 3
  %4 = icmp eq i64 %n.mod.vf, 0
  %5 = select i1 %4, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count, %5
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %6 = or disjoint i64 %index, 1
  %7 = or disjoint i64 %index, 2
  %8 = or disjoint i64 %index, 3
  %9 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %index
  %10 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %6
  %11 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %7
  %12 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %8
  %13 = load double, ptr %9, align 16, !tbaa !9
  %14 = load double, ptr %10, align 16, !tbaa !9
  %15 = insertelement <2 x double> poison, double %13, i64 0
  %16 = insertelement <2 x double> %15, double %14, i64 1
  %17 = load double, ptr %11, align 16, !tbaa !9
  %18 = load double, ptr %12, align 16, !tbaa !9
  %19 = insertelement <2 x double> poison, double %17, i64 0
  %20 = insertelement <2 x double> %19, double %18, i64 1
  %21 = fadd <2 x double> %16, <double 5.000000e-01, double 5.000000e-01>
  %22 = fadd <2 x double> %20, <double 5.000000e-01, double 5.000000e-01>
  %23 = fptosi <2 x double> %21 to <2 x i32>
  %24 = fptosi <2 x double> %22 to <2 x i32>
  %25 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %index
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  store <2 x i32> %23, ptr %25, align 16, !tbaa !5
  store <2 x i32> %24, ptr %26, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %.lr.ph.preheader41, label %vector.body, !llvm.loop !12

.preheader22:                                     ; preds = %.lr.ph
  br i1 %3, label %.lr.ph25.preheader, label %.preheader22..preheader_crit_edge

.preheader22..preheader_crit_edge:                ; preds = %0, %.preheader22
  %.pre40 = zext i32 %2 to i64
  br label %.preheader.preheader

.lr.ph25.preheader:                               ; preds = %.preheader22
  %wide.trip.count31 = zext nneg i32 %2 to i64
  %.pre = load i32, ptr @res, align 16, !tbaa !5
  br label %.lr.ph25

.lr.ph:                                           ; preds = %.lr.ph.preheader41, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader41 ]
  %28 = getelementptr inbounds [500005 x %struct.Complex], ptr @va, i64 0, i64 %indvars.iv
  %29 = load double, ptr %28, align 16, !tbaa !9
  %30 = fadd double %29, 5.000000e-01
  %31 = fptosi double %30 to i32
  %32 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %indvars.iv
  store i32 %31, ptr %32, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader22, label %.lr.ph, !llvm.loop !16

.lr.ph25:                                         ; preds = %.lr.ph25.preheader, %.lr.ph25
  %33 = phi i32 [ %.pre, %.lr.ph25.preheader ], [ %38, %.lr.ph25 ]
  %indvars.iv28 = phi i64 [ 0, %.lr.ph25.preheader ], [ %indvars.iv.next29, %.lr.ph25 ]
  %34 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %indvars.iv28
  %35 = sdiv i32 %33, 10
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %36 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %indvars.iv.next29
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, %35
  store i32 %38, ptr %36, align 4, !tbaa !5
  %39 = srem i32 %33, 10
  store i32 %39, ptr %34, align 4, !tbaa !5
  %exitcond32.not = icmp eq i64 %indvars.iv.next29, %wide.trip.count31
  br i1 %exitcond32.not, label %.preheader.preheader, label %.lr.ph25, !llvm.loop !17

.preheader.preheader:                             ; preds = %.lr.ph25, %.preheader22..preheader_crit_edge
  %indvars.iv33.ph = phi i64 [ %.pre40, %.preheader22..preheader_crit_edge ], [ %wide.trip.count31, %.lr.ph25 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %42
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %42 ], [ %indvars.iv33.ph, %.preheader.preheader ]
  %40 = trunc nuw i64 %indvars.iv33 to i32
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %42, label %._crit_edge.preheader

42:                                               ; preds = %.preheader
  %indvars.iv.next34 = add nsw i64 %indvars.iv33, -1
  %43 = and i64 %indvars.iv.next34, 4294967295
  %44 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %.not = icmp eq i32 %45, 0
  br i1 %.not, label %.preheader, label %split, !llvm.loop !18

split:                                            ; preds = %42
  %46 = and i64 %indvars.iv.next34, 4294967295
  br label %._crit_edge.preheader

._crit_edge.preheader:                            ; preds = %.preheader, %split
  %indvars.iv36.ph = phi i64 [ %46, %split ], [ 0, %.preheader ]
  br label %._crit_edge

47:                                               ; preds = %._crit_edge
  %48 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  ret void

._crit_edge:                                      ; preds = %._crit_edge.preheader, %._crit_edge
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %._crit_edge ], [ %indvars.iv36.ph, %._crit_edge.preheader ]
  %49 = getelementptr inbounds [500005 x i32], ptr @res, i64 0, i64 %indvars.iv36
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add nsw i32 %50, 48
  %52 = tail call i32 @putchar(i32 noundef %51)
  %indvars.iv.next37 = add nsw i64 %indvars.iv36, -1
  %53 = trunc nuw i64 %indvars.iv36 to i32
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %._crit_edge, label %47, !llvm.loop !19
}

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2

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

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


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