; 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.struct_s = type { i32, i32, ptr, ptr, [10 x double] }
%struct.hashmultiset1 = type { ptr, i64, i64, i64, double, i32, ptr, ptr }
%struct.hashmultiset1_entry = type { %struct.struct_s, 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 @hms1_impl_insert_and_return(ptr noundef, ptr noundef byval(%struct.struct_s) align 8, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hms1_update(ptr noundef %0, ptr noundef byval(%struct.struct_s) 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 %struct.struct_s, 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 %47

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 @hms1_impl_get_entry(ptr noundef %15, ptr noundef byval(%struct.struct_s) 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 %45

20:                                               ; preds = %14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hashmultiset1, 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.hashmultiset1_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.hashmultiset1, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !18
  %31 = sub i64 %30, %27
  store i64 %31, ptr %29, align 8, !tbaa !18
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %32, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 104, i1 false)
  %34 = getelementptr inbounds %struct.struct_s, ptr %8, i32 0, i32 0
  %35 = getelementptr inbounds %struct.struct_s, ptr %8, i32 0, i32 1
  %36 = getelementptr inbounds %struct.struct_s, ptr %8, i32 0, i32 2
  %37 = getelementptr inbounds %struct.struct_s, ptr %8, i32 0, i32 3
  %38 = getelementptr inbounds %struct.struct_s, ptr %8, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %33, ptr align 8 %8, i64 104, i1 false), !tbaa.struct !19
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %39, i32 0, i32 1
  store i64 0, ptr %40, align 8, !tbaa !15
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %41, i32 0, i32 2
  store i64 0, ptr %42, align 8, !tbaa !22
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %43, i32 0, i32 3
  store i32 -1, ptr %44, align 8, !tbaa !23
  store i32 2, ptr %9, align 4
  br label %45

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

47:                                               ; preds = %3
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call ptr @hms1_impl_insert_and_return(ptr noundef %48, ptr noundef byval(%struct.struct_s) align 8 %1, ptr noundef %10)
  store ptr %49, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %53, label %52

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

53:                                               ; preds = %47
  %54 = load i8, ptr %10, align 1, !tbaa !24, !range !26, !noundef !27
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %61

56:                                               ; preds = %53
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.hashmultiset1, ptr %57, i32 0, i32 3
  %59 = load i64, ptr %58, align 8, !tbaa !18
  %60 = add i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !18
  br label %61

61:                                               ; preds = %56, %53
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.hashmultiset1, ptr %62, i32 0, i32 3
  %64 = load i64, ptr %63, align 8, !tbaa !18
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %65, i32 0, i32 1
  %67 = load i64, ptr %66, align 8, !tbaa !15
  %68 = sub i64 %64, %67
  %69 = load i64, ptr %6, align 8, !tbaa !9
  %70 = add i64 %68, %69
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.hashmultiset1, ptr %71, i32 0, i32 3
  store i64 %70, ptr %72, align 8, !tbaa !18
  %73 = load i64, ptr %6, align 8, !tbaa !9
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.hashmultiset1_entry, ptr %74, i32 0, i32 1
  store i64 %73, ptr %75, align 8, !tbaa !15
  br label %76

76:                                               ; preds = %61, %45
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.hashmultiset1, ptr %77, i32 0, i32 5
  store i32 0, ptr %78, align 8, !tbaa !28
  store i1 true, ptr %4, align 1
  br label %79

79:                                               ; preds = %76, %52
  %80 = load i1, ptr %4, align 1
  ret i1 %80

81:                                               ; preds = %45
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden ptr @hms1_impl_get_entry(ptr noundef, ptr noundef byval(%struct.struct_s) 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 = !{!"hashmultiset1", !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 = !{!"hashmultiset1_entry", !17, i64 0, !10, i64 104, !10, i64 112, !14, i64 120}
!17 = !{!"struct_s", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 16, !7, i64 24}
!18 = !{!12, !10, i64 24}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 80, !21}
!20 = !{!14, !14, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!16, !10, i64 112}
!23 = !{!16, !14, i64 120}
!24 = !{!25, !25, i64 0}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!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"

%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 @hms1_impl_insert_and_return(ptr noundef, ptr noundef byval(%struct.struct_s) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @hms1_update(ptr noundef %0, ptr noundef byval(%struct.struct_s) 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 @hms1_impl_get_entry(ptr noundef %0, ptr noundef nonnull byval(%struct.struct_s) 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 !16
  %16 = sub i64 %15, %13
  store i64 %16, ptr %14, align 8, !tbaa !16
  %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 !17
  br label %30

18:                                               ; preds = %3
  %19 = call ptr @hms1_impl_insert_and_return(ptr noundef %0, ptr noundef nonnull byval(%struct.struct_s) 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 !18, !range !20, !noundef !21
  %21 = zext nneg i8 %20 to i64
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !16
  %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 !16
  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 !22
  br label %32

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

; Function Attrs: nounwind uwtable
declare hidden ptr @hms1_impl_get_entry(ptr noundef, ptr noundef byval(%struct.struct_s) 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 = !{!"hashmultiset1", !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 = !{!"hashmultiset1_entry", !15, i64 0, !10, i64 104, !10, i64 112, !12, i64 120}
!15 = !{!"struct_s", !12, i64 0, !12, i64 4, !7, i64 8, !7, i64 16, !8, i64 24}
!16 = !{!6, !10, i64 24}
!17 = !{!14, !12, i64 120}
!18 = !{!19, !19, i64 0}
!19 = !{!"_Bool", !8, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!6, !12, i64 40}


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