; LLVM IR from intel/x86-simd-sort :: example (main)

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store i64 10, ptr %2, align 8, !tbaa !5
  %6 = call ptr @llvm.stacksave.p0()
  store ptr %6, ptr %3, align 8
  %7 = alloca %struct.Point, i64 10, align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %25, %0
  %9 = load i64, ptr %4, align 8, !tbaa !5
  %10 = icmp ult i64 %9, 10
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %28

12:                                               ; preds = %8
  %13 = call i32 @rand() #5
  %14 = sitofp i32 %13 to float
  %15 = fdiv float %14, 0x41E0000000000000
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Point, ptr %7, i64 %16
  %18 = getelementptr inbounds %struct.Point, ptr %17, i32 0, i32 2
  store float %15, ptr %18, align 8, !tbaa !9
  %19 = call i32 @rand() #5
  %20 = srem i32 %19, 100
  %21 = sext i32 %20 to i64
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Point, ptr %7, i64 %22
  %24 = getelementptr inbounds %struct.Point, ptr %23, i32 0, i32 3
  store i64 %21, ptr %24, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %12
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = add i64 %26, 1
  store i64 %27, ptr %4, align 8, !tbaa !5
  br label %8, !llvm.loop !14

28:                                               ; preds = %11
  call void @object_qsort(ptr noundef %7, i64 noundef 10)
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %40, %28
  %31 = load i64, ptr %5, align 8, !tbaa !5
  %32 = icmp ult i64 %31, 10
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %43

34:                                               ; preds = %30
  %35 = load i64, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Point, ptr %7, i64 %35
  %37 = getelementptr inbounds %struct.Point, ptr %36, i32 0, i32 3
  %38 = load i64, ptr %37, align 8, !tbaa !13
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %38)
  br label %40

40:                                               ; preds = %34
  %41 = load i64, ptr %5, align 8, !tbaa !5
  %42 = add i64 %41, 1
  store i64 %42, ptr %5, align 8, !tbaa !5
  br label %30, !llvm.loop !16

43:                                               ; preds = %33
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  %45 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %45)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %46 = load i32, ptr %1, align 4
  ret i32 %46
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nounwind
declare i32 @rand() #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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 = { nocallback nofree nosync nounwind willreturn }
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 }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"Point", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

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

; Function Attrs: nounwind uwtable
declare dso_local void @object_qsort(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [10 x %struct.Point], align 16
  %2 = tail call i32 @rand() #3
  %3 = sitofp i32 %2 to float
  %4 = fmul float %3, 0x3E00000000000000
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  store float %4, ptr %5, align 8, !tbaa !5
  %6 = tail call i32 @rand() #3
  %7 = srem i32 %6, 100
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 %8, ptr %9, align 16, !tbaa !12
  %10 = tail call i32 @rand() #3
  %11 = sitofp i32 %10 to float
  %12 = fmul float %11, 0x3E00000000000000
  %13 = getelementptr inbounds i8, ptr %1, i64 32
  store float %12, ptr %13, align 16, !tbaa !5
  %14 = tail call i32 @rand() #3
  %15 = srem i32 %14, 100
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 %16, ptr %17, align 8, !tbaa !12
  %18 = tail call i32 @rand() #3
  %19 = sitofp i32 %18 to float
  %20 = fmul float %19, 0x3E00000000000000
  %21 = getelementptr inbounds i8, ptr %1, i64 56
  store float %20, ptr %21, align 8, !tbaa !5
  %22 = tail call i32 @rand() #3
  %23 = srem i32 %22, 100
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %1, i64 64
  store i64 %24, ptr %25, align 16, !tbaa !12
  %26 = tail call i32 @rand() #3
  %27 = sitofp i32 %26 to float
  %28 = fmul float %27, 0x3E00000000000000
  %29 = getelementptr inbounds i8, ptr %1, i64 80
  store float %28, ptr %29, align 16, !tbaa !5
  %30 = tail call i32 @rand() #3
  %31 = srem i32 %30, 100
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %1, i64 88
  store i64 %32, ptr %33, align 8, !tbaa !12
  %34 = tail call i32 @rand() #3
  %35 = sitofp i32 %34 to float
  %36 = fmul float %35, 0x3E00000000000000
  %37 = getelementptr inbounds i8, ptr %1, i64 104
  store float %36, ptr %37, align 8, !tbaa !5
  %38 = tail call i32 @rand() #3
  %39 = srem i32 %38, 100
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %1, i64 112
  store i64 %40, ptr %41, align 16, !tbaa !12
  %42 = tail call i32 @rand() #3
  %43 = sitofp i32 %42 to float
  %44 = fmul float %43, 0x3E00000000000000
  %45 = getelementptr inbounds i8, ptr %1, i64 128
  store float %44, ptr %45, align 16, !tbaa !5
  %46 = tail call i32 @rand() #3
  %47 = srem i32 %46, 100
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %1, i64 136
  store i64 %48, ptr %49, align 8, !tbaa !12
  %50 = tail call i32 @rand() #3
  %51 = sitofp i32 %50 to float
  %52 = fmul float %51, 0x3E00000000000000
  %53 = getelementptr inbounds i8, ptr %1, i64 152
  store float %52, ptr %53, align 8, !tbaa !5
  %54 = tail call i32 @rand() #3
  %55 = srem i32 %54, 100
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %1, i64 160
  store i64 %56, ptr %57, align 16, !tbaa !12
  %58 = tail call i32 @rand() #3
  %59 = sitofp i32 %58 to float
  %60 = fmul float %59, 0x3E00000000000000
  %61 = getelementptr inbounds i8, ptr %1, i64 176
  store float %60, ptr %61, align 16, !tbaa !5
  %62 = tail call i32 @rand() #3
  %63 = srem i32 %62, 100
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %1, i64 184
  store i64 %64, ptr %65, align 8, !tbaa !12
  %66 = tail call i32 @rand() #3
  %67 = sitofp i32 %66 to float
  %68 = fmul float %67, 0x3E00000000000000
  %69 = getelementptr inbounds i8, ptr %1, i64 200
  store float %68, ptr %69, align 8, !tbaa !5
  %70 = tail call i32 @rand() #3
  %71 = srem i32 %70, 100
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i8, ptr %1, i64 208
  store i64 %72, ptr %73, align 16, !tbaa !12
  %74 = tail call i32 @rand() #3
  %75 = sitofp i32 %74 to float
  %76 = fmul float %75, 0x3E00000000000000
  %77 = getelementptr inbounds i8, ptr %1, i64 224
  store float %76, ptr %77, align 16, !tbaa !5
  %78 = tail call i32 @rand() #3
  %79 = srem i32 %78, 100
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i8, ptr %1, i64 232
  store i64 %80, ptr %81, align 8, !tbaa !12
  call void @object_qsort(ptr noundef nonnull %1, i64 noundef 10)
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %83 = load i64, ptr %9, align 16, !tbaa !12
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %83)
  %85 = getelementptr inbounds i8, ptr %1, i64 40
  %86 = load i64, ptr %85, align 8, !tbaa !12
  %87 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %86)
  %88 = getelementptr inbounds i8, ptr %1, i64 64
  %89 = load i64, ptr %88, align 16, !tbaa !12
  %90 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %89)
  %91 = getelementptr inbounds i8, ptr %1, i64 88
  %92 = load i64, ptr %91, align 8, !tbaa !12
  %93 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %92)
  %94 = getelementptr inbounds i8, ptr %1, i64 112
  %95 = load i64, ptr %94, align 16, !tbaa !12
  %96 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %95)
  %97 = getelementptr inbounds i8, ptr %1, i64 136
  %98 = load i64, ptr %97, align 8, !tbaa !12
  %99 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %98)
  %100 = getelementptr inbounds i8, ptr %1, i64 160
  %101 = load i64, ptr %100, align 16, !tbaa !12
  %102 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %101)
  %103 = getelementptr inbounds i8, ptr %1, i64 184
  %104 = load i64, ptr %103, align 8, !tbaa !12
  %105 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %104)
  %106 = getelementptr inbounds i8, ptr %1, i64 208
  %107 = load i64, ptr %106, align 16, !tbaa !12
  %108 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %107)
  %109 = getelementptr inbounds i8, ptr %1, i64 232
  %110 = load i64, ptr %109, align 8, !tbaa !12
  %111 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %110)
  %112 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  ret i32 0
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

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

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 = { 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 = { 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 = { 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, !10, i64 8}
!6 = !{!"Point", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass