; LLVM IR from swifterfit/algorithm :: 简易桶排序 (bucket_sort)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [11 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 44, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %13, %0
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = icmp sle i32 %7, 10
  br i1 %8, label %9, label %16

9:                                                ; preds = %6
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [11 x i32], ptr %2, i64 0, i64 %11
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %9
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %3, align 4, !tbaa !5
  br label %6, !llvm.loop !9

16:                                               ; preds = %6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %27, %16
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 5
  br i1 %19, label %20, label %30

20:                                               ; preds = %17
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [11 x i32], ptr %2, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %24, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %20
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %3, align 4, !tbaa !5
  br label %17, !llvm.loop !11

30:                                               ; preds = %17
  store i32 10, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %49, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp sge i32 %32, 0
  br i1 %33, label %34, label %52

34:                                               ; preds = %31
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %45, %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [11 x i32], ptr %2, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp slt i32 %36, %40
  br i1 %41, label %42, label %48

42:                                               ; preds = %35
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %43)
  br label %45

45:                                               ; preds = %42
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !5
  br label %35, !llvm.loop !12

48:                                               ; preds = %35
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !13

52:                                               ; preds = %31
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 44, ptr %2) #3
  ret i32 0
}

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

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

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

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

attributes #0 = { 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 = { "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 = { 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/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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader13.preheader:
  %0 = alloca [11 x i32], align 16
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 44, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(44) %0, i8 0, i64 44, i1 false), !tbaa !5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [11 x i32], ptr %0, i64 0, i64 %4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr %5, align 4, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [11 x i32], ptr %0, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr %11, align 4, !tbaa !5
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [11 x i32], ptr %0, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !5
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [11 x i32], ptr %0, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !5
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [11 x i32], ptr %0, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %29, align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 40
  %33 = load i32, ptr %32, align 8, !tbaa !5
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader13.preheader, %.lr.ph
  %.016 = phi i32 [ %36, %.lr.ph ], [ 0, %.preheader13.preheader ]
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 10)
  %36 = add nuw nsw i32 %.016, 1
  %exitcond.not = icmp eq i32 %36, %33
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader13.preheader
  %37 = getelementptr inbounds i8, ptr %0, i64 36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.lr.ph.1, label %._crit_edge.1

.lr.ph.1:                                         ; preds = %._crit_edge, %.lr.ph.1
  %.016.1 = phi i32 [ %41, %.lr.ph.1 ], [ 0, %._crit_edge ]
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 9)
  %41 = add nuw nsw i32 %.016.1, 1
  %exitcond.1.not = icmp eq i32 %41, %38
  br i1 %exitcond.1.not, label %._crit_edge.1, label %.lr.ph.1, !llvm.loop !9

._crit_edge.1:                                    ; preds = %.lr.ph.1, %._crit_edge
  %42 = getelementptr inbounds i8, ptr %0, i64 32
  %43 = load i32, ptr %42, align 16, !tbaa !5
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph.2, label %._crit_edge.2

.lr.ph.2:                                         ; preds = %._crit_edge.1, %.lr.ph.2
  %.016.2 = phi i32 [ %46, %.lr.ph.2 ], [ 0, %._crit_edge.1 ]
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 8)
  %46 = add nuw nsw i32 %.016.2, 1
  %exitcond.2.not = icmp eq i32 %46, %43
  br i1 %exitcond.2.not, label %._crit_edge.2, label %.lr.ph.2, !llvm.loop !9

._crit_edge.2:                                    ; preds = %.lr.ph.2, %._crit_edge.1
  %47 = getelementptr inbounds i8, ptr %0, i64 28
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph.3, label %._crit_edge.3

.lr.ph.3:                                         ; preds = %._crit_edge.2, %.lr.ph.3
  %.016.3 = phi i32 [ %51, %.lr.ph.3 ], [ 0, %._crit_edge.2 ]
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 7)
  %51 = add nuw nsw i32 %.016.3, 1
  %exitcond.3.not = icmp eq i32 %51, %48
  br i1 %exitcond.3.not, label %._crit_edge.3, label %.lr.ph.3, !llvm.loop !9

._crit_edge.3:                                    ; preds = %.lr.ph.3, %._crit_edge.2
  %52 = getelementptr inbounds i8, ptr %0, i64 24
  %53 = load i32, ptr %52, align 8, !tbaa !5
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %.lr.ph.4, label %._crit_edge.4

.lr.ph.4:                                         ; preds = %._crit_edge.3, %.lr.ph.4
  %.016.4 = phi i32 [ %56, %.lr.ph.4 ], [ 0, %._crit_edge.3 ]
  %55 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 6)
  %56 = add nuw nsw i32 %.016.4, 1
  %exitcond.4.not = icmp eq i32 %56, %53
  br i1 %exitcond.4.not, label %._crit_edge.4, label %.lr.ph.4, !llvm.loop !9

._crit_edge.4:                                    ; preds = %.lr.ph.4, %._crit_edge.3
  %57 = getelementptr inbounds i8, ptr %0, i64 20
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %.lr.ph.5, label %._crit_edge.5

.lr.ph.5:                                         ; preds = %._crit_edge.4, %.lr.ph.5
  %.016.5 = phi i32 [ %61, %.lr.ph.5 ], [ 0, %._crit_edge.4 ]
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 5)
  %61 = add nuw nsw i32 %.016.5, 1
  %exitcond.5.not = icmp eq i32 %61, %58
  br i1 %exitcond.5.not, label %._crit_edge.5, label %.lr.ph.5, !llvm.loop !9

._crit_edge.5:                                    ; preds = %.lr.ph.5, %._crit_edge.4
  %62 = getelementptr inbounds i8, ptr %0, i64 16
  %63 = load i32, ptr %62, align 16, !tbaa !5
  %64 = icmp sgt i32 %63, 0
  br i1 %64, label %.lr.ph.6, label %._crit_edge.6

.lr.ph.6:                                         ; preds = %._crit_edge.5, %.lr.ph.6
  %.016.6 = phi i32 [ %66, %.lr.ph.6 ], [ 0, %._crit_edge.5 ]
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 4)
  %66 = add nuw nsw i32 %.016.6, 1
  %exitcond.6.not = icmp eq i32 %66, %63
  br i1 %exitcond.6.not, label %._crit_edge.6, label %.lr.ph.6, !llvm.loop !9

._crit_edge.6:                                    ; preds = %.lr.ph.6, %._crit_edge.5
  %67 = getelementptr inbounds i8, ptr %0, i64 12
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %.lr.ph.7, label %._crit_edge.7

.lr.ph.7:                                         ; preds = %._crit_edge.6, %.lr.ph.7
  %.016.7 = phi i32 [ %71, %.lr.ph.7 ], [ 0, %._crit_edge.6 ]
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 3)
  %71 = add nuw nsw i32 %.016.7, 1
  %exitcond.7.not = icmp eq i32 %71, %68
  br i1 %exitcond.7.not, label %._crit_edge.7, label %.lr.ph.7, !llvm.loop !9

._crit_edge.7:                                    ; preds = %.lr.ph.7, %._crit_edge.6
  %72 = getelementptr inbounds i8, ptr %0, i64 8
  %73 = load i32, ptr %72, align 8, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %.lr.ph.8, label %._crit_edge.8

.lr.ph.8:                                         ; preds = %._crit_edge.7, %.lr.ph.8
  %.016.8 = phi i32 [ %76, %.lr.ph.8 ], [ 0, %._crit_edge.7 ]
  %75 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 2)
  %76 = add nuw nsw i32 %.016.8, 1
  %exitcond.8.not = icmp eq i32 %76, %73
  br i1 %exitcond.8.not, label %._crit_edge.8, label %.lr.ph.8, !llvm.loop !9

._crit_edge.8:                                    ; preds = %.lr.ph.8, %._crit_edge.7
  %77 = getelementptr inbounds i8, ptr %0, i64 4
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp sgt i32 %78, 0
  br i1 %79, label %.lr.ph.9, label %._crit_edge.9

.lr.ph.9:                                         ; preds = %._crit_edge.8, %.lr.ph.9
  %.016.9 = phi i32 [ %81, %.lr.ph.9 ], [ 0, %._crit_edge.8 ]
  %80 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 1)
  %81 = add nuw nsw i32 %.016.9, 1
  %exitcond.9.not = icmp eq i32 %81, %78
  br i1 %exitcond.9.not, label %._crit_edge.9, label %.lr.ph.9, !llvm.loop !9

._crit_edge.9:                                    ; preds = %.lr.ph.9, %._crit_edge.8
  %82 = load i32, ptr %0, align 16, !tbaa !5
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %.lr.ph.10, label %._crit_edge.10

.lr.ph.10:                                        ; preds = %._crit_edge.9, %.lr.ph.10
  %.016.10 = phi i32 [ %85, %.lr.ph.10 ], [ 0, %._crit_edge.9 ]
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 0)
  %85 = add nuw nsw i32 %.016.10, 1
  %exitcond.10.not = icmp eq i32 %85, %82
  br i1 %exitcond.10.not, label %._crit_edge.10, label %.lr.ph.10, !llvm.loop !9

._crit_edge.10:                                   ; preds = %.lr.ph.10, %._crit_edge.9
  %86 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 44, ptr nonnull %0) #4
  ret i32 0
}

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

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

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

; Function Attrs: mustprogress 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass