; 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.5 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.Table_remove = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

13:                                               ; preds = %2
  br label %15

14:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 141, ptr noundef @__PRETTY_FUNCTION__.Table_remove) #4
  unreachable

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

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 142, ptr noundef @__PRETTY_FUNCTION__.Table_remove) #4
  unreachable

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

36:                                               ; preds = %73, %20
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %77

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

51:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  store ptr %53, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.binding, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  store ptr %57, ptr %9, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.binding, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %60, ptr %61, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %62) #5
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.table, ptr %63, i32 0, i32 4
  %65 = load i32, ptr %64, align 4, !tbaa !20
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr %64, align 4, !tbaa !20
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.table, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 8, !tbaa !21
  %70 = add i32 %69, 1
  store i32 %70, ptr %68, align 8, !tbaa !21
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %71, ptr %3, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %78

72:                                               ; preds = %40
  br label %73

73:                                               ; preds = %72
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.binding, ptr %75, i32 0, i32 0
  store ptr %76, ptr %6, align 8, !tbaa !5
  br label %36, !llvm.loop !22

77:                                               ; preds = %36
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %78

78:                                               ; preds = %77, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %79 = load ptr, ptr %3, align 8
  ret ptr %79
}

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

!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 16}
!19 = !{!17, !6, i64 0}
!20 = !{!10, !11, i64 28}
!21 = !{!10, !11, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.Table_remove = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 141, ptr noundef nonnull @__PRETTY_FUNCTION__.Table_remove) #3
  unreachable

4:                                                ; preds = %2
  %.not24 = icmp eq ptr %1, null
  br i1 %.not24, label %5, label %6

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

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call i32 %8(ptr noundef nonnull %1) #4
  %10 = load i32, ptr %0, align 8, !tbaa !11
  %11 = urem i32 %9, %10
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = zext i32 %11 to i64
  %15 = getelementptr inbounds ptr, ptr %13, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %.not2527 = icmp eq ptr %16, null
  br i1 %.not2527, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  br label %18

18:                                               ; preds = %.lr.ph, %33
  %19 = phi ptr [ %16, %.lr.ph ], [ %34, %33 ]
  %.02028 = phi ptr [ %15, %.lr.ph ], [ %25, %33 ]
  %20 = load ptr, ptr %17, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %19, 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
  %25 = load ptr, ptr %.02028, align 8, !tbaa !13
  br i1 %24, label %26, label %33

26:                                               ; preds = %18
  %27 = getelementptr inbounds i8, ptr %25, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = load ptr, ptr %25, align 8, !tbaa !18
  store ptr %29, ptr %.02028, align 8, !tbaa !13
  tail call void @free(ptr noundef %25) #4
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %31 = load <2 x i32>, ptr %30, align 8, !tbaa !19
  %32 = add <2 x i32> %31, <i32 1, i32 -1>
  store <2 x i32> %32, ptr %30, align 8, !tbaa !19
  br label %.loopexit

33:                                               ; preds = %18
  %34 = load ptr, ptr %25, align 8, !tbaa !13
  %.not25 = icmp eq ptr %34, null
  br i1 %.not25, label %.loopexit, label %18, !llvm.loop !20

.loopexit:                                        ; preds = %33, %6, %26
  %.0 = phi ptr [ %28, %26 ], [ null, %6 ], [ null, %33 ]
  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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 }

!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 = !{!16, !10, i64 16}
!18 = !{!16, !10, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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