; LLVM IR from bartobri/data-structures-c :: symbol-table/trie (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 { i8, i32 }

@__const.main.keys = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [10 x i8], align 1
  %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 10, ptr %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 @__const.main.keys, i64 10, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %5 = call i64 @time(ptr noundef null) #6
  %6 = trunc i64 %5 to i32
  call void @srand(i32 noundef %6) #6
  call void @STinit()
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %7

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

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

23:                                               ; preds = %10
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !15

26:                                               ; preds = %7
  call void @STsort(ptr noundef @visit)
  %27 = call ptr @STselect(i32 noundef 4)
  store ptr %27, ptr %4, align 8, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %36

30:                                               ; preds = %26
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.anon, ptr %31, i32 0, i32 0
  %33 = load i8, ptr %32, align 4, !tbaa !12
  %34 = zext i8 %33 to i32
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %34)
  br label %38

36:                                               ; preds = %26
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %38

38:                                               ; preds = %36, %30
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %54, %38
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = icmp slt i32 %41, 10
  br i1 %42, label %43, label %57

43:                                               ; preds = %40
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  call void @STdelete(i8 noundef zeroext %47)
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !11
  %52 = zext i8 %51 to i32
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %52)
  br label %54

54:                                               ; preds = %43
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %2, align 4, !tbaa !5
  br label %40, !llvm.loop !17

57:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 10, 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) #2

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) #4

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #4

declare void @STinit() #1

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

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

declare void @STinsert(ptr noundef) #1

declare void @STsort(ptr noundef) #1

declare ptr @STselect(i32 noundef) #1

declare void @STdelete(i8 noundef zeroext) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #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 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !6, i64 4}
!14 = !{!13, !6, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [16 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i64 @time(ptr noundef null) #5
  %2 = trunc i64 %1 to i32
  tail call void @srand(i32 noundef %2) #5
  tail call void @STinit() #5
  %3 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %4 = load i8, ptr @__const.main.keys, align 1, !tbaa !5
  store i8 %4, ptr %3, align 4, !tbaa !8
  %5 = tail call i32 @rand() #5
  %6 = srem i32 %5, 1000
  %7 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %6, ptr %7, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %3) #5
  %8 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %9 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 1), align 1, !tbaa !5
  store i8 %9, ptr %8, align 4, !tbaa !8
  %10 = tail call i32 @rand() #5
  %11 = srem i32 %10, 1000
  %12 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %11, ptr %12, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %8) #5
  %13 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 2), align 1, !tbaa !5
  store i8 %14, ptr %13, align 4, !tbaa !8
  %15 = tail call i32 @rand() #5
  %16 = srem i32 %15, 1000
  %17 = getelementptr inbounds i8, ptr %13, i64 4
  store i32 %16, ptr %17, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %13) #5
  %18 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 3), align 1, !tbaa !5
  store i8 %19, ptr %18, align 4, !tbaa !8
  %20 = tail call i32 @rand() #5
  %21 = srem i32 %20, 1000
  %22 = getelementptr inbounds i8, ptr %18, i64 4
  store i32 %21, ptr %22, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %18) #5
  %23 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %24 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 4), align 1, !tbaa !5
  store i8 %24, ptr %23, align 4, !tbaa !8
  %25 = tail call i32 @rand() #5
  %26 = srem i32 %25, 1000
  %27 = getelementptr inbounds i8, ptr %23, i64 4
  store i32 %26, ptr %27, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %23) #5
  %28 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 5), align 1, !tbaa !5
  store i8 %29, ptr %28, align 4, !tbaa !8
  %30 = tail call i32 @rand() #5
  %31 = srem i32 %30, 1000
  %32 = getelementptr inbounds i8, ptr %28, i64 4
  store i32 %31, ptr %32, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %28) #5
  %33 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 6), align 1, !tbaa !5
  store i8 %34, ptr %33, align 4, !tbaa !8
  %35 = tail call i32 @rand() #5
  %36 = srem i32 %35, 1000
  %37 = getelementptr inbounds i8, ptr %33, i64 4
  store i32 %36, ptr %37, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %33) #5
  %38 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %39 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 7), align 1, !tbaa !5
  store i8 %39, ptr %38, align 4, !tbaa !8
  %40 = tail call i32 @rand() #5
  %41 = srem i32 %40, 1000
  %42 = getelementptr inbounds i8, ptr %38, i64 4
  store i32 %41, ptr %42, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %38) #5
  %43 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %44 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 8), align 1, !tbaa !5
  store i8 %44, ptr %43, align 4, !tbaa !8
  %45 = tail call i32 @rand() #5
  %46 = srem i32 %45, 1000
  %47 = getelementptr inbounds i8, ptr %43, i64 4
  store i32 %46, ptr %47, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %43) #5
  %48 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  %49 = load i8, ptr getelementptr inbounds (i8, ptr @__const.main.keys, i64 9), align 1, !tbaa !5
  store i8 %49, ptr %48, align 4, !tbaa !8
  %50 = tail call i32 @rand() #5
  %51 = srem i32 %50, 1000
  %52 = getelementptr inbounds i8, ptr %48, i64 4
  store i32 %51, ptr %52, align 4, !tbaa !11
  tail call void @STinsert(ptr noundef nonnull %48) #5
  tail call void @STsort(ptr noundef nonnull @visit) #5
  %53 = tail call ptr @STselect(i32 noundef 4) #5
  %.not = icmp eq ptr %53, null
  br i1 %.not, label %58, label %54

54:                                               ; preds = %0
  %55 = load i8, ptr %53, align 4, !tbaa !8
  %56 = zext i8 %55 to i32
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %56)
  br label %60

58:                                               ; preds = %0
  %59 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %60

60:                                               ; preds = %58, %54
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  tail call void @STdelete(i8 noundef zeroext %4) #5
  %62 = zext i8 %4 to i32
  %63 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %62)
  tail call void @STdelete(i8 noundef zeroext %9) #5
  %64 = zext i8 %9 to i32
  %65 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %64)
  tail call void @STdelete(i8 noundef zeroext %14) #5
  %66 = zext i8 %14 to i32
  %67 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %66)
  tail call void @STdelete(i8 noundef zeroext %19) #5
  %68 = zext i8 %19 to i32
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %68)
  tail call void @STdelete(i8 noundef zeroext %24) #5
  %70 = zext i8 %24 to i32
  %71 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %70)
  tail call void @STdelete(i8 noundef zeroext %29) #5
  %72 = zext i8 %29 to i32
  %73 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %72)
  tail call void @STdelete(i8 noundef zeroext %34) #5
  %74 = zext i8 %34 to i32
  %75 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %74)
  tail call void @STdelete(i8 noundef zeroext %39) #5
  %76 = zext i8 %39 to i32
  %77 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %76)
  tail call void @STdelete(i8 noundef zeroext %44) #5
  %78 = zext i8 %44 to i32
  %79 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %78)
  tail call void @STdelete(i8 noundef zeroext %49) #5
  %80 = zext i8 %49 to i32
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %80)
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

declare void @STinit() local_unnamed_addr #3

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

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

declare void @STinsert(ptr noundef) local_unnamed_addr #3

declare void @STsort(ptr noundef) local_unnamed_addr #3

declare ptr @STselect(i32 noundef) local_unnamed_addr #3

declare void @STdelete(i8 noundef zeroext) local_unnamed_addr #3

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" }
attributes #2 = { 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 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"", !6, i64 0, !10, i64 4}
!10 = !{!"int", !6, i64 0}
!11 = !{!9, !10, i64 4}


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