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

; 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.slot = type { i8, i32 }
%struct.MyHashSet = type { ptr, i32, i32 }

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

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

; Function Attrs: inlinehint nounwind uwtable
declare dso_local i32 @hash_int(i32 noundef) #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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @myHashSetContains(ptr noundef %0, i32 noundef %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.slot, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.slot, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.MyHashSet, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !11
  store i32 %16, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 -1, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MyHashSet, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %9, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %66, %2
  br label %21

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = call i32 @hash_int(i32 noundef %22)
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = add i32 %24, 1
  store i32 %25, ptr %7, align 4, !tbaa !9
  %26 = add i32 %23, %24
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = urem i32 %26, %27
  store i32 %28, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds %struct.slot, ptr %29, i64 %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %32, i64 8, i1 false), !tbaa.struct !14
  %33 = getelementptr inbounds %struct.slot, ptr %11, i32 0, i32 0
  %34 = load i8, ptr %33, align 4, !tbaa !16
  %35 = zext i8 %34 to i32
  switch i32 %35, label %63 [
    i32 102, label %36
    i32 111, label %37
    i32 100, label %61
  ]

36:                                               ; preds = %21
  store i1 false, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %64

37:                                               ; preds = %21
  %38 = getelementptr inbounds %struct.slot, ptr %11, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !18
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = icmp eq i32 %39, %40
  br i1 %41, label %42, label %60

42:                                               ; preds = %37
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = icmp ne i32 %43, -1
  br i1 %44, label %45, label %59

45:                                               ; preds = %42
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.slot, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.slot, ptr %13, i32 0, i32 0
  store i8 111, ptr %50, align 4, !tbaa !16
  %51 = getelementptr inbounds %struct.slot, ptr %13, i32 0, i32 1
  %52 = getelementptr inbounds %struct.slot, ptr %11, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !18
  store i32 %53, ptr %51, align 4, !tbaa !18
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %13, i64 8, i1 false), !tbaa.struct !14
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds %struct.slot, ptr %54, i64 %56
  %58 = getelementptr inbounds %struct.slot, ptr %57, i32 0, i32 0
  store i8 102, ptr %58, align 4, !tbaa !16
  br label %59

59:                                               ; preds = %45, %42
  store i1 true, ptr %3, align 1
  store i32 1, ptr %12, align 4
  br label %64

60:                                               ; preds = %37
  br label %63

61:                                               ; preds = %21
  %62 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %62, ptr %8, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %61, %60, %21
  store i32 0, ptr %12, align 4
  br label %64

64:                                               ; preds = %63, %59, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %65 = load i32, ptr %12, align 4
  switch i32 %65, label %67 [
    i32 0, label %66
  ]

66:                                               ; preds = %64
  br label %20

67:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %68 = load i1, ptr %3, align 1
  ret i1 %68
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = !{i64 0, i64 1, !15, i64 4, i64 4, !9}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !7, i64 0}
!17 = !{!"", !7, i64 0, !10, i64 4}
!18 = !{!17, !10, i64 4}


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

%struct.slot = type { i8, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @myHashSetContains(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !11
  br label %.outer

.outer:                                           ; preds = %6, %2
  %.021.ph = phi i32 [ -1, %2 ], [ %10, %6 ]
  %.019.ph = phi i32 [ 0, %2 ], [ %8, %6 ]
  br label %6

6:                                                ; preds = %.backedge, %.outer
  %.019 = phi i32 [ %.019.ph, %.outer ], [ %8, %.backedge ]
  %7 = tail call i32 @hash_int(i32 noundef %1)
  %8 = add i32 %.019, 1
  %9 = add i32 %7, %.019
  %10 = urem i32 %9, %4
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds %struct.slot, ptr %5, i64 %11
  %.sroa.02.0.copyload = load i8, ptr %12, align 4, !tbaa !12
  switch i8 %.sroa.02.0.copyload, label %.backedge [
    i8 102, label %.loopexit
    i8 111, label %13
    i8 100, label %.outer
  ]

13:                                               ; preds = %6
  %.sroa.43.0..sroa_idx = getelementptr inbounds i8, ptr %12, i64 4
  %.sroa.43.0.copyload = load i32, ptr %.sroa.43.0..sroa_idx, align 4, !tbaa !13
  %14 = icmp eq i32 %.sroa.43.0.copyload, %1
  br i1 %14, label %15, label %.backedge

.backedge:                                        ; preds = %6, %13
  br label %6

15:                                               ; preds = %13
  %.not = icmp eq i32 %.021.ph, -1
  br i1 %.not, label %.loopexit, label %16

16:                                               ; preds = %15
  %17 = sext i32 %.021.ph to i64
  %18 = getelementptr inbounds %struct.slot, ptr %5, i64 %17
  store i8 111, ptr %18, align 4, !tbaa !12
  %.sroa.21.0..sroa_idx = getelementptr inbounds i8, ptr %18, i64 4
  store i32 %1, ptr %.sroa.21.0..sroa_idx, align 4, !tbaa !13
  store i8 102, ptr %12, align 4, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %6, %16, %15
  %.1.ph = phi i1 [ true, %15 ], [ true, %16 ], [ false, %6 ]
  ret i1 %.1.ph
}

attributes #0 = { inlinehint 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 = { 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" }

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


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