; LLVM IR from BurntSushi/clibs :: libds (hashmap)

; 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.DSHashMap = type { ptr, ptr }
%struct.DSHashItem = type { ptr, ptr, ptr }
%struct.DSHashKey = type { ptr, i8, %union.anon }
%union.anon = type { ptr }

; 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
define dso_local void @ds_hashmap_free(ptr noundef %0, i1 noundef zeroext %1, i1 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %10 = zext i1 %1 to i8
  store i8 %10, ptr %5, align 1, !tbaa !9
  %11 = zext i1 %2 to i8
  store i8 %11, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %60, %3
  %13 = load i32, ptr %9, align 4, !tbaa !11
  %14 = icmp slt i32 %13, 1000000
  br i1 %14, label %15, label %63

15:                                               ; preds = %12
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.DSHashMap, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %9, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %18, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %22, ptr %7, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %53, %15
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %59

26:                                               ; preds = %23
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DSHashItem, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %46

32:                                               ; preds = %26
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DSHashItem, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = getelementptr inbounds %struct.DSHashKey, ptr %35, i32 0, i32 1
  %37 = load i8, ptr %36, align 8, !tbaa !20
  %38 = sext i8 %37 to i32
  %39 = icmp eq i32 %38, 2
  br i1 %39, label %40, label %46

40:                                               ; preds = %32
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.DSHashItem, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = getelementptr inbounds %struct.DSHashKey, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  call void @free(ptr noundef %45) #4
  br label %46

46:                                               ; preds = %40, %32, %26
  %47 = load i8, ptr %5, align 1, !tbaa !9, !range !17, !noundef !18
  %48 = trunc i8 %47 to i1
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.DSHashItem, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  call void @free(ptr noundef %52) #4
  br label %53

53:                                               ; preds = %49, %46
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.DSHashItem, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  call void @free(ptr noundef %56) #4
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %57) #4
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %58, ptr %7, align 8, !tbaa !5
  br label %23, !llvm.loop !24

59:                                               ; preds = %23
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %9, align 4, !tbaa !11
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %9, align 4, !tbaa !11
  br label %12, !llvm.loop !26

63:                                               ; preds = %12
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.DSHashMap, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !27
  call void @ds_vector_free_no_data(ptr noundef %66)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.DSHashMap, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  call void @free(ptr noundef %69) #4
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %70) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

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

declare void @ds_vector_free_no_data(ptr noundef) #3

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 = { 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 = { "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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"DSHashMap", !6, i64 0, !6, i64 8}
!15 = !{!16, !6, i64 16}
!16 = !{!"DSHashItem", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!16, !6, i64 0}
!20 = !{!21, !7, i64 8}
!21 = !{!"DSHashKey", !6, i64 0, !7, i64 8, !7, i64 16}
!22 = !{!7, !7, i64 0}
!23 = !{!16, !6, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = !{!14, !6, i64 0}


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

; Function Attrs: nounwind uwtable
define dso_local void @ds_hashmap_free(ptr nocapture noundef %0, i1 noundef zeroext %1, i1 noundef zeroext %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %2, label %.split.us, label %.split

.split.us:                                        ; preds = %3
  br i1 %1, label %.split.us.split.us, label %.split.us.split

.split.us.split.us:                               ; preds = %.split.us, %._crit_edge.split.us.us.split.us.us
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %._crit_edge.split.us.us.split.us.us ], [ 0, %.split.us ]
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv39
  %7 = load ptr, ptr %6, align 8, !tbaa !10
  %.not17.us.us = icmp eq ptr %7, null
  br i1 %.not17.us.us, label %._crit_edge.split.us.us.split.us.us, label %.lr.ph.us.us

._crit_edge.split.us.us.split.us.us:              ; preds = %17, %.split.us.split.us
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond42.not = icmp eq i64 %indvars.iv.next40, 1000000
  br i1 %exitcond42.not, label %.split23.us, label %.split.us.split.us, !llvm.loop !11

.lr.ph.us.us:                                     ; preds = %.split.us.split.us, %17
  %.01618.us.us.us.us = phi ptr [ %9, %17 ], [ %7, %.split.us.split.us ]
  %8 = getelementptr inbounds i8, ptr %.01618.us.us.us.us, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = load ptr, ptr %.01618.us.us.us.us, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i8, ptr %11, align 8, !tbaa !16
  %13 = icmp eq i8 %12, 2
  br i1 %13, label %14, label %17

14:                                               ; preds = %.lr.ph.us.us
  %15 = getelementptr inbounds i8, ptr %10, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !18
  tail call void @free(ptr noundef %16) #3
  br label %17

17:                                               ; preds = %14, %.lr.ph.us.us
  %18 = getelementptr inbounds i8, ptr %.01618.us.us.us.us, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  tail call void @free(ptr noundef %19) #3
  %20 = load ptr, ptr %.01618.us.us.us.us, align 8, !tbaa !15
  tail call void @free(ptr noundef %20) #3
  tail call void @free(ptr noundef nonnull %.01618.us.us.us.us) #3
  %.not.us.us.us.us = icmp eq ptr %9, null
  br i1 %.not.us.us.us.us, label %._crit_edge.split.us.us.split.us.us, label %.lr.ph.us.us, !llvm.loop !20

.split.us.split:                                  ; preds = %.split.us, %._crit_edge.split.us.us.split
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %._crit_edge.split.us.us.split ], [ 0, %.split.us ]
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv35
  %23 = load ptr, ptr %22, align 8, !tbaa !10
  %.not17.us = icmp eq ptr %23, null
  br i1 %.not17.us, label %._crit_edge.split.us.us.split, label %.lr.ph.us

._crit_edge.split.us.us.split:                    ; preds = %33, %.split.us.split
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %exitcond38.not = icmp eq i64 %indvars.iv.next36, 1000000
  br i1 %exitcond38.not, label %.split23.us, label %.split.us.split, !llvm.loop !11

.lr.ph.us:                                        ; preds = %.split.us.split, %33
  %.01618.us.us = phi ptr [ %25, %33 ], [ %23, %.split.us.split ]
  %24 = getelementptr inbounds i8, ptr %.01618.us.us, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = load ptr, ptr %.01618.us.us, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i8, ptr %27, align 8, !tbaa !16
  %29 = icmp eq i8 %28, 2
  br i1 %29, label %30, label %33

30:                                               ; preds = %.lr.ph.us
  %31 = getelementptr inbounds i8, ptr %26, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  tail call void @free(ptr noundef %32) #3
  %.pre = load ptr, ptr %.01618.us.us, align 8, !tbaa !15
  br label %33

33:                                               ; preds = %30, %.lr.ph.us
  %34 = phi ptr [ %.pre, %30 ], [ %26, %.lr.ph.us ]
  tail call void @free(ptr noundef %34) #3
  tail call void @free(ptr noundef nonnull %.01618.us.us) #3
  %.not.us.us = icmp eq ptr %25, null
  br i1 %.not.us.us, label %._crit_edge.split.us.us.split, label %.lr.ph.us, !llvm.loop !20

.split:                                           ; preds = %3
  br i1 %1, label %.split.split.us, label %.split.split

.split.split.us:                                  ; preds = %.split, %._crit_edge.split.split.us.us
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %._crit_edge.split.split.us.us ], [ 0, %.split ]
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %35, i64 %indvars.iv31
  %37 = load ptr, ptr %36, align 8, !tbaa !10
  %.not17.us25 = icmp eq ptr %37, null
  br i1 %.not17.us25, label %._crit_edge.split.split.us.us, label %.lr.ph.us26

._crit_edge.split.split.us.us:                    ; preds = %.lr.ph.us26, %.split.split.us
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %exitcond34.not = icmp eq i64 %indvars.iv.next32, 1000000
  br i1 %exitcond34.not, label %.split23.us, label %.split.split.us, !llvm.loop !11

.lr.ph.us26:                                      ; preds = %.split.split.us, %.lr.ph.us26
  %.01618.us19.us = phi ptr [ %39, %.lr.ph.us26 ], [ %37, %.split.split.us ]
  %38 = getelementptr inbounds i8, ptr %.01618.us19.us, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %.01618.us19.us, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  tail call void @free(ptr noundef %41) #3
  %42 = load ptr, ptr %.01618.us19.us, align 8, !tbaa !15
  tail call void @free(ptr noundef %42) #3
  tail call void @free(ptr noundef nonnull %.01618.us19.us) #3
  %.not.us20.us = icmp eq ptr %39, null
  br i1 %.not.us20.us, label %._crit_edge.split.split.us.us, label %.lr.ph.us26, !llvm.loop !20

.split.split:                                     ; preds = %.split, %._crit_edge.split.split
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge.split.split ], [ 0, %.split ]
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 %indvars.iv
  %45 = load ptr, ptr %44, align 8, !tbaa !10
  %.not17 = icmp eq ptr %45, null
  br i1 %.not17, label %._crit_edge.split.split, label %.lr.ph

.lr.ph:                                           ; preds = %.split.split, %.lr.ph
  %.01618 = phi ptr [ %47, %.lr.ph ], [ %45, %.split.split ]
  %46 = getelementptr inbounds i8, ptr %.01618, i64 16
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load ptr, ptr %.01618, align 8, !tbaa !15
  tail call void @free(ptr noundef %48) #3
  tail call void @free(ptr noundef nonnull %.01618) #3
  %.not = icmp eq ptr %47, null
  br i1 %.not, label %._crit_edge.split.split, label %.lr.ph, !llvm.loop !20

._crit_edge.split.split:                          ; preds = %.lr.ph, %.split.split
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1000000
  br i1 %exitcond.not, label %.split23.us, label %.split.split, !llvm.loop !11

.split23.us:                                      ; preds = %._crit_edge.split.split, %._crit_edge.split.split.us.us, %._crit_edge.split.us.us.split, %._crit_edge.split.us.us.split.us.us
  %49 = load ptr, ptr %0, align 8, !tbaa !21
  tail call void @ds_vector_free_no_data(ptr noundef %49) #3
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @free(ptr noundef %50) #3
  tail call void @free(ptr noundef %0) #3
  ret void
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

declare void @ds_vector_free_no_data(ptr noundef) local_unnamed_addr #2

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

!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, !7, i64 8}
!6 = !{!"DSHashMap", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !7, i64 16}
!14 = !{!"DSHashItem", !7, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!14, !7, i64 0}
!16 = !{!17, !8, i64 8}
!17 = !{!"DSHashKey", !7, i64 0, !8, i64 8, !8, i64 16}
!18 = !{!8, !8, i64 0}
!19 = !{!14, !7, i64 8}
!20 = distinct !{!20, !12}
!21 = !{!6, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass