; LLVM IR from hao14293/2021-Postgraduate-408 :: Data-Structure/Sort/sorts (shellSort)

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

@__const.main.a = external hidden unnamed_addr constant [8 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [8 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.main.a, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 8, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sdiv i32 %8, 2
  store i32 %9, ptr %4, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %67, %0
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %13, label %70

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %14 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %14, ptr %5, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %63, %13
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %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 %5) #4
  br label %67

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %39, %20
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = icmp sge i32 %22, %23
  br i1 %24, label %25, label %37

25:                                               ; preds = %21
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sub nsw i32 %26, %27
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = icmp sgt i32 %31, %35
  br label %37

37:                                               ; preds = %25, %21
  %38 = phi i1 [ false, %21 ], [ %36, %25 ]
  br i1 %38, label %39, label %62

39:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sub nsw i32 %40, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  store i32 %45, ptr %6, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sub nsw i32 %50, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %53
  store i32 %49, ptr %54, align 4, !tbaa !5
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %57
  store i32 %55, ptr %58, align 4, !tbaa !5
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sub nsw i32 %60, %59
  store i32 %61, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %21, !llvm.loop !9

62:                                               ; preds = %37
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = add nsw i32 %65, %64
  store i32 %66, ptr %5, align 4, !tbaa !5
  br label %15, !llvm.loop !11

67:                                               ; preds = %19
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sdiv i32 %68, 2
  store i32 %69, ptr %4, align 4, !tbaa !5
  br label %10, !llvm.loop !12

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

71:                                               ; preds = %82, %70
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %71
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %80)
  br label %82

82:                                               ; preds = %76
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %7, align 4, !tbaa !5
  br label %71, !llvm.loop !13

85:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #4
  ret i32 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 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

%"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 }

@__const.main.a = external hidden unnamed_addr constant [8 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader31.preheader:
  %0 = alloca [8 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %0) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %0, ptr noundef nonnull align 16 dereferenceable(32) @__const.main.a, i64 32, i1 false)
  br label %.preheader31

.preheader31:                                     ; preds = %.critedge, %.preheader31.preheader
  %.02737 = phi i32 [ %55, %.critedge ], [ 4, %.preheader31.preheader ]
  %.not3033 = icmp slt i32 %.02737, 4
  br i1 %.not3033, label %.critedge, label %.lr.ph

.preheader31.1:                                   ; preds = %.lr.ph, %.critedge.1
  %.02737.1 = phi i32 [ %10, %.critedge.1 ], [ 2, %.lr.ph ]
  %.not3033.1 = icmp slt i32 %.02737.1, 2
  br i1 %.not3033.1, label %.critedge.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.preheader31.1, %9
  %.134.1 = phi i32 [ %1, %9 ], [ %.02737.1, %.preheader31.1 ]
  %1 = add nsw i32 %.134.1, -2
  %2 = zext nneg i32 %1 to i64
  %3 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %2
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = zext nneg i32 %.134.1 to i64
  %6 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp sgt i32 %4, %7
  br i1 %8, label %9, label %.critedge.1

9:                                                ; preds = %.lr.ph.1
  store i32 %7, ptr %3, align 4, !tbaa !5
  store i32 %4, ptr %6, align 4, !tbaa !5
  %.not30.1 = icmp ult i32 %.134.1, 4
  br i1 %.not30.1, label %.critedge.1, label %.lr.ph.1, !llvm.loop !9

.critedge.1:                                      ; preds = %.lr.ph.1, %9, %.preheader31.1
  %.1.lcssa.1 = phi i32 [ %.02737.1, %.preheader31.1 ], [ %.134.1, %.lr.ph.1 ], [ %1, %9 ]
  %10 = add nsw i32 %.1.lcssa.1, 2
  %11 = icmp slt i32 %.1.lcssa.1, 6
  br i1 %11, label %.preheader31.1, label %.preheader31.2, !llvm.loop !11

.preheader31.2:                                   ; preds = %.critedge.1, %.critedge.2
  %.02737.2 = phi i32 [ %21, %.critedge.2 ], [ 1, %.critedge.1 ]
  %.not3033.2 = icmp slt i32 %.02737.2, 1
  br i1 %.not3033.2, label %.critedge.2, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %.preheader31.2, %20
  %.134.2 = phi i32 [ %12, %20 ], [ %.02737.2, %.preheader31.2 ]
  %12 = add nsw i32 %.134.2, -1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = zext nneg i32 %.134.2 to i64
  %17 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp sgt i32 %15, %18
  br i1 %19, label %20, label %.critedge.2

20:                                               ; preds = %.lr.ph.2
  store i32 %18, ptr %14, align 4, !tbaa !5
  store i32 %15, ptr %17, align 4, !tbaa !5
  %.not30.2 = icmp ult i32 %.134.2, 2
  br i1 %.not30.2, label %.critedge.2, label %.lr.ph.2, !llvm.loop !9

.critedge.2:                                      ; preds = %.lr.ph.2, %20, %.preheader31.2
  %.1.lcssa.2 = phi i32 [ %.02737.2, %.preheader31.2 ], [ %.134.2, %.lr.ph.2 ], [ 0, %20 ]
  %21 = add nsw i32 %.1.lcssa.2, 1
  %22 = icmp slt i32 %.1.lcssa.2, 7
  br i1 %22, label %.preheader31.2, label %._crit_edge.2, !llvm.loop !11

._crit_edge.2:                                    ; preds = %.critedge.2
  %23 = load i32, ptr %0, align 16, !tbaa !5
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %23)
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %26)
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !5
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %29)
  %31 = getelementptr inbounds i8, ptr %0, i64 12
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %32)
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  %35 = load i32, ptr %34, align 16, !tbaa !5
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %35)
  %37 = getelementptr inbounds i8, ptr %0, i64 20
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %38)
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load i32, ptr %40, align 8, !tbaa !5
  %42 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %41)
  %43 = getelementptr inbounds i8, ptr %0, i64 28
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %44)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %0) #4
  ret i32 0

.lr.ph:                                           ; preds = %.preheader31, %54
  %.134 = phi i32 [ %46, %54 ], [ %.02737, %.preheader31 ]
  %46 = add nsw i32 %.134, -4
  %47 = zext nneg i32 %46 to i64
  %48 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = zext nneg i32 %.134 to i64
  %51 = getelementptr inbounds [8 x i32], ptr %0, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp sgt i32 %49, %52
  br i1 %53, label %54, label %.preheader31.1

54:                                               ; preds = %.lr.ph
  store i32 %52, ptr %48, align 4, !tbaa !5
  store i32 %49, ptr %51, align 4, !tbaa !5
  %.not30 = icmp ult i32 %.134, 8
  br i1 %.not30, label %.critedge, label %.lr.ph, !llvm.loop !9

.critedge:                                        ; preds = %54, %.preheader31
  %.1.lcssa = phi i32 [ %.02737, %.preheader31 ], [ %46, %54 ]
  %55 = add nsw i32 %.1.lcssa, 4
  br label %.preheader31, !llvm.loop !11
}

; 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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}


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