; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.207 = external hidden unnamed_addr constant [35 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_part_quick_a(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @r8vec_sort_quick_a(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [30 x i32], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 120, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 1
  br i1 %13, label %14, label %21

14:                                               ; preds = %2
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str) #4
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.207) #4
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.72) #4
  call void @exit(i32 noundef 1) #5
  unreachable

21:                                               ; preds = %2
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i32 1, ptr %11, align 4
  br label %111

25:                                               ; preds = %21
  br label %26

26:                                               ; preds = %25
  store i32 1, ptr %7, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  %29 = getelementptr inbounds [30 x i32], ptr %9, i64 0, i64 0
  store i32 %28, ptr %29, align 16, !tbaa !5
  store i32 1, ptr %5, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %30, ptr %8, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %109, %26
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = icmp slt i32 0, %32
  br i1 %33, label %34, label %110

34:                                               ; preds = %31
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !9
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %36, i64 %38
  %40 = getelementptr inbounds double, ptr %39, i64 -1
  call void @r8vec_part_quick_a(i32 noundef %35, ptr noundef %40, ptr noundef %6, ptr noundef %10)
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = icmp slt i32 1, %41
  br i1 %42, label %43, label %65

43:                                               ; preds = %34
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = icmp slt i32 30, %44
  br i1 %45, label %46, label %53

46:                                               ; preds = %43
  %47 = load ptr, ptr @stderr, align 8, !tbaa !9
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str) #4
  %49 = load ptr, ptr @stderr, align 8, !tbaa !9
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.207) #4
  %51 = load ptr, ptr @stderr, align 8, !tbaa !9
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.75, i32 noundef 30) #4
  call void @exit(i32 noundef 1) #5
  unreachable

53:                                               ; preds = %43
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %56, ptr %8, align 4, !tbaa !5
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = add nsw i32 %57, %58
  %60 = sub nsw i32 %59, 1
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [30 x i32], ptr %9, i64 0, i64 %63
  store i32 %60, ptr %64, align 4, !tbaa !5
  br label %109

65:                                               ; preds = %34
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %69, label %78

69:                                               ; preds = %65
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = load i32, ptr %10, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  store i32 %73, ptr %8, align 4, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = load i32, ptr %10, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %108

78:                                               ; preds = %65
  br label %79

79:                                               ; preds = %106, %78
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = icmp slt i32 1, %80
  br i1 %81, label %82, label %105

82:                                               ; preds = %79
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [30 x i32], ptr %9, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  store i32 %87, ptr %5, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sub nsw i32 %88, 2
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [30 x i32], ptr %9, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [30 x i32], ptr %9, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sub nsw i32 %92, %97
  store i32 %98, ptr %8, align 4, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = sub nsw i32 %99, 1
  store i32 %100, ptr %7, align 4, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = icmp slt i32 0, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %82
  br label %107

104:                                              ; preds = %82
  br label %106

105:                                              ; preds = %79
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %107

106:                                              ; preds = %104
  br label %79

107:                                              ; preds = %105, %103
  br label %108

108:                                              ; preds = %107, %69
  br label %109

109:                                              ; preds = %108, %53
  br label %31, !llvm.loop !11

110:                                              ; preds = %31
  store i32 1, ptr %11, align 4
  br label %111

111:                                              ; preds = %110, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 120, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.207 = external hidden unnamed_addr constant [35 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @r8vec_part_quick_a(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @r8vec_sort_quick_a(i32 noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  %4 = alloca [30 x i32], align 16
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %6 = icmp slt i32 %0, 1
  br i1 %6, label %7, label %14

7:                                                ; preds = %2
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str) #5
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.207) #5
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.72) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

14:                                               ; preds = %2
  %15 = icmp eq i32 %0, 1
  br i1 %15, label %.loopexit29, label %.lr.ph40.preheader

.lr.ph40.preheader:                               ; preds = %14
  %16 = add nuw nsw i32 %0, 1
  store i32 %16, ptr %4, align 16, !tbaa !9
  %invariant.gep = getelementptr i8, ptr %1, i64 -8
  br label %.lr.ph40

.lr.ph40:                                         ; preds = %.lr.ph40.preheader, %.loopexit
  %.039 = phi i32 [ %.1, %.loopexit ], [ %0, %.lr.ph40.preheader ]
  %.02038 = phi i32 [ %.2, %.loopexit ], [ 1, %.lr.ph40.preheader ]
  %.02237 = phi i32 [ %.224, %.loopexit ], [ 1, %.lr.ph40.preheader ]
  %17 = sext i32 %.02237 to i64
  %gep = getelementptr double, ptr %invariant.gep, i64 %17
  call void @r8vec_part_quick_a(i32 noundef %.039, ptr noundef nonnull %gep, ptr noundef nonnull %3, ptr noundef nonnull %5)
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = icmp sgt i32 %18, 1
  br i1 %19, label %20, label %36

20:                                               ; preds = %.lr.ph40
  %21 = icmp sgt i32 %.02038, 30
  br i1 %21, label %22, label %29

22:                                               ; preds = %20
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str) #5
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.207) #5
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.75, i32 noundef 30) #5
  call void @exit(i32 noundef 1) #6
  unreachable

29:                                               ; preds = %20
  %30 = add nsw i32 %.02038, 1
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = add i32 %.02237, -1
  %33 = add i32 %32, %31
  %34 = sext i32 %.02038 to i64
  %35 = getelementptr inbounds [30 x i32], ptr %4, i64 0, i64 %34
  store i32 %33, ptr %35, align 4, !tbaa !9
  br label %.loopexit

36:                                               ; preds = %.lr.ph40
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp slt i32 %37, %.039
  br i1 %38, label %41, label %.preheader

.preheader:                                       ; preds = %36
  %39 = icmp sgt i32 %.02038, 1
  br i1 %39, label %.lr.ph.preheader, label %.loopexit29

.lr.ph.preheader:                                 ; preds = %.preheader
  %40 = zext nneg i32 %.02038 to i64
  br label %.lr.ph

41:                                               ; preds = %36
  %42 = add nuw nsw i32 %.039, 1
  %43 = sub i32 %42, %37
  %44 = add i32 %.02237, -1
  %45 = add i32 %44, %37
  br label %.loopexit

46:                                               ; preds = %.lr.ph
  %47 = icmp ugt i64 %indvars.iv, 2
  br i1 %47, label %.lr.ph, label %.loopexit29

.lr.ph:                                           ; preds = %.lr.ph.preheader, %46
  %indvars.iv = phi i64 [ %40, %.lr.ph.preheader ], [ %indvars.iv.next, %46 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %48 = getelementptr inbounds [30 x i32], ptr %4, i64 0, i64 %indvars.iv.next
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = add nsw i64 %indvars.iv, -2
  %51 = getelementptr inbounds [30 x i32], ptr %4, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = sub nsw i32 %52, %49
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %.loopexit.loopexit, label %46

.loopexit.loopexit:                               ; preds = %.lr.ph
  %55 = trunc nuw nsw i64 %indvars.iv.next to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %41, %29
  %.224 = phi i32 [ %.02237, %29 ], [ %45, %41 ], [ %49, %.loopexit.loopexit ]
  %.2 = phi i32 [ %30, %29 ], [ %.02038, %41 ], [ %55, %.loopexit.loopexit ]
  %.1 = phi i32 [ %18, %29 ], [ %43, %41 ], [ %53, %.loopexit.loopexit ]
  %56 = icmp sgt i32 %.1, 0
  br i1 %56, label %.lr.ph40, label %.loopexit29, !llvm.loop !11

.loopexit29:                                      ; preds = %.preheader, %.loopexit, %46, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 120, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { cold nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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