; LLVM IR from Discngine/fpocket :: src (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"

%struct.s_vsort = type { ptr, i32 }
%struct.s_vect_elem = type { ptr, i32 }
%struct.s_atm = type { i32, float, float, float, float, float, float, float, [5 x i8], [7 x i8], [16 x i8], [16 x i8], [3 x i8], [8 x i8], i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, i8, i8, float, float, float, float, i16, ptr, i32 }
%struct.s_vvertice = type { i32, i32, i32, i32, i32, float, float, float, float, i32, i32, [4 x i32], [4 x ptr], [3 x float], float }

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 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 uwtable
define dso_local void @print_sorted_lst(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_vsort, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float -1.000000e+00, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %16

16:                                               ; preds = %78, %2
  %17 = load i32, ptr %8, align 4, !tbaa !14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_vsort, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = icmp slt i32 %17, %20
  br i1 %21, label %22, label %81

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load i32, ptr %8, align 4, !tbaa !14
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.1, i32 noundef %24) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !14
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.s_vect_elem, ptr %26, i64 %28
  %30 = getelementptr inbounds %struct.s_vect_elem, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %50

33:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !14
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %struct.s_vect_elem, ptr %34, i64 %36
  %38 = getelementptr inbounds %struct.s_vect_elem, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  store ptr %39, ptr %9, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_atm, ptr %40, i32 0, i32 5
  %42 = load float, ptr %41, align 4, !tbaa !19
  store float %42, ptr %6, align 4, !tbaa !12
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load float, ptr %6, align 4, !tbaa !12
  %45 = fpext float %44 to double
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_atm, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !22
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.2, double noundef %45, i32 noundef %48) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %67

50:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !14
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %struct.s_vect_elem, ptr %51, i64 %53
  %55 = getelementptr inbounds %struct.s_vect_elem, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  store ptr %56, ptr %10, align 8, !tbaa !5
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_vvertice, ptr %57, i32 0, i32 6
  %59 = load float, ptr %58, align 8, !tbaa !23
  store float %59, ptr %6, align 4, !tbaa !12
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load float, ptr %6, align 4, !tbaa !12
  %62 = fpext float %61 to double
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_vvertice, ptr %63, i32 0, i32 9
  %65 = load i32, ptr %64, align 4, !tbaa !25
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.3, double noundef %62, i32 noundef %65) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %67

67:                                               ; preds = %50, %33
  %68 = load float, ptr %7, align 4, !tbaa !12
  %69 = load float, ptr %6, align 4, !tbaa !12
  %70 = fcmp ogt float %68, %69
  br i1 %70, label %71, label %74

71:                                               ; preds = %67
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str.4) #3
  br label %74

74:                                               ; preds = %71, %67
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.5) #3
  %77 = load float, ptr %6, align 4, !tbaa !12
  store float %77, ptr %7, align 4, !tbaa !12
  br label %78

78:                                               ; preds = %74
  %79 = load i32, ptr %8, align 4, !tbaa !14
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %8, align 4, !tbaa !14
  br label %16, !llvm.loop !26

81:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

!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, !6, i64 0}
!10 = !{!"s_vsort", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!17, !11, i64 8}
!17 = !{!"s_vect_elem", !6, i64 0, !11, i64 8}
!18 = !{!17, !6, i64 0}
!19 = !{!20, !13, i64 20}
!20 = !{!"s_atm", !11, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !7, i64 32, !7, i64 37, !7, i64 44, !7, i64 60, !7, i64 76, !7, i64 79, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !13, i64 132, !13, i64 136, !13, i64 140, !7, i64 144, !7, i64 145, !13, i64 148, !13, i64 152, !13, i64 156, !13, i64 160, !21, i64 164, !6, i64 168, !11, i64 176}
!21 = !{!"short", !7, i64 0}
!22 = !{!20, !11, i64 0}
!23 = !{!24, !13, i64 24}
!24 = !{!"s_vvertice", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !11, i64 36, !11, i64 40, !7, i64 44, !7, i64 64, !7, i64 96, !13, i64 108}
!25 = !{!24, !11, i64 36}
!26 = distinct !{!26, !27}
!27 = !{!"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"

%struct.s_vect_elem = type { ptr, i32 }

@.str = external hidden unnamed_addr constant [66 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_sorted_lst(ptr nocapture noundef readonly %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %32
  %indvars.iv = phi i64 [ %indvars.iv.next, %32 ], [ 0, %2 ]
  %.02627 = phi float [ %.0, %32 ], [ -1.000000e+00, %2 ]
  %8 = trunc nuw nsw i64 %indvars.iv to i32
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.1, i32 noundef %8) #2
  %10 = getelementptr inbounds %struct.s_vect_elem, ptr %3, i64 %indvars.iv
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = icmp eq i32 %12, 0
  %14 = load ptr, ptr %10, align 8, !tbaa !14
  br i1 %13, label %15, label %21

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %14, i64 20
  %17 = load float, ptr %16, align 4, !tbaa !15
  %18 = fpext float %17 to double
  %19 = load i32, ptr %14, align 8, !tbaa !19
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.2, double noundef %18, i32 noundef %19) #2
  br label %28

21:                                               ; preds = %.lr.ph
  %22 = getelementptr inbounds i8, ptr %14, i64 24
  %23 = load float, ptr %22, align 8, !tbaa !20
  %24 = fpext float %23 to double
  %25 = getelementptr inbounds i8, ptr %14, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !22
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.3, double noundef %24, i32 noundef %26) #2
  br label %28

28:                                               ; preds = %21, %15
  %.0 = phi float [ %17, %15 ], [ %23, %21 ]
  %29 = fcmp ogt float %.02627, %.0
  br i1 %29, label %30, label %32

30:                                               ; preds = %28
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.4) #2
  br label %32

32:                                               ; preds = %30, %28
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.5) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr %5, align 8, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %32, %2
  ret void
}

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

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 = { 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 = { 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, !7, i64 0}
!6 = !{!"s_vsort", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !10, i64 8}
!13 = !{!"s_vect_elem", !7, i64 0, !10, i64 8}
!14 = !{!13, !7, i64 0}
!15 = !{!16, !17, i64 20}
!16 = !{!"s_atm", !10, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20, !17, i64 24, !17, i64 28, !8, i64 32, !8, i64 37, !8, i64 44, !8, i64 60, !8, i64 76, !8, i64 79, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !17, i64 116, !17, i64 120, !17, i64 124, !17, i64 128, !17, i64 132, !17, i64 136, !17, i64 140, !8, i64 144, !8, i64 145, !17, i64 148, !17, i64 152, !17, i64 156, !17, i64 160, !18, i64 164, !7, i64 168, !10, i64 176}
!17 = !{!"float", !8, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = !{!16, !10, i64 0}
!20 = !{!21, !17, i64 24}
!21 = !{!"s_vvertice", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !17, i64 20, !17, i64 24, !17, i64 28, !17, i64 32, !10, i64 36, !10, i64 40, !8, i64 44, !8, i64 64, !8, i64 96, !17, i64 108}
!22 = !{!21, !10, i64 36}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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