; LLVM IR from fmela/libdict :: src (hashtable2)

; 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.hashtable2_itor = type { ptr, i32 }
%struct.hashtable2 = type { i64, ptr, ptr, ptr, i32 }
%struct.hash_node = type { ptr, ptr, i32 }

; Function Attrs: nounwind uwtable
declare hidden void @remove_node(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hashtable2_itor_remove(ptr noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.hashtable2_itor, ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i1 false, ptr %2, align 1
  br label %50

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.hashtable2_itor, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hashtable2_itor, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds %struct.hashtable2, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hashtable2_itor, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds %struct.hashtable2, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.hashtable2_itor, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.hash_node, ptr %22, i64 %26
  %28 = getelementptr inbounds %struct.hash_node, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.hashtable2_itor, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !12
  %33 = getelementptr inbounds %struct.hashtable2, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !18
  %35 = urem i32 %29, %34
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds %struct.hash_node, ptr %17, i64 %36
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.hashtable2_itor, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = getelementptr inbounds %struct.hashtable2, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashtable2_itor, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds %struct.hash_node, ptr %42, i64 %46
  call void @remove_node(ptr noundef %12, ptr noundef %37, ptr noundef %47)
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.hashtable2_itor, ptr %48, i32 0, i32 1
  store i32 -1, ptr %49, align 8, !tbaa !9
  store i1 true, ptr %2, align 1
  br label %50

50:                                               ; preds = %9, %8
  %51 = load i1, ptr %2, align 1
  ret i1 %51
}

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

!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, !11, i64 8}
!10 = !{!"hashtable2_itor", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"hashtable2", !15, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !11, i64 16}
!17 = !{!"hash_node", !6, i64 0, !6, i64 8, !11, i64 16}
!18 = !{!14, !11, i64 32}


; 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.hash_node = type { ptr, ptr, i32 }

; Function Attrs: nounwind uwtable
declare hidden void @remove_node(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hashtable2_itor_remove(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, -1
  br i1 %4, label %5, label %18

5:                                                ; preds = %1
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = zext nneg i32 %3 to i64
  %10 = getelementptr inbounds %struct.hash_node, ptr %8, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %6, i64 32
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = urem i32 %12, %14
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %struct.hash_node, ptr %8, i64 %16
  tail call void @remove_node(ptr noundef %6, ptr noundef %17, ptr noundef %10)
  store i32 -1, ptr %2, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %1, %5
  ret i1 %4
}

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

!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 = !{!"hashtable2_itor", !7, i64 0, !10, i64 8}
!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 = !{!13, !7, i64 24}
!13 = !{!"hashtable2", !14, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!14 = !{!"long", !8, i64 0}
!15 = !{!16, !10, i64 16}
!16 = !{!"hash_node", !7, i64 0, !7, i64 8, !10, i64 16}
!17 = !{!13, !10, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass