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

%union.union_u = type { %struct.struct_s }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.hashmultiset6 = type { ptr, i64, i64, i64, double, i32, ptr, ptr }
%struct.hashmultiset6_entry = type { %union.union_u, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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
declare hidden ptr @hms6_impl_insert_and_return(ptr noundef, ptr noundef byval(%union.union_u) align 8, ptr noundef) #3

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

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call ptr @hms6_impl_get_entry(ptr noundef %15, ptr noundef byval(%union.union_u) align 8 %1)
  store ptr %16, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  store i32 2, ptr %9, align 4
  br label %40

20:                                               ; preds = %14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashmultiset6, ptr %21, i32 0, i32 2
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = add i64 %23, -1
  store i64 %24, ptr %22, align 8, !tbaa !11
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %25, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.hashmultiset6, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !17
  %31 = sub i64 %30, %27
  store i64 %31, ptr %29, align 8, !tbaa !17
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %32, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 104, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %33, ptr align 8 %8, i64 104, i1 false), !tbaa.struct !18
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %34, i32 0, i32 1
  store i64 0, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %36, i32 0, i32 2
  store i64 0, ptr %37, align 8, !tbaa !20
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %38, i32 0, i32 3
  store i32 -1, ptr %39, align 8, !tbaa !21
  store i32 2, ptr %9, align 4
  br label %40

40:                                               ; preds = %20, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %41 = load i32, ptr %9, align 4
  switch i32 %41, label %76 [
    i32 2, label %71
  ]

42:                                               ; preds = %3
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call ptr @hms6_impl_insert_and_return(ptr noundef %43, ptr noundef byval(%union.union_u) align 8 %1, ptr noundef %10)
  store ptr %44, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  store i1 false, ptr %4, align 1
  br label %74

48:                                               ; preds = %42
  %49 = load i8, ptr %10, align 1, !tbaa !22, !range !24, !noundef !25
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %56

51:                                               ; preds = %48
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.hashmultiset6, ptr %52, i32 0, i32 3
  %54 = load i64, ptr %53, align 8, !tbaa !17
  %55 = add i64 %54, 1
  store i64 %55, ptr %53, align 8, !tbaa !17
  br label %56

56:                                               ; preds = %51, %48
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.hashmultiset6, ptr %57, i32 0, i32 3
  %59 = load i64, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %60, i32 0, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !15
  %63 = sub i64 %59, %62
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = add i64 %63, %64
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.hashmultiset6, ptr %66, i32 0, i32 3
  store i64 %65, ptr %67, align 8, !tbaa !17
  %68 = load i64, ptr %6, align 8, !tbaa !9
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.hashmultiset6_entry, ptr %69, i32 0, i32 1
  store i64 %68, ptr %70, align 8, !tbaa !15
  br label %71

71:                                               ; preds = %56, %40
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.hashmultiset6, ptr %72, i32 0, i32 5
  store i32 0, ptr %73, align 8, !tbaa !26
  store i1 true, ptr %4, align 1
  br label %74

74:                                               ; preds = %71, %47
  %75 = load i1, ptr %4, align 1
  ret i1 %75

76:                                               ; preds = %40
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden ptr @hms6_impl_get_entry(ptr noundef, ptr noundef byval(%union.union_u) align 8) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"hashmultiset6", !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 104}
!16 = !{!"hashmultiset6_entry", !7, i64 0, !10, i64 104, !10, i64 112, !14, i64 120}
!17 = !{!12, !10, i64 24}
!18 = !{i64 0, i64 104, !19}
!19 = !{!7, !7, i64 0}
!20 = !{!16, !10, i64 112}
!21 = !{!16, !14, i64 120}
!22 = !{!23, !23, i64 0}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!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"

%union.union_u = type { %struct.struct_s }
%struct.struct_s = type { i32, i32, ptr, ptr, [10 x double] }

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @hms6_impl_insert_and_return(ptr noundef, ptr noundef byval(%union.union_u) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hms6_update(ptr noundef %0, ptr noundef byval(%union.union_u) align 8 %1, i64 noundef %2) local_unnamed_addr #1 {
  %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 @hms6_impl_get_entry(ptr noundef %0, ptr noundef nonnull byval(%union.union_u) align 8 %1)
  %.not23 = icmp eq ptr %7, null
  br i1 %.not23, 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 104
  %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 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(120) %7, i8 0, i64 120, i1 false)
  store i32 -1, ptr %17, align 8, !tbaa !16
  br label %30

18:                                               ; preds = %3
  %19 = call ptr @hms6_impl_insert_and_return(ptr noundef %0, ptr noundef nonnull byval(%union.union_u) align 8 %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 104
  %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 @hms6_impl_get_entry(ptr noundef, ptr noundef byval(%union.union_u) align 8) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 16}
!6 = !{!"hashmultiset6", !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 104}
!14 = !{!"hashmultiset6_entry", !8, i64 0, !10, i64 104, !10, i64 112, !12, i64 120}
!15 = !{!6, !10, i64 24}
!16 = !{!14, !12, i64 120}
!17 = !{!18, !18, i64 0}
!18 = !{!"_Bool", !8, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !12, i64 40}


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