; LLVM IR from bartobri/data-structures-c :: symbol-table/extendable-hashing (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.anon = type { i32, i32 }

@__const.main.keys = external hidden unnamed_addr constant [9 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [9 x i32], align 16
  %4 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 36, ptr %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.main.keys, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @STinit()
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %21, %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 9
  br i1 %7, label %8, label %24

8:                                                ; preds = %5
  %9 = call noalias ptr @malloc(i64 noundef 8) #7
  store ptr %9, ptr %4, align 8, !tbaa !9
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [9 x i32], ptr %3, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 0
  store i32 %13, ptr %15, align 4, !tbaa !11
  %16 = call i32 @rand() #6
  %17 = srem i32 %16, 1000
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.anon, ptr %18, i32 0, i32 1
  store i32 %17, ptr %19, align 4, !tbaa !13
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  call void @STinsert(ptr noundef %20)
  br label %21

21:                                               ; preds = %8
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %5, !llvm.loop !14

24:                                               ; preds = %5
  call void @STdraw()
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 36, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @STinit() #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

declare void @STinsert(ptr noundef) #3

declare void @STdraw() #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 allocsize(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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, 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"

@__const.main.keys = external hidden unnamed_addr constant [9 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @STinit() #4
  %1 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %2 = load i32, ptr @__const.main.keys, align 16, !tbaa !5
  store i32 %2, ptr %1, align 4, !tbaa !9
  %3 = tail call i32 @rand() #4
  %4 = srem i32 %3, 1000
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %4, ptr %5, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %1) #4
  %6 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 4), align 4, !tbaa !5
  store i32 %7, ptr %6, align 4, !tbaa !9
  %8 = tail call i32 @rand() #4
  %9 = srem i32 %8, 1000
  %10 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 %9, ptr %10, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %6) #4
  %11 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 8), align 8, !tbaa !5
  store i32 %12, ptr %11, align 4, !tbaa !9
  %13 = tail call i32 @rand() #4
  %14 = srem i32 %13, 1000
  %15 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %14, ptr %15, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %11) #4
  %16 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 12), align 4, !tbaa !5
  store i32 %17, ptr %16, align 4, !tbaa !9
  %18 = tail call i32 @rand() #4
  %19 = srem i32 %18, 1000
  %20 = getelementptr inbounds i8, ptr %16, i64 4
  store i32 %19, ptr %20, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %16) #4
  %21 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 16), align 16, !tbaa !5
  store i32 %22, ptr %21, align 4, !tbaa !9
  %23 = tail call i32 @rand() #4
  %24 = srem i32 %23, 1000
  %25 = getelementptr inbounds i8, ptr %21, i64 4
  store i32 %24, ptr %25, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %21) #4
  %26 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 20), align 4, !tbaa !5
  store i32 %27, ptr %26, align 4, !tbaa !9
  %28 = tail call i32 @rand() #4
  %29 = srem i32 %28, 1000
  %30 = getelementptr inbounds i8, ptr %26, i64 4
  store i32 %29, ptr %30, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %26) #4
  %31 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 24), align 8, !tbaa !5
  store i32 %32, ptr %31, align 4, !tbaa !9
  %33 = tail call i32 @rand() #4
  %34 = srem i32 %33, 1000
  %35 = getelementptr inbounds i8, ptr %31, i64 4
  store i32 %34, ptr %35, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %31) #4
  %36 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 28), align 4, !tbaa !5
  store i32 %37, ptr %36, align 4, !tbaa !9
  %38 = tail call i32 @rand() #4
  %39 = srem i32 %38, 1000
  %40 = getelementptr inbounds i8, ptr %36, i64 4
  store i32 %39, ptr %40, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %36) #4
  %41 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 32), align 16, !tbaa !5
  store i32 %42, ptr %41, align 4, !tbaa !9
  %43 = tail call i32 @rand() #4
  %44 = srem i32 %43, 1000
  %45 = getelementptr inbounds i8, ptr %41, i64 4
  store i32 %44, ptr %45, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %41) #4
  tail call void @STdraw() #4
  ret i32 0
}

declare void @STinit() local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

declare void @STinsert(ptr noundef) local_unnamed_addr #1

declare void @STdraw() 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 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 }
attributes #5 = { nounwind allocsize(0) }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}


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