; LLVM IR from Montimage/mmt-security :: test/perf (hash)

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

@entry = external dso_local global [50 x %struct.entry_struct], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @swap(ptr noundef, ptr 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 void @sort() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  store i64 0, ptr %1, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %38, %0
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = icmp ult i64 %4, 50
  br i1 %5, label %6, label %41

6:                                                ; preds = %3
  %7 = load i64, ptr %1, align 8, !tbaa !5
  %8 = add i64 %7, 1
  store i64 %8, ptr %2, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %34, %6
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = icmp ult i64 %10, 50
  br i1 %11, label %12, label %37

12:                                               ; preds = %9
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = load i64, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = icmp ugt i64 %15, %18
  br i1 %19, label %20, label %33

20:                                               ; preds = %12
  %21 = load i64, ptr %1, align 8, !tbaa !5
  %22 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %21
  %23 = getelementptr inbounds %struct.entry_struct, ptr %22, i32 0, i32 0
  %24 = load i64, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.entry_struct, ptr %25, i32 0, i32 0
  call void @swap(ptr noundef %23, ptr noundef %26)
  %27 = load i64, ptr %1, align 8, !tbaa !5
  %28 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.entry_struct, ptr %28, i32 0, i32 1
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.entry_struct, ptr %31, i32 0, i32 1
  call void @swap(ptr noundef %29, ptr noundef %32)
  br label %33

33:                                               ; preds = %20, %12
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = add i64 %35, 1
  store i64 %36, ptr %2, align 8, !tbaa !5
  br label %9, !llvm.loop !9

37:                                               ; preds = %9
  br label %38

38:                                               ; preds = %37
  %39 = load i64, ptr %1, align 8, !tbaa !5
  %40 = add i64 %39, 1
  store i64 %40, ptr %1, align 8, !tbaa !5
  br label %3, !llvm.loop !11

41:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret void
}

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !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"

%struct.entry_struct = type { i32, i32 }

@entry = external dso_local global [50 x %struct.entry_struct], align 16

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

; Function Attrs: nounwind uwtable
define dso_local void @sort() local_unnamed_addr #0 {
  br label %1

.loopexit:                                        ; preds = %13, %1
  %exitcond.not = icmp eq i64 %2, 50
  br i1 %exitcond.not, label %16, label %1, !llvm.loop !5

1:                                                ; preds = %0, %.loopexit
  %.01113 = phi i64 [ 0, %0 ], [ %2, %.loopexit ]
  %2 = add nuw nsw i64 %.01113, 1
  %3 = icmp ult i64 %.01113, 49
  br i1 %3, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %1
  %4 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %.01113
  %5 = getelementptr inbounds i8, ptr %4, i64 4
  br label %6

6:                                                ; preds = %.lr.ph, %13
  %.012 = phi i64 [ %2, %.lr.ph ], [ %14, %13 ]
  %7 = load i64, ptr %4, align 8, !tbaa !7
  %8 = getelementptr inbounds [50 x %struct.entry_struct], ptr @entry, i64 0, i64 %.012
  %9 = load i64, ptr %8, align 8, !tbaa !7
  %10 = icmp ugt i64 %7, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %6
  tail call void @swap(ptr noundef nonnull %4, ptr noundef nonnull %8)
  %12 = getelementptr inbounds i8, ptr %8, i64 4
  tail call void @swap(ptr noundef nonnull %5, ptr noundef nonnull %12)
  br label %13

13:                                               ; preds = %6, %11
  %14 = add nuw nsw i64 %.012, 1
  %15 = icmp ult i64 %.012, 49
  br i1 %15, label %6, label %.loopexit, !llvm.loop !11

16:                                               ; preds = %.loopexit
  ret void
}

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}


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