; LLVM IR from Softmotions/iowow :: src/utils (iwhmap)

; 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.iwhmap = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8 }
%struct.bucket_t = type { ptr, i32, i32 }
%struct.entry = type { ptr, ptr, ptr, 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: nounwind uwtable
declare hidden ptr @_entry_find(ptr noundef, ptr noundef, i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @_entry_add(ptr noundef, ptr noundef, i32 noundef) #1

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: nounwind uwtable
define dso_local i64 @iwhmap_rename(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, 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
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.iwhmap, ptr %13, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call i32 %15(ptr noundef %16)
  store i32 %17, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !13
  %21 = call ptr @_entry_find(ptr noundef %18, ptr noundef %19, i32 noundef %20)
  store ptr %21, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.iwhmap, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load i32, ptr %8, align 4, !tbaa !13
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.iwhmap, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = and i32 %25, %28
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %struct.bucket_t, ptr %24, i64 %30
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %93

34:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.entry, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  store ptr %37, ptr %11, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.entry, ptr %38, i32 0, i32 1
  store ptr null, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_entry_remove(ptr noundef %40, ptr noundef %41, ptr noundef %42)
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.iwhmap, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i32 %45(ptr noundef %46)
  store i32 %47, ptr %8, align 4, !tbaa !13
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load i32, ptr %8, align 4, !tbaa !13
  %51 = call ptr @_entry_add(ptr noundef %48, ptr noundef %49, i32 noundef %50)
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %58, label %54

54:                                               ; preds = %34
  %55 = call ptr @__errno_location() #5
  %56 = load i32, ptr %55, align 4, !tbaa !13
  %57 = call i64 @iwrc_set_errno(i64 noundef 70001, i32 noundef %56)
  store i64 %57, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %90

58:                                               ; preds = %34
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.iwhmap, ptr %59, i32 0, i32 5
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.iwhmap, ptr %62, i32 0, i32 10
  %64 = load i8, ptr %63, align 8, !tbaa !19, !range !20, !noundef !21
  %65 = trunc i8 %64 to i1
  br i1 %65, label %66, label %67

66:                                               ; preds = %58
  br label %71

67:                                               ; preds = %58
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.entry, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !22
  br label %71

71:                                               ; preds = %67, %66
  %72 = phi ptr [ null, %66 ], [ %70, %67 ]
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.entry, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  call void %61(ptr noundef %72, ptr noundef %75)
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.entry, ptr %77, i32 0, i32 0
  store ptr %76, ptr %78, align 8, !tbaa !22
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.entry, ptr %80, i32 0, i32 1
  store ptr %79, ptr %81, align 8, !tbaa !16
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.iwhmap, ptr %82, i32 0, i32 8
  %84 = load ptr, ptr %83, align 8, !tbaa !23
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %89

86:                                               ; preds = %71
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_lru_entry_update(ptr noundef %87, ptr noundef %88)
  br label %89

89:                                               ; preds = %86, %71
  store i32 0, ptr %12, align 4
  br label %90

90:                                               ; preds = %89, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %91 = load i32, ptr %12, align 4
  switch i32 %91, label %94 [
    i32 0, label %92
  ]

92:                                               ; preds = %90
  br label %93

93:                                               ; preds = %92, %3
  store i64 0, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %94

94:                                               ; preds = %93, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %95 = load i64, ptr %4, align 8
  ret i64 %95
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { "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 willreturn memory(none) "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 }
attributes #5 = { nounwind willreturn memory(none) }

!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 24}
!10 = !{!"iwhmap", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !11, i64 4}
!16 = !{!17, !6, i64 8}
!17 = !{!"entry", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!18 = !{!10, !6, i64 32}
!19 = !{!10, !12, i64 72}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!17, !6, i64 0}
!23 = !{!10, !6, i64 56}


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

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

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

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

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

declare i64 @iwrc_set_errno(i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @iwhmap_rename(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call i32 %5(ptr noundef %1) #3
  %7 = tail call ptr @_entry_find(ptr noundef %0, ptr noundef %1, i32 noundef %6)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %.thread, label %8

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = and i32 %12, %6
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds %struct.bucket_t, ptr %10, i64 %14
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr null, ptr %16, align 8, !tbaa !14
  tail call void @_entry_remove(ptr noundef nonnull %0, ptr noundef %15, ptr noundef nonnull %7)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = tail call i32 %18(ptr noundef %2) #3
  %20 = tail call ptr @_entry_add(ptr noundef nonnull %0, ptr noundef %2, i32 noundef %19)
  %.not35.not = icmp eq ptr %20, null
  br i1 %.not35.not, label %36, label %21

21:                                               ; preds = %8
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %0, i64 72
  %25 = load i8, ptr %24, align 8, !tbaa !17, !range !18, !noundef !19
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %29, label %27

27:                                               ; preds = %21
  %28 = load ptr, ptr %20, align 8, !tbaa !20
  br label %29

29:                                               ; preds = %21, %27
  %30 = phi ptr [ %28, %27 ], [ null, %21 ]
  %31 = getelementptr inbounds i8, ptr %20, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  tail call void %23(ptr noundef %30, ptr noundef %32) #3
  store ptr %2, ptr %20, align 8, !tbaa !20
  store ptr %17, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %0, i64 56
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %.not36 = icmp eq ptr %34, null
  br i1 %.not36, label %.thread, label %35

35:                                               ; preds = %29
  tail call void @_lru_entry_update(ptr noundef nonnull %0, ptr noundef nonnull %20)
  br label %.thread

36:                                               ; preds = %8
  %37 = tail call ptr @__errno_location() #4
  %38 = load i32, ptr %37, align 4, !tbaa !22
  %39 = tail call i64 @iwrc_set_errno(i64 noundef 70001, i32 noundef %38) #3
  br label %.thread

.thread:                                          ; preds = %35, %29, %3, %36
  %.1 = phi i64 [ %39, %36 ], [ 0, %3 ], [ 0, %29 ], [ 0, %35 ]
  ret i64 %.1
}

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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 }
attributes #4 = { nounwind willreturn memory(none) }

!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 24}
!6 = !{!"iwhmap", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !11, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !7, i64 4}
!14 = !{!15, !10, i64 8}
!15 = !{!"entry", !10, i64 0, !10, i64 8, !10, i64 16, !7, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !11, i64 72}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!15, !10, i64 0}
!21 = !{!6, !10, i64 56}
!22 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass