; LLVM IR from DimitrisJim/leetcode_solutions :: C/Algorithms/Support (dict)

; 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.table = type { i32, ptr, ptr, i32, i32, ptr }
%struct.binding = type { ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__.Table_put = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Table_put(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 98, ptr noundef @__PRETTY_FUNCTION__.Table_put) #4
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  br label %19

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 99, ptr noundef @__PRETTY_FUNCTION__.Table_put) #4
  unreachable

19:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.table, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 %22(ptr noundef %23)
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.table, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !12
  %28 = urem i32 %24, %27
  store i32 %28, ptr %8, align 4, !tbaa !13
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.table, ptr %29, i32 0, i32 5
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = load i32, ptr %8, align 4, !tbaa !13
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds ptr, ptr %31, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  store ptr %35, ptr %7, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %51, %19
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %55

39:                                               ; preds = %36
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.table, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.binding, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = call i32 %42(ptr noundef %43, ptr noundef %46)
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %39
  br label %55

50:                                               ; preds = %39
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.binding, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !18
  store ptr %54, ptr %7, align 8, !tbaa !5
  br label %36, !llvm.loop !19

55:                                               ; preds = %49, %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %86

58:                                               ; preds = %55
  %59 = call noalias ptr @malloc(i64 noundef 24) #6
  store ptr %59, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.binding, ptr %61, i32 0, i32 2
  store ptr %60, ptr %62, align 8, !tbaa !21
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.binding, ptr %64, i32 0, i32 1
  store ptr %63, ptr %65, align 8, !tbaa !16
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.table, ptr %66, i32 0, i32 5
  %68 = load ptr, ptr %67, align 8, !tbaa !14
  %69 = load i32, ptr %8, align 4, !tbaa !13
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds ptr, ptr %68, i64 %70
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.binding, ptr %73, i32 0, i32 0
  store ptr %72, ptr %74, align 8, !tbaa !18
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.table, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %77, align 8, !tbaa !14
  %79 = load i32, ptr %8, align 4, !tbaa !13
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %78, i64 %80
  store ptr %75, ptr %81, align 8, !tbaa !5
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.table, ptr %82, i32 0, i32 4
  %84 = load i32, ptr %83, align 4, !tbaa !22
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %83, align 4, !tbaa !22
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %90

86:                                               ; preds = %55
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.binding, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  store ptr %89, ptr %9, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %86, %58
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.binding, ptr %92, i32 0, i32 2
  store ptr %91, ptr %93, align 8, !tbaa !21
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.table, ptr %94, i32 0, i32 3
  %96 = load i32, ptr %95, align 8, !tbaa !23
  %97 = add i32 %96, 1
  store i32 %97, ptr %95, align 8, !tbaa !23
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret ptr %98
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 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 #3 = { 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 #4 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"table", !11, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 32}
!15 = !{!10, !6, i64 8}
!16 = !{!17, !6, i64 8}
!17 = !{!"binding", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!17, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !6, i64 16}
!22 = !{!10, !11, i64 28}
!23 = !{!10, !11, i64 24}


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

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__.Table_put = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Table_put(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 98, ptr noundef nonnull @__PRETTY_FUNCTION__.Table_put) #3
  unreachable

5:                                                ; preds = %3
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 99, ptr noundef nonnull @__PRETTY_FUNCTION__.Table_put) #3
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call i32 %9(ptr noundef nonnull %1) #4
  %11 = load i32, ptr %0, align 8, !tbaa !11
  %12 = urem i32 %10, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = zext i32 %12 to i64
  %16 = getelementptr inbounds ptr, ptr %14, i64 %15
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  br label %18

18:                                               ; preds = %19, %7
  %.028.in = phi ptr [ %16, %7 ], [ %.028, %19 ]
  %.028 = load ptr, ptr %.028.in, align 8, !tbaa !13
  %cond = icmp eq ptr %.028, null
  br i1 %cond, label %25, label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %17, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %.028, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = tail call i32 %20(ptr noundef nonnull %1, ptr noundef %22) #4
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %35, label %18, !llvm.loop !17

25:                                               ; preds = %18
  %26 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #5
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr %2, ptr %27, align 8, !tbaa !19
  %28 = getelementptr inbounds i8, ptr %26, i64 8
  store ptr %1, ptr %28, align 8, !tbaa !15
  %29 = load ptr, ptr %13, align 8, !tbaa !12
  %30 = getelementptr inbounds ptr, ptr %29, i64 %15
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  store ptr %31, ptr %26, align 8, !tbaa !20
  store ptr %26, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds i8, ptr %0, i64 28
  %33 = load i32, ptr %32, align 4, !tbaa !21
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !21
  br label %38

35:                                               ; preds = %19
  %36 = getelementptr inbounds i8, ptr %.028, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  br label %38

38:                                               ; preds = %35, %25
  %.1 = phi ptr [ %26, %25 ], [ %.028, %35 ]
  %.0 = phi ptr [ null, %25 ], [ %37, %35 ]
  %39 = getelementptr inbounds i8, ptr %.1, i64 16
  store ptr %2, ptr %39, align 8, !tbaa !19
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load i32, ptr %40, align 8, !tbaa !22
  %42 = add i32 %41, 1
  store i32 %42, ptr %40, align 8, !tbaa !22
  ret ptr %.0
}

attributes #0 = { noreturn 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 #1 = { 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 #2 = { 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 #3 = { noreturn nounwind }
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, !10, i64 16}
!6 = !{!"table", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 32}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !10, i64 8}
!15 = !{!16, !10, i64 8}
!16 = !{!"binding", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!16, !10, i64 16}
!20 = !{!16, !10, i64 0}
!21 = !{!6, !7, i64 28}
!22 = !{!6, !7, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass