; LLVM IR from LeoVen/C-Macro-Collections :: tests (types)

; 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.hashmultiset0 = type { ptr, i64, i64, i64, double, i32, ptr, ptr }
%struct.hashmultiset0_entry = type { ptr, i64, i64, 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 @hms0_impl_insert_and_return(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hms0_update(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %45

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call ptr @hms0_impl_get_entry(ptr noundef %16, ptr noundef %17)
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  store i32 2, ptr %10, align 4
  br label %43

22:                                               ; preds = %15
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.hashmultiset0, ptr %23, i32 0, i32 2
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = add i64 %25, -1
  store i64 %26, ptr %24, align 8, !tbaa !11
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.hashmultiset0, ptr %30, i32 0, i32 3
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = sub i64 %32, %29
  store i64 %33, ptr %31, align 8, !tbaa !17
  store ptr null, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %35, i32 0, i32 0
  store ptr %34, ptr %36, align 8, !tbaa !18
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %37, i32 0, i32 1
  store i64 0, ptr %38, align 8, !tbaa !15
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %39, i32 0, i32 2
  store i64 0, ptr %40, align 8, !tbaa !19
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %41, i32 0, i32 3
  store i32 -1, ptr %42, align 8, !tbaa !20
  store i32 2, ptr %10, align 4
  br label %43

43:                                               ; preds = %22, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %44 = load i32, ptr %10, align 4
  switch i32 %44, label %80 [
    i32 2, label %75
  ]

45:                                               ; preds = %3
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call ptr @hms0_impl_insert_and_return(ptr noundef %46, ptr noundef %47, ptr noundef %11)
  store ptr %48, ptr %12, align 8, !tbaa !5
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %52, label %51

51:                                               ; preds = %45
  store i1 false, ptr %4, align 1
  br label %78

52:                                               ; preds = %45
  %53 = load i8, ptr %11, align 1, !tbaa !21, !range !23, !noundef !24
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %60

55:                                               ; preds = %52
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.hashmultiset0, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !17
  %59 = add i64 %58, 1
  store i64 %59, ptr %57, align 8, !tbaa !17
  br label %60

60:                                               ; preds = %55, %52
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.hashmultiset0, ptr %61, i32 0, i32 3
  %63 = load i64, ptr %62, align 8, !tbaa !17
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !15
  %67 = sub i64 %63, %66
  %68 = load i64, ptr %7, align 8, !tbaa !9
  %69 = add i64 %67, %68
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hashmultiset0, ptr %70, i32 0, i32 3
  store i64 %69, ptr %71, align 8, !tbaa !17
  %72 = load i64, ptr %7, align 8, !tbaa !9
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.hashmultiset0_entry, ptr %73, i32 0, i32 1
  store i64 %72, ptr %74, align 8, !tbaa !15
  br label %75

75:                                               ; preds = %60, %43
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.hashmultiset0, ptr %76, i32 0, i32 5
  store i32 0, ptr %77, align 8, !tbaa !25
  store i1 true, ptr %4, align 1
  br label %78

78:                                               ; preds = %75, %51
  %79 = load i1, ptr %4, align 1
  ret i1 %79

80:                                               ; preds = %43
  unreachable
}

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

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 }

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


; 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
declare hidden ptr @hms0_impl_insert_and_return(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hms0_update(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i8, align 1
  %5 = icmp eq i64 %2, 0
  br i1 %5, label %6, label %18

6:                                                ; preds = %3
  %7 = tail call ptr @hms0_impl_get_entry(ptr noundef %0, ptr noundef %1)
  %.not26 = icmp eq ptr %7, null
  br i1 %.not26, label %30, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = add i64 %10, -1
  store i64 %11, ptr %9, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %7, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !15
  %16 = sub i64 %15, %13
  store i64 %16, ptr %14, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %7, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, i8 0, i64 24, i1 false)
  store i32 -1, ptr %17, align 8, !tbaa !16
  br label %30

18:                                               ; preds = %3
  %19 = call ptr @hms0_impl_insert_and_return(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %4)
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %32, label %._crit_edge

._crit_edge:                                      ; preds = %18
  %20 = load i8, ptr %4, align 1, !tbaa !17, !range !19, !noundef !20
  %21 = zext nneg i8 %20 to i64
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !15
  %24 = add i64 %23, %21
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = getelementptr inbounds i8, ptr %19, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !13
  %28 = add i64 %24, %2
  %29 = sub i64 %28, %27
  store i64 %29, ptr %25, align 8, !tbaa !15
  store i64 %2, ptr %26, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %8, %6, %._crit_edge
  %31 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 0, ptr %31, align 8, !tbaa !21
  br label %32

32:                                               ; preds = %18, %30
  %.0 = phi i1 [ true, %30 ], [ false, %18 ]
  ret i1 %.0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass