; LLVM IR from Ubpa/USTC_CG :: Homeworks/0_CppPratices/documents/1_BasicDArray/C2Cpp/src/Array (Array)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.Array = type <{ [15 x double], i32, [4 x i8] }>

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Array4InitEv(ptr noundef nonnull align 8 dereferenceable(124)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ArrayC2Eid(ptr noundef nonnull align 8 dereferenceable(124) %0, i32 noundef %1, double noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  call void @_ZN5Array4InitEv(ptr noundef nonnull align 8 dereferenceable(124) %8)
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = icmp sgt i32 %9, 15
  br i1 %10, label %11, label %14

11:                                               ; preds = %3
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %13 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @exit(i32 noundef 0) #5
  unreachable

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %26, %14
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = load double, ptr %6, align 8, !tbaa !11
  %22 = getelementptr inbounds %class.Array, ptr %8, i32 0, i32 0
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [15 x double], ptr %22, i64 0, i64 %24
  store double %21, ptr %25, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %20
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !9
  br label %15, !llvm.loop !13

29:                                               ; preds = %19
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = getelementptr inbounds %class.Array, ptr %8, i32 0, i32 1
  store i32 %30, ptr %31, align 8, !tbaa !15
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

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

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 = { 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple 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 = !{!16, !10, i64 120}
!16 = !{!"_ZTS5Array", !7, i64 0, !10, i64 120}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [51 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Array4InitEv(ptr noundef nonnull align 8 dereferenceable(124)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ArrayC2Eid(ptr noundef nonnull align 8 dereferenceable(124) %0, i32 noundef %1, double noundef %2) unnamed_addr #1 align 2 {
  tail call void @_ZN5Array4InitEv(ptr noundef nonnull align 8 dereferenceable(124) %0)
  %4 = icmp sgt i32 %1, 15
  br i1 %4, label %52, label %.preheader

.preheader:                                       ; preds = %3
  %5 = icmp sgt i32 %1, 0
  br i1 %5, label %vector.ph, label %._crit_edge

vector.ph:                                        ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %1 to i64
  %n.rnd.up = add nuw nsw i64 %wide.trip.count, 1
  %n.vec = and i64 %n.rnd.up, 4294967294
  %trip.count.minus.1 = add nsw i64 %wide.trip.count, -1
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %trip.count.minus.1, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %6 = icmp uge <2 x i64> %broadcast.splat, <i64 0, i64 1>
  %7 = extractelement <2 x i1> %6, i64 0
  br i1 %7, label %pred.store.if, label %pred.store.continue

pred.store.if:                                    ; preds = %vector.ph
  store double %2, ptr %0, align 8, !tbaa !5
  br label %pred.store.continue

pred.store.continue:                              ; preds = %pred.store.if, %vector.ph
  %8 = extractelement <2 x i1> %6, i64 1
  br i1 %8, label %pred.store.if10, label %pred.store.continue11

pred.store.if10:                                  ; preds = %pred.store.continue
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store double %2, ptr %9, align 8, !tbaa !5
  br label %pred.store.continue11

pred.store.continue11:                            ; preds = %pred.store.if10, %pred.store.continue
  %10 = icmp eq i64 %n.vec, 2
  br i1 %10, label %._crit_edge, label %vector.body.1, !llvm.loop !9

vector.body.1:                                    ; preds = %pred.store.continue11
  %11 = icmp ugt <2 x i64> %broadcast.splat, <i64 1, i64 2>
  %12 = extractelement <2 x i1> %11, i64 0
  br i1 %12, label %pred.store.if.1, label %pred.store.continue.1

pred.store.if.1:                                  ; preds = %vector.body.1
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store double %2, ptr %13, align 8, !tbaa !5
  br label %pred.store.continue.1

pred.store.continue.1:                            ; preds = %pred.store.if.1, %vector.body.1
  %14 = extractelement <2 x i1> %11, i64 1
  br i1 %14, label %pred.store.if10.1, label %pred.store.continue11.1

pred.store.if10.1:                                ; preds = %pred.store.continue.1
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  store double %2, ptr %15, align 8, !tbaa !5
  br label %pred.store.continue11.1

pred.store.continue11.1:                          ; preds = %pred.store.if10.1, %pred.store.continue.1
  %16 = icmp eq i64 %n.vec, 4
  br i1 %16, label %._crit_edge, label %vector.body.2, !llvm.loop !9

vector.body.2:                                    ; preds = %pred.store.continue11.1
  %17 = icmp ugt <2 x i64> %broadcast.splat, <i64 3, i64 4>
  %18 = extractelement <2 x i1> %17, i64 0
  br i1 %18, label %pred.store.if.2, label %pred.store.continue.2

pred.store.if.2:                                  ; preds = %vector.body.2
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  store double %2, ptr %19, align 8, !tbaa !5
  br label %pred.store.continue.2

pred.store.continue.2:                            ; preds = %pred.store.if.2, %vector.body.2
  %20 = extractelement <2 x i1> %17, i64 1
  br i1 %20, label %pred.store.if10.2, label %pred.store.continue11.2

pred.store.if10.2:                                ; preds = %pred.store.continue.2
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  store double %2, ptr %21, align 8, !tbaa !5
  br label %pred.store.continue11.2

pred.store.continue11.2:                          ; preds = %pred.store.if10.2, %pred.store.continue.2
  %22 = icmp eq i64 %n.vec, 6
  br i1 %22, label %._crit_edge, label %vector.body.3, !llvm.loop !9

vector.body.3:                                    ; preds = %pred.store.continue11.2
  %23 = icmp ugt <2 x i64> %broadcast.splat, <i64 5, i64 6>
  %24 = extractelement <2 x i1> %23, i64 0
  br i1 %24, label %pred.store.if.3, label %pred.store.continue.3

pred.store.if.3:                                  ; preds = %vector.body.3
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  store double %2, ptr %25, align 8, !tbaa !5
  br label %pred.store.continue.3

pred.store.continue.3:                            ; preds = %pred.store.if.3, %vector.body.3
  %26 = extractelement <2 x i1> %23, i64 1
  br i1 %26, label %pred.store.if10.3, label %pred.store.continue11.3

pred.store.if10.3:                                ; preds = %pred.store.continue.3
  %27 = getelementptr inbounds i8, ptr %0, i64 56
  store double %2, ptr %27, align 8, !tbaa !5
  br label %pred.store.continue11.3

pred.store.continue11.3:                          ; preds = %pred.store.if10.3, %pred.store.continue.3
  %28 = icmp eq i64 %n.vec, 8
  br i1 %28, label %._crit_edge, label %vector.body.4, !llvm.loop !9

vector.body.4:                                    ; preds = %pred.store.continue11.3
  %29 = icmp ugt <2 x i64> %broadcast.splat, <i64 7, i64 8>
  %30 = extractelement <2 x i1> %29, i64 0
  br i1 %30, label %pred.store.if.4, label %pred.store.continue.4

pred.store.if.4:                                  ; preds = %vector.body.4
  %31 = getelementptr inbounds i8, ptr %0, i64 64
  store double %2, ptr %31, align 8, !tbaa !5
  br label %pred.store.continue.4

pred.store.continue.4:                            ; preds = %pred.store.if.4, %vector.body.4
  %32 = extractelement <2 x i1> %29, i64 1
  br i1 %32, label %pred.store.if10.4, label %pred.store.continue11.4

pred.store.if10.4:                                ; preds = %pred.store.continue.4
  %33 = getelementptr inbounds i8, ptr %0, i64 72
  store double %2, ptr %33, align 8, !tbaa !5
  br label %pred.store.continue11.4

pred.store.continue11.4:                          ; preds = %pred.store.if10.4, %pred.store.continue.4
  %34 = icmp eq i64 %n.vec, 10
  br i1 %34, label %._crit_edge, label %vector.body.5, !llvm.loop !9

vector.body.5:                                    ; preds = %pred.store.continue11.4
  %35 = icmp ugt <2 x i64> %broadcast.splat, <i64 9, i64 10>
  %36 = extractelement <2 x i1> %35, i64 0
  br i1 %36, label %pred.store.if.5, label %pred.store.continue.5

pred.store.if.5:                                  ; preds = %vector.body.5
  %37 = getelementptr inbounds i8, ptr %0, i64 80
  store double %2, ptr %37, align 8, !tbaa !5
  br label %pred.store.continue.5

pred.store.continue.5:                            ; preds = %pred.store.if.5, %vector.body.5
  %38 = extractelement <2 x i1> %35, i64 1
  br i1 %38, label %pred.store.if10.5, label %pred.store.continue11.5

pred.store.if10.5:                                ; preds = %pred.store.continue.5
  %39 = getelementptr inbounds i8, ptr %0, i64 88
  store double %2, ptr %39, align 8, !tbaa !5
  br label %pred.store.continue11.5

pred.store.continue11.5:                          ; preds = %pred.store.if10.5, %pred.store.continue.5
  %40 = icmp eq i64 %n.vec, 12
  br i1 %40, label %._crit_edge, label %vector.body.6, !llvm.loop !9

vector.body.6:                                    ; preds = %pred.store.continue11.5
  %41 = icmp ugt <2 x i64> %broadcast.splat, <i64 11, i64 12>
  %42 = extractelement <2 x i1> %41, i64 0
  br i1 %42, label %pred.store.if.6, label %pred.store.continue.6

pred.store.if.6:                                  ; preds = %vector.body.6
  %43 = getelementptr inbounds i8, ptr %0, i64 96
  store double %2, ptr %43, align 8, !tbaa !5
  br label %pred.store.continue.6

pred.store.continue.6:                            ; preds = %pred.store.if.6, %vector.body.6
  %44 = extractelement <2 x i1> %41, i64 1
  br i1 %44, label %pred.store.if10.6, label %pred.store.continue11.6

pred.store.if10.6:                                ; preds = %pred.store.continue.6
  %45 = getelementptr inbounds i8, ptr %0, i64 104
  store double %2, ptr %45, align 8, !tbaa !5
  br label %pred.store.continue11.6

pred.store.continue11.6:                          ; preds = %pred.store.if10.6, %pred.store.continue.6
  %46 = icmp eq i64 %n.vec, 14
  br i1 %46, label %._crit_edge, label %vector.body.7, !llvm.loop !9

vector.body.7:                                    ; preds = %pred.store.continue11.6
  %47 = icmp ugt <2 x i64> %broadcast.splat, <i64 13, i64 14>
  %48 = extractelement <2 x i1> %47, i64 0
  br i1 %48, label %pred.store.if.7, label %pred.store.continue.7

pred.store.if.7:                                  ; preds = %vector.body.7
  %49 = getelementptr inbounds i8, ptr %0, i64 112
  store double %2, ptr %49, align 8, !tbaa !5
  br label %pred.store.continue.7

pred.store.continue.7:                            ; preds = %pred.store.if.7, %vector.body.7
  %50 = extractelement <2 x i1> %47, i64 1
  br i1 %50, label %pred.store.if10.7, label %._crit_edge

pred.store.if10.7:                                ; preds = %pred.store.continue.7
  %51 = getelementptr inbounds i8, ptr %0, i64 120
  store double %2, ptr %51, align 8, !tbaa !5
  br label %._crit_edge

52:                                               ; preds = %3
  %53 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  tail call void @exit(i32 noundef 0) #4
  unreachable

._crit_edge:                                      ; preds = %pred.store.continue11, %pred.store.continue11.1, %pred.store.continue11.2, %pred.store.continue11.3, %pred.store.continue11.4, %pred.store.continue11.5, %pred.store.continue11.6, %pred.store.if10.7, %pred.store.continue.7, %.preheader
  %55 = getelementptr inbounds i8, ptr %0, i64 120
  store i32 %1, ptr %55, align 8, !tbaa !13
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) 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 = { 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 #3 = { 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 #4 = { 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++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = !{!14, !15, i64 120}
!14 = !{!"_ZTS5Array", !7, i64 0, !15, i64 120}
!15 = !{!"int", !7, i64 0}


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