; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/vorbis-src/vq (vqgen)

; 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.vqgen = type { i32, i32, i32, i32, i32, float, i32, ptr, i64, i64, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@sortit = external hidden global i32, align 4
@sortsize = external hidden global i32, align 4
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [69 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: inlinehint nounwind uwtable
declare hidden ptr @_point(ptr noundef, i64 noundef) #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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare void @spinnit(ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @vqgen_sortmesh(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  store i32 0, ptr @sortit, align 4, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.vqgen, ptr %5, i32 0, i32 5
  %7 = load float, ptr %6, align 4, !tbaa !11
  %8 = fcmp ogt float %7, 0.000000e+00
  br i1 %8, label %9, label %88

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 1, ptr %4, align 8, !tbaa !15
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.vqgen, ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 4, !tbaa !16
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.vqgen, ptr %13, i32 0, i32 4
  %15 = load i32, ptr %14, align 8, !tbaa !17
  %16 = add nsw i32 %12, %15
  %17 = sext i32 %16 to i64
  %18 = mul i64 %17, 4
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr @sortsize, align 4, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.vqgen, ptr %20, i32 0, i32 7
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.vqgen, ptr %23, i32 0, i32 8
  %25 = load i64, ptr %24, align 8, !tbaa !19
  %26 = load i32, ptr @sortsize, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  call void @qsort(ptr noundef %22, i64 noundef %25, i64 noundef %27, ptr noundef @meshcomp)
  store i64 1, ptr %3, align 8, !tbaa !15
  br label %28

28:                                               ; preds = %69, %9
  %29 = load i64, ptr %3, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.vqgen, ptr %30, i32 0, i32 8
  %32 = load i64, ptr %31, align 8, !tbaa !19
  %33 = icmp slt i64 %29, %32
  br i1 %33, label %34, label %72

34:                                               ; preds = %28
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load i64, ptr %3, align 8, !tbaa !15
  %37 = call ptr @_point(ptr noundef %35, i64 noundef %36)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = load i64, ptr %3, align 8, !tbaa !15
  %40 = sub nsw i64 %39, 1
  %41 = call ptr @_point(ptr noundef %38, i64 noundef %40)
  %42 = load i32, ptr @sortsize, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call i32 @memcmp(ptr noundef %37, ptr noundef %41, i64 noundef %43) #8
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %62

46:                                               ; preds = %34
  %47 = load i64, ptr %3, align 8, !tbaa !15
  %48 = load i64, ptr %4, align 8, !tbaa !15
  %49 = icmp sgt i64 %47, %48
  br i1 %49, label %50, label %59

50:                                               ; preds = %46
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = load i64, ptr %4, align 8, !tbaa !15
  %53 = call ptr @_point(ptr noundef %51, i64 noundef %52)
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = load i64, ptr %3, align 8, !tbaa !15
  %56 = call ptr @_point(ptr noundef %54, i64 noundef %55)
  %57 = load i32, ptr @sortsize, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %56, i64 %58, i1 false)
  br label %59

59:                                               ; preds = %50, %46
  %60 = load i64, ptr %4, align 8, !tbaa !15
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %4, align 8, !tbaa !15
  br label %62

62:                                               ; preds = %59, %34
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.vqgen, ptr %63, i32 0, i32 8
  %65 = load i64, ptr %64, align 8, !tbaa !19
  %66 = load i64, ptr %3, align 8, !tbaa !15
  %67 = sub nsw i64 %65, %66
  %68 = trunc i64 %67 to i32
  call void @spinnit(ptr noundef @.str.5, i32 noundef %68)
  br label %69

69:                                               ; preds = %62
  %70 = load i64, ptr %3, align 8, !tbaa !15
  %71 = add nsw i64 %70, 1
  store i64 %71, ptr %3, align 8, !tbaa !15
  br label %28, !llvm.loop !20

72:                                               ; preds = %28
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = load i64, ptr %4, align 8, !tbaa !15
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.vqgen, ptr %75, i32 0, i32 8
  %77 = load i64, ptr %76, align 8, !tbaa !19
  %78 = load i64, ptr %4, align 8, !tbaa !15
  %79 = mul nsw i64 %78, 100
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.vqgen, ptr %80, i32 0, i32 8
  %82 = load i64, ptr %81, align 8, !tbaa !19
  %83 = sdiv i64 %79, %82
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.6, i64 noundef %74, i64 noundef %77, i64 noundef %83) #7
  %85 = load i64, ptr %4, align 8, !tbaa !15
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.vqgen, ptr %86, i32 0, i32 8
  store i64 %85, ptr %87, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %88

88:                                               ; preds = %72, %1
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.vqgen, ptr %89, i32 0, i32 1
  store i32 1, ptr %90, align 4, !tbaa !22
  ret void
}

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @meshcomp(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #6

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

!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 = !{!12, !13, i64 20}
!12 = !{!"vqgen", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20, !10, i64 24, !6, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !14, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}
!13 = !{!"float", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !6, i64 32}
!19 = !{!12, !14, i64 40}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !10, i64 4}


; 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
@sortit = external hidden local_unnamed_addr global i32, align 4
@sortsize = external hidden local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [69 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @_point(ptr noundef, i64 noundef) local_unnamed_addr #0

; 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) #1

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

declare void @spinnit(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @vqgen_sortmesh(ptr noundef %0) local_unnamed_addr #4 {
  store i32 0, ptr @sortit, align 4, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 20
  %3 = load float, ptr %2, align 4, !tbaa !9
  %4 = fcmp ogt float %3, 0.000000e+00
  br i1 %4, label %5, label %44

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !15
  %10 = add nsw i32 %9, %7
  %11 = shl i32 %10, 2
  store i32 %11, ptr @sortsize, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load i64, ptr %14, align 8, !tbaa !17
  %16 = sext i32 %11 to i64
  tail call void @qsort(ptr noundef %13, i64 noundef %15, i64 noundef %16, ptr noundef nonnull @meshcomp) #7
  %17 = load i64, ptr %14, align 8, !tbaa !17
  %18 = icmp sgt i64 %17, 1
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5, %33
  %.031 = phi i64 [ %.1, %33 ], [ 1, %5 ]
  %.02729 = phi i64 [ %37, %33 ], [ 1, %5 ]
  %19 = tail call ptr @_point(ptr noundef nonnull %0, i64 noundef %.02729)
  %20 = add nsw i64 %.02729, -1
  %21 = tail call ptr @_point(ptr noundef nonnull %0, i64 noundef %20)
  %22 = load i32, ptr @sortsize, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %bcmp = tail call i32 @bcmp(ptr %19, ptr %21, i64 %23)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %33, label %24

24:                                               ; preds = %.lr.ph
  %25 = icmp sgt i64 %.02729, %.031
  br i1 %25, label %26, label %31

26:                                               ; preds = %24
  %27 = tail call ptr @_point(ptr noundef nonnull %0, i64 noundef %.031)
  %28 = tail call ptr @_point(ptr noundef nonnull %0, i64 noundef %.02729)
  %29 = load i32, ptr @sortsize, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %28, i64 %30, i1 false)
  br label %31

31:                                               ; preds = %26, %24
  %32 = add nsw i64 %.031, 1
  br label %33

33:                                               ; preds = %31, %.lr.ph
  %.1 = phi i64 [ %32, %31 ], [ %.031, %.lr.ph ]
  %34 = load i64, ptr %14, align 8, !tbaa !17
  %35 = sub nsw i64 %34, %.02729
  %36 = trunc i64 %35 to i32
  tail call void @spinnit(ptr noundef nonnull @.str.5, i32 noundef %36) #7
  %37 = add nuw nsw i64 %.02729, 1
  %38 = load i64, ptr %14, align 8, !tbaa !17
  %39 = icmp slt i64 %37, %38
  br i1 %39, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %33, %5
  %.0.lcssa = phi i64 [ 1, %5 ], [ %.1, %33 ]
  %.lcssa = phi i64 [ %17, %5 ], [ %38, %33 ]
  %40 = load ptr, ptr @stderr, align 8, !tbaa !20
  %41 = mul nsw i64 %.0.lcssa, 100
  %42 = sdiv i64 %41, %.lcssa
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.6, i64 noundef %.0.lcssa, i64 noundef %.lcssa, i64 noundef %42) #8
  store i64 %.0.lcssa, ptr %14, align 8, !tbaa !17
  br label %44

44:                                               ; preds = %._crit_edge, %1
  %45 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1, ptr %45, align 4, !tbaa !21
  ret void
}

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden i32 @meshcomp(ptr noundef, ptr noundef) #4

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6

attributes #0 = { inlinehint 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 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 = { "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 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 #5 = { nofree "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 #6 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nounwind }
attributes #8 = { cold 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, !11, i64 20}
!10 = !{!"vqgen", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !11, i64 20, !6, i64 24, !12, i64 32, !13, i64 40, !13, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !13, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112}
!11 = !{!"float", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 12}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !12, i64 32}
!17 = !{!10, !13, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !12, i64 0}
!21 = !{!10, !6, i64 4}


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