; LLVM IR from Montimage/mmt-security :: test/hoa (simple_hash_table)

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

@hashArray = external dso_local global [10 x ptr], align 16
@.str = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @hashCode(i32 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 @insert(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.DataItem, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %11, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.DataItem, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !13
  store i32 %14, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %15 = load i32, ptr %5, align 4, !tbaa !12
  %16 = call i32 @hashCode(i32 noundef %15)
  store i32 %16, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %17

17:                                               ; preds = %32, %1
  %18 = load i32, ptr %6, align 4, !tbaa !12
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %35

23:                                               ; preds = %17
  %24 = load i32, ptr %6, align 4, !tbaa !12
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %6, align 4, !tbaa !12
  %26 = load i32, ptr %7, align 4, !tbaa !12
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %7, align 4, !tbaa !12
  %28 = load i32, ptr %7, align 4, !tbaa !12
  %29 = icmp sgt i32 %28, 10
  br i1 %29, label %30, label %32

30:                                               ; preds = %23
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %40

32:                                               ; preds = %23
  %33 = load i32, ptr %6, align 4, !tbaa !12
  %34 = srem i32 %33, 10
  store i32 %34, ptr %6, align 4, !tbaa !12
  br label %17, !llvm.loop !14

35:                                               ; preds = %17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %38
  store ptr %36, ptr %39, align 8, !tbaa !5
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %40

40:                                               ; preds = %35, %30
  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 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %41 = load i32, ptr %2, align 4
  ret i32 %41
}

declare i32 @printf(ptr noundef, ...) #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 = { "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, !11, i64 0}
!10 = !{!"DataItem", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@hashArray = external dso_local local_unnamed_addr global [10 x ptr], align 16
@.str = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @hashCode(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @insert(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = tail call i32 @hashCode(i32 noundef %3)
  %.fr40 = freeze i32 %4
  %5 = sext i32 %.fr40 to i64
  %6 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %5
  %7 = load ptr, ptr %6, align 8, !tbaa !10
  %.not15 = icmp eq ptr %7, null
  br i1 %.not15, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %8 = add i32 %.fr40, 1
  %9 = srem i32 %8, 10
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !10
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %._crit_edge, label %.lr.ph.1, !llvm.loop !12

13:                                               ; preds = %.lr.ph.9
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %54

.lr.ph.1:                                         ; preds = %.lr.ph.preheader
  %15 = trunc nsw i32 %9 to i8
  %.lhs.trunc = add nsw i8 %15, 1
  %16 = srem i8 %.lhs.trunc, 10
  %17 = sext i8 %16 to i64
  %18 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !10
  %.not.1 = icmp eq ptr %19, null
  br i1 %.not.1, label %._crit_edge, label %.lr.ph.2, !llvm.loop !12

.lr.ph.2:                                         ; preds = %.lr.ph.1
  %narrow = add nsw i8 %16, 1
  %20 = srem i8 %narrow, 10
  %21 = sext i8 %20 to i64
  %22 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !10
  %.not.2 = icmp eq ptr %23, null
  br i1 %.not.2, label %._crit_edge, label %.lr.ph.3, !llvm.loop !12

.lr.ph.3:                                         ; preds = %.lr.ph.2
  %narrow32 = add nsw i8 %20, 1
  %24 = srem i8 %narrow32, 10
  %25 = sext i8 %24 to i64
  %26 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !10
  %.not.3 = icmp eq ptr %27, null
  br i1 %.not.3, label %._crit_edge, label %.lr.ph.4, !llvm.loop !12

.lr.ph.4:                                         ; preds = %.lr.ph.3
  %narrow33 = add nsw i8 %24, 1
  %28 = srem i8 %narrow33, 10
  %29 = sext i8 %28 to i64
  %30 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !10
  %.not.4 = icmp eq ptr %31, null
  br i1 %.not.4, label %._crit_edge, label %.lr.ph.5, !llvm.loop !12

.lr.ph.5:                                         ; preds = %.lr.ph.4
  %narrow34 = add nsw i8 %28, 1
  %32 = srem i8 %narrow34, 10
  %33 = sext i8 %32 to i64
  %34 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !10
  %.not.5 = icmp eq ptr %35, null
  br i1 %.not.5, label %._crit_edge, label %.lr.ph.6, !llvm.loop !12

.lr.ph.6:                                         ; preds = %.lr.ph.5
  %narrow35 = add nsw i8 %32, 1
  %36 = srem i8 %narrow35, 10
  %37 = sext i8 %36 to i64
  %38 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !10
  %.not.6 = icmp eq ptr %39, null
  br i1 %.not.6, label %._crit_edge, label %.lr.ph.7, !llvm.loop !12

.lr.ph.7:                                         ; preds = %.lr.ph.6
  %narrow36 = add nsw i8 %36, 1
  %40 = srem i8 %narrow36, 10
  %41 = sext i8 %40 to i64
  %42 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  %.not.7 = icmp eq ptr %43, null
  br i1 %.not.7, label %._crit_edge, label %.lr.ph.8, !llvm.loop !12

.lr.ph.8:                                         ; preds = %.lr.ph.7
  %narrow37 = add nsw i8 %40, 1
  %44 = srem i8 %narrow37, 10
  %45 = sext i8 %44 to i64
  %46 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !10
  %.not.8 = icmp eq ptr %47, null
  br i1 %.not.8, label %._crit_edge, label %.lr.ph.9, !llvm.loop !12

.lr.ph.9:                                         ; preds = %.lr.ph.8
  %narrow38 = add nsw i8 %44, 1
  %48 = sext i8 %narrow38 to i32
  %.urem = add nsw i32 %48, -10
  %.cmp = icmp ult i8 %narrow38, 10
  %49 = select i1 %.cmp, i32 %48, i32 %.urem
  %50 = zext nneg i32 %49 to i64
  %51 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !10
  %.not.9 = icmp eq ptr %52, null
  br i1 %.not.9, label %._crit_edge, label %13, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph.preheader, %.lr.ph.1, %.lr.ph.2, %.lr.ph.3, %.lr.ph.4, %.lr.ph.5, %.lr.ph.6, %.lr.ph.7, %.lr.ph.8, %.lr.ph.9, %1
  %.lcssa14 = phi i64 [ %5, %1 ], [ %10, %.lr.ph.preheader ], [ %17, %.lr.ph.1 ], [ %21, %.lr.ph.2 ], [ %25, %.lr.ph.3 ], [ %29, %.lr.ph.4 ], [ %33, %.lr.ph.5 ], [ %37, %.lr.ph.6 ], [ %41, %.lr.ph.7 ], [ %45, %.lr.ph.8 ], [ %50, %.lr.ph.9 ]
  %53 = getelementptr inbounds [10 x ptr], ptr @hashArray, i64 0, i64 %.lcssa14
  store ptr %0, ptr %53, align 8, !tbaa !10
  br label %54

54:                                               ; preds = %._crit_edge, %13
  %.011 = phi i32 [ 0, %13 ], [ 1, %._crit_edge ]
  ret i32 %.011
}

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

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

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


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